diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/runner.py b/tests/runner.py index 7eacd059..335d7d4b 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -8605,9 +8605,43 @@ def process(filename): open('dead_funcs', 'w').write(pgo_output[pgo_output.find('['):-1]) self.emcc_args += ['-s', 'DEAD_FUNCTIONS=@' + self.in_dir('dead_funcs')] self.do_run(src, output) + self.emcc_args.pop() + self.emcc_args.pop() + shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed2.js')) + assert open('pgoed.js').read() == open('pgoed2.js').read() + + # with relative response in settings element itself + + open('dead_funcs', 'w').write(pgo_output[pgo_output.find('['):-1]) + self.emcc_args += ['-s', 'DEAD_FUNCTIONS=@dead_funcs'] + self.do_run(src, output) + self.emcc_args.pop() + self.emcc_args.pop() shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed2.js')) assert open('pgoed.js').read() == open('pgoed2.js').read() + def test_exported_response(self): + if self.emcc_args is None: return self.skip('requires emcc') + + src = r''' + #include <stdio.h> + #include <stdlib.h> + + extern "C" { + int other_function() { return 5; } + } + + int main() { + printf("waka!\n"); + return 0; + } + ''' + open('exps', 'w').write('["_main","_other_function"]') + + self.emcc_args += ['-s', 'EXPORTED_FUNCTIONS=@exps'] + self.do_run(src, '''waka!''') + assert 'other_function' in open('src.cpp.o.js').read() + def test_add_function(self): if self.emcc_args is None: return self.skip('requires emcc') @@ -11469,6 +11503,12 @@ elif 'browser' in str(sys.argv): Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', os.path.join(self.get_dir(), 'somefile.txt'), '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + # By ./path + + make_main('somefile.txt') + Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', './somefile.txt', '-o', 'page.html']).communicate() + self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + # Should still work with -o subdir/.. make_main(os.path.join(self.get_dir(), 'somefile.txt')) @@ -13063,6 +13103,11 @@ elif 'benchmark' in str(sys.argv): src = open(path_from_root('tests', 'life.c'), 'r').read() self.do_benchmark('life', src, '''--------------------------------''', shared_args=['-std=c99'], force_c=True) + def test_linpack(self): + def output_parser(output): + return 100.0/float(re.search('Unrolled Double Precision +([\d\.]+) Mflops', output).group(1)) + self.do_benchmark('linpack', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Double Precision''', force_c=True, output_parser=output_parser) + def test_zzz_java_nbody(self): # tests xmlvm compiled java, including bitcasts of doubles, i64 math, etc. args = [path_from_root('tests', 'nbody-java', x) for x in os.listdir(path_from_root('tests', 'nbody-java')) if x.endswith('.c')] + \ ['-I' + path_from_root('tests', 'nbody-java')] @@ -13086,7 +13131,7 @@ elif 'benchmark' in str(sys.argv): def test_zzz_lua_scimark(self): def output_parser(output): - return 1.0/float(re.search('\nSciMark +([\d\.]+) ', output).group(1)) + return 100.0/float(re.search('\nSciMark +([\d\.]+) ', output).group(1)) self.lua('scimark', '[small problem sizes]', output_parser=output_parser) |