-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ThunksDB": { | ||
"fex_thunk_test": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
$info$ | ||
tags: thunklibs|fex_thunk_test | ||
$end_info$ | ||
*/ | ||
|
||
#include "common/Guest.h" | ||
#include "api.h" | ||
|
||
#include "thunkgen_guest_libfex_thunk_test.inl" | ||
|
||
LOAD_LIB(libfex_thunk_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
$info$ | ||
tags: thunklibs|fex_thunk_test | ||
$end_info$ | ||
*/ | ||
|
||
#include <cstddef> | ||
#include <dlfcn.h> | ||
|
||
#include "common/Host.h" | ||
|
||
#include "api.h" | ||
|
||
#include "thunkgen_host_libfex_thunk_test.inl" | ||
|
||
EXPORTS(libfex_thunk_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* This file defines interfaces of a dummy library used to test various | ||
* features of the thunk generator. | ||
*/ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
extern "C" { | ||
|
||
uint32_t GetDoubledValue(uint32_t); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "api.h" | ||
|
||
extern "C" { | ||
|
||
uint32_t GetDoubledValue(uint32_t input) { | ||
return 2 * input; | ||
} | ||
|
||
} // extern "C" |
14 changes: 14 additions & 0 deletions
14
ThunkLibs/libfex_thunk_test/libfex_thunk_test_interface.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <common/GeneratorInterface.h> | ||
|
||
#include "api.h" | ||
|
||
template<auto> | ||
struct fex_gen_config {}; | ||
|
||
template<typename> | ||
struct fex_gen_type {}; | ||
|
||
template<auto, int, typename> | ||
struct fex_gen_param {}; | ||
|
||
template<> struct fex_gen_config<GetDoubledValue> {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <dlfcn.h> | ||
|
||
#include <stdexcept> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
#include "../../../../ThunkLibs/libfex_thunk_test/api.h" | ||
|
||
struct Fixture { | ||
void* lib = []() { | ||
auto ret = dlopen("libfex_thunk_test.so", RTLD_LAZY); | ||
if (!ret) { | ||
throw std::runtime_error("Failed to open lib\n"); | ||
} | ||
return ret; | ||
}(); | ||
|
||
#define GET_SYMBOL(name) decltype(&::name) name = (decltype(name))dlsym(lib, #name) | ||
GET_SYMBOL(GetDoubledValue); | ||
}; | ||
|
||
TEST_CASE_METHOD(Fixture, "Trivial") { | ||
CHECK(GetDoubledValue(10) == 20); | ||
} |