diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 14:52:11 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:59 +0200 |
commit | d3ddeed8669e4b7cc2b3b1f8a2ab9b916059f342 (patch) | |
tree | b9ade6d1cb34486ed719988a9509927036e8cd1d | |
parent | 0fc6c9d2e6356e5b39328f4c93255cc34e0acd72 (diff) |
Use do_run_from_file() for test_dlfcn_self
-rw-r--r-- | tests/core/test_dlfcn_self.in | 24 | ||||
-rw-r--r-- | tests/core/test_dlfcn_self.out | 2 | ||||
-rw-r--r-- | tests/test_core.py | 29 |
3 files changed, 30 insertions, 25 deletions
diff --git a/tests/core/test_dlfcn_self.in b/tests/core/test_dlfcn_self.in new file mode 100644 index 00000000..687c4d6f --- /dev/null +++ b/tests/core/test_dlfcn_self.in @@ -0,0 +1,24 @@ + +#include <stdio.h> +#include <dlfcn.h> +#include <emscripten.h> + +int EMSCRIPTEN_KEEPALIVE global = 123; + +extern "C" EMSCRIPTEN_KEEPALIVE void foo(int x) { +printf("%d\n", x); +} + +extern "C" EMSCRIPTEN_KEEPALIVE void repeatable() { +void* self = dlopen(NULL, RTLD_LAZY); +int* global_ptr = (int*)dlsym(self, "global"); +void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo"); +foo_ptr(*global_ptr); +dlclose(self); +} + +int main() { +repeatable(); +repeatable(); +return 0; +}
\ No newline at end of file diff --git a/tests/core/test_dlfcn_self.out b/tests/core/test_dlfcn_self.out new file mode 100644 index 00000000..4ca9456b --- /dev/null +++ b/tests/core/test_dlfcn_self.out @@ -0,0 +1,2 @@ +123 +123
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index ea25d83f..572e2585 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3067,30 +3067,6 @@ def process(filename): if Settings.USE_TYPED_ARRAYS == 1: return self.skip('Does not work with USE_TYPED_ARRAYS=1') Settings.DLOPEN_SUPPORT = 1 - src = r''' -#include <stdio.h> -#include <dlfcn.h> -#include <emscripten.h> - -int EMSCRIPTEN_KEEPALIVE global = 123; - -extern "C" EMSCRIPTEN_KEEPALIVE void foo(int x) { -printf("%d\n", x); -} - -extern "C" EMSCRIPTEN_KEEPALIVE void repeatable() { -void* self = dlopen(NULL, RTLD_LAZY); -int* global_ptr = (int*)dlsym(self, "global"); -void (*foo_ptr)(int) = (void (*)(int))dlsym(self, "foo"); -foo_ptr(*global_ptr); -dlclose(self); -} - -int main() { -repeatable(); -repeatable(); -return 0; -}''' def post(filename): with open(filename) as f: for line in f: @@ -3102,8 +3078,11 @@ return 0; table = table[table.find('{'):table.rfind('}')+1] # ensure there aren't too many globals; we don't want unnamed_addr assert table.count(',') <= 4 - self.do_run(src, '123\n123', post_build=(None, post)) + test_path = path_from_root('tests', 'core', 'test_dlfcn_self') + src, output = (test_path + s for s in ('.in', '.out')) + + self.do_run_from_file(src, output, post_build=(None, post)) def test_dlfcn_unique_sig(self): if not self.can_dlfcn(): return |