diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-08-26 15:35:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-09-03 14:41:29 -0700 |
commit | 2079eb527ca3e25b0f5dfebd867cbc3efa9b6382 (patch) | |
tree | 91b4eabbb2494c3f40a7d5c3b73446cba1a95d64 /tests | |
parent | d0249dba76d07138e17ff1cf72d8b91b5a0c8da6 (diff) |
refactor dlfcn test code
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_core.py | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index 5e801646..ed026e6f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -5580,7 +5580,7 @@ The current type of b is: 9 Settings.RUNTIME_LINKED_LIBS = ['liblib.so']; self.do_run(main, 'supp: 54,2\nmain: 56\nsupp see: 543\nmain see: 76\nok.') - def test_dlfcn_basic(self): + def can_dlfcn(self): if self.emcc_args and '--memory-init-file' in self.emcc_args: for i in range(len(self.emcc_args)): if self.emcc_args[i] == '--memory-init-file': @@ -5592,6 +5592,31 @@ The current type of b is: 9 else: Settings.NAMED_GLOBALS = 1 + if not self.is_le32(): + self.skip('need le32 for dlfcn support') + return False + else: + return True + + def prep_dlfcn_lib(self): + if Settings.ASM_JS: + Settings.MAIN_MODULE = 0 + Settings.SIDE_MODULE = 1 + else: + Settings.BUILD_AS_SHARED_LIB = 1 + + def prep_dlfcn_main(self): + if Settings.ASM_JS: + Settings.MAIN_MODULE = 1 + Settings.SIDE_MODULE = 0 + else: + Settings.BUILD_AS_SHARED_LIB = 0 + + def test_dlfcn_basic(self): + if not self.can_dlfcn(): return + + self.prep_dlfcn_lib() + lib_src = ''' #include <cstdio> @@ -5606,13 +5631,11 @@ The current type of b is: 9 ''' dirname = self.get_dir() filename = os.path.join(dirname, 'liblib.cpp') - if Settings.ASM_JS: - Settings.SIDE_MODULE = 1 - else: - Settings.BUILD_AS_SHARED_LIB = 1 self.build(lib_src, dirname, filename) shutil.move(filename + '.o.js', os.path.join(dirname, 'liblib.so')) + self.prep_dlfcn_main() + src = ''' #include <cstdio> #include <dlfcn.h> @@ -5631,11 +5654,6 @@ The current type of b is: 9 return 0; } ''' - if Settings.ASM_JS: - Settings.MAIN_MODULE = 1 - Settings.SIDE_MODULE = 0 - else: - Settings.BUILD_AS_SHARED_LIB = 0 add_pre_run_and_checks = ''' def process(filename): src = open(filename, 'r').read().replace( |