diff options
author | Jez Ng <me@jezng.com> | 2013-07-09 07:02:47 -0700 |
---|---|---|
committer | Jez Ng <me@jezng.com> | 2013-07-11 20:37:57 -0700 |
commit | c1e1d87bc3b9e249795543e44a1224c2f03154ce (patch) | |
tree | 3f8506715b75acdf97e68dfdc3e4c1a35ffccb5a /tests/runner.py | |
parent | 9f9af4cefb142960cad37b3f43f4777e4334f2f2 (diff) |
Implement self-dlopen.
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index b21eee08..a892eb56 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5885,6 +5885,35 @@ def process(filename): self.do_run(src, '100\n200\n13\n42\n', post_build=add_pre_run_and_checks) + def test_dlfcn_self(self): + if Settings.USE_TYPED_ARRAYS == 1: return self.skip('Does not work with USE_TYPED_ARRAYS=1') + Settings.LINKABLE = 1 + + src = r''' +#include <stdio.h> +#include <dlfcn.h> + +int global = 123; + +extern "C" __attribute__((noinline)) void foo(int x) { + printf("%d\n", x); +} + +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; +}''' + self.do_run(src, '123\n123') + def test_rand(self): return self.skip('rand() is now random') # FIXME |