diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-11 15:21:51 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-11 15:21:51 -0500 |
commit | b0098a4be7c3198e67529f6f50ab7e39e79e69cb (patch) | |
tree | 72668719882b30abb4fbc1f3a2456fcbe989adf6 | |
parent | f377f670ccc0439bdb7c065e0671342c96713e6b (diff) |
refactor runtimelink test
-rwxr-xr-x | tests/runner.py | 115 |
1 files changed, 62 insertions, 53 deletions
diff --git a/tests/runner.py b/tests/runner.py index b64d8056..34e617d5 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -102,6 +102,9 @@ class RunnerCore(unittest.TestCase): def get_dir(self): return self.working_dir + def in_dir(self, *pathelems): + return os.path.join(self.get_dir(), *pathelems) + def get_shared_library_name(self, linux_name): if platform.system() == 'Linux': return linux_name @@ -325,6 +328,58 @@ process(sys.argv[1]) for name in os.listdir(EMSCRIPTEN_TEMP_DIR): try_delete(os.path.join(EMSCRIPTEN_TEMP_DIR, name)) + # Shared test code between main suite and others + + def setup_runtimelink_test(self): + header = r''' + struct point + { + int x, y; + }; + + ''' + open(os.path.join(self.get_dir(), 'header.h'), 'w').write(header) + + supp = r''' + #include <stdio.h> + #include "header.h" + + extern void mainFunc(int x); + extern int mainInt; + + void suppFunc(struct point &p) { + printf("supp: %d,%d\n", p.x, p.y); + mainFunc(p.x+p.y); + printf("supp see: %d\n", mainInt); + } + + int suppInt = 76; + ''' + supp_name = os.path.join(self.get_dir(), 'supp.c') + open(supp_name, 'w').write(supp) + + main = r''' + #include <stdio.h> + #include "header.h" + + extern void suppFunc(struct point &p); + extern int suppInt; + + void mainFunc(int x) { + printf("main: %d\n", x); + } + + int mainInt = 543; + + int main( int argc, const char *argv[] ) { + struct point p = { 54, 2 }; + suppFunc(p); + printf("main see: %d\nok.\n", suppInt); + return 0; + } + ''' + + return (main, supp) ################################################################################################### @@ -3432,62 +3487,14 @@ def process(filename): def test_runtimelink(self): if Building.LLVM_OPTS: return self.skip('LLVM opts will optimize printf into puts in the parent, and the child will still look for puts') - Settings.LINKABLE = 1 + main, supp = self.setup_runtimelink_test() self.banned_js_engines = [NODE_JS] # node's global scope behaves differently than everything else, needs investigation FIXME - - header = r''' - struct point - { - int x, y; - }; - - ''' - open(os.path.join(self.get_dir(), 'header.h'), 'w').write(header) - - supp = r''' - #include <stdio.h> - #include "header.h" - - extern void mainFunc(int x); - extern int mainInt; - - void suppFunc(struct point &p) { - printf("supp: %d,%d\n", p.x, p.y); - mainFunc(p.x+p.y); - printf("supp see: %d\n", mainInt); - } - - int suppInt = 76; - ''' - supp_name = os.path.join(self.get_dir(), 'supp.c') - open(supp_name, 'w').write(supp) - - main = r''' - #include <stdio.h> - #include "header.h" - - extern void suppFunc(struct point &p); - extern int suppInt; - - void mainFunc(int x) { - printf("main: %d\n", x); - } - - int mainInt = 543; - - int main( int argc, const char *argv[] ) { - struct point p = { 54, 2 }; - suppFunc(p); - printf("main see: %d\nok.\n", suppInt); - return 0; - } - ''' - + Settings.LINKABLE = 1 Settings.BUILD_AS_SHARED_LIB = 2 - dirname = self.get_dir() - self.build(supp, dirname, supp_name) - shutil.move(supp_name + '.o.js', os.path.join(dirname, 'liblib.so')) + + self.build(supp, self.get_dir(), self.in_dir('supp.c')) + shutil.move(self.in_dir('supp.c.o.js'), self.in_dir('liblib.so')) Settings.BUILD_AS_SHARED_LIB = 0 Settings.RUNTIME_LINKED_LIBS = ['liblib.so']; @@ -8616,6 +8623,8 @@ elif 'browser' in str(sys.argv): def test_float_tex(self): self.btest('float_tex.cpp', reference='float_tex.png') + #def test_runtimelink(self): + def test_pre_run_deps(self): # Adding a dependency in preRun will delay run open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' |