diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-25 16:10:37 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:03 -0700 |
commit | 3e031879b5335d5c5dafc3747fb475391daaf5e6 (patch) | |
tree | 762a852f0d512b29237482d53088d01969a3a398 | |
parent | 8c72d6795373155b79141c5092aa25d3f217d233 (diff) |
first working static linking test
-rwxr-xr-x | tests/runner.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tests/runner.py b/tests/runner.py index cb2b7e02..3239858b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -265,6 +265,12 @@ process(sys.argv[1]) else: assert 'memory initializer */' in open(filename + '.o.js').read() + def validate_asmjs(self, err): + if 'uccessfully compiled asm.js code' in err and 'asm.js link error' not in err: + print >> sys.stderr, "[was asm.js'ified]" + elif 'asm.js' in err: # if no asm.js error, then not an odin build + raise Exception("did NOT asm.js'ify") + def run_generated_code(self, engine, filename, args=[], check_timeout=True, output_nicerizer=None): stdout = os.path.join(self.get_dir(), 'stdout') # use files, as PIPE can get too full and hang us stderr = os.path.join(self.get_dir(), 'stderr') @@ -279,10 +285,7 @@ process(sys.argv[1]) out = open(stdout, 'r').read() err = open(stderr, 'r').read() if engine == SPIDERMONKEY_ENGINE and Settings.ASM_JS: - if 'uccessfully compiled asm.js code' in err and 'asm.js link error' not in err: - print >> sys.stderr, "[was asm.js'ified]" - elif 'asm.js' in err: # if no asm.js error, then not an odin build - raise Exception("did NOT asm.js'ify") + self.validate_asmjs(err) if output_nicerizer: ret = output_nicerizer(out, err) else: @@ -10608,24 +10611,24 @@ f.close() def test_static_link(self): open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(''' - extern void printey(); + #include <stdio.h> + extern int sidey(); int main() { - printey(); + printf("side says %d.", sidey()); return 0; } ''') open(os.path.join(self.get_dir(), 'side.cpp'), 'w').write(''' - #include <stdio.h> - void printey() { - printf("hello from side\\n"); - } + int sidey() { return 11; } ''') Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'side.cpp'), '-o', 'side.js', '-s', 'SIDE_MODULE=1', '-O2']).communicate() # TODO: test with and without DISABLE_GL_EMULATION, check that file sizes change Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-o', 'main.js', '-s', 'MAIN_MODULE=1', '-O2', '-s', 'DISABLE_GL_EMULATION=1']).communicate() Popen([PYTHON, EMLINK, 'main.js', 'side.js', 'together.js']).communicate() assert os.path.exists('together.js') - self.assertContained('hello from side', run_js('together.js')) + out = run_js('together.js', engine=SPIDERMONKEY_ENGINE, stderr=PIPE, full_output=True) + self.assertContained('side says 11.', out) + self.validate_asmjs(out) def test_symlink(self): if os.name == 'nt': |