aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-15 15:24:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-15 15:24:54 -0700
commit6e7a7aa3e8c2096463fed1f24d561557f49787f8 (patch)
treef81ea4377db6d4fd1b002cb55875d2291b71b62e /tests/runner.py
parent9bf755607fc7a0e7f446a5e2d6c82738d77d876f (diff)
parent61c31f69359132e7630a9c4c2c3d25a6ed742247 (diff)
Merge branch 'self-dlopen' of github.com:int3/emscripten into incoming
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 0efcce86..c08434f5 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6021,6 +6021,50 @@ 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.DLOPEN_SUPPORT = 1
+
+ src = r'''
+#include <stdio.h>
+#include <dlfcn.h>
+
+int global = 123;
+
+extern "C" __attribute__((noinline)) void foo(int x) {
+ printf("%d\n", x);
+}
+
+extern "C" __attribute__((noinline)) 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:
+ if 'var SYMBOL_TABLE' in line:
+ table = line
+ break
+ else:
+ raise Exception('Could not find symbol table!')
+ import json
+ table = json.loads(table[table.find('{'):table.rfind('}')+1])
+ actual = list(sorted(table.keys()))
+ # ensure there aren't too many globals; we don't want unnamed_addr
+ assert actual == ['_foo', '_global', '_main', '_repeatable'], \
+ "Symbol table does not match: %s" % actual
+
+ self.do_run(src, '123\n123', post_build=(None, post))
+
def test_rand(self):
return self.skip('rand() is now random') # FIXME