diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-09-04 17:28:08 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-04 17:28:08 -0700 |
commit | ce8acc241ac5638f4c4914c05c6ff615cf3937eb (patch) | |
tree | 7dc98ef5985276174bc314a7fcd7526cbc65de41 | |
parent | b1481dda9cd026d47eb1999dbde3ad34a0097c74 (diff) |
dlopen+exceptions+asm is not supported yet
-rwxr-xr-x | emcc | 3 | ||||
-rw-r--r-- | tests/test_core.py | 69 |
2 files changed, 72 insertions, 0 deletions
@@ -1125,6 +1125,9 @@ try: else: logging.debug('using response file for EXPORTED_FUNCTIONS, make sure it includes _malloc and _free') + if shared.Settings.ASM_JS and shared.Settings.DLOPEN_SUPPORT: + assert shared.Settings.DISABLE_EXCEPTION_CATCHING, 'no exceptions support with dlopen in asm yet' + ## Compile source code to bitcode logging.debug('compiling to bitcode') diff --git a/tests/test_core.py b/tests/test_core.py index fca58e60..0df4eeef 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -6226,6 +6226,75 @@ ok Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc', '_free'] self.do_run(src, '''*294,153*''', force_c=True, post_build=self.dlfcn_post_build) + def zzztest_dlfcn_exceptions(self): # TODO: make this work. need to forward tempRet0 across modules + if not self.can_dlfcn(): return + + Settings.DISABLE_EXCEPTION_CATCHING = 0 + + self.prep_dlfcn_lib() + lib_src = r''' + extern "C" { + int ok() { + return 65; + } + int fail() { + throw 123; + } + } + ''' + Settings.EXPORTED_FUNCTIONS = ['_ok', '_fail'] + dirname = self.get_dir() + filename = os.path.join(dirname, 'liblib.cpp') + self.build(lib_src, dirname, filename) + shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so')) + + self.prep_dlfcn_main() + src = r''' + #include <assert.h> + #include <stdio.h> + #include <dlfcn.h> + + typedef int (*intfunc)(); + + int main() { + printf("go!\n"); + + void *lib_handle; + lib_handle = dlopen("liblib.so", RTLD_NOW); + assert(lib_handle != NULL); + + intfunc okk = (intfunc)dlsym(lib_handle, "ok"); + intfunc faill = (intfunc)dlsym(lib_handle, "fail"); + assert(okk && faill); + + try { + printf("ok: %d\n", okk()); + } catch(...) { + printf("wha\n"); + } + + try { + printf("fail: %d\n", faill()); + } catch(int x) { + printf("int %d\n", x); + } + + try { + printf("fail: %d\n", faill()); + } catch(double x) { + printf("caught %f\n", x); + } + + return 0; + } + ''' + Settings.EXPORTED_FUNCTIONS = ['_main', '_malloc', '_free'] + self.do_run(src, '''go! +ok: 65 +int 123 +ok +''', post_build=self.dlfcn_post_build) + def test_rand(self): return self.skip('rand() is now random') # FIXME |