diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/tests/runner.py b/tests/runner.py index eb0f8e7b..89ddf2ac 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7697,7 +7697,7 @@ def process(filename): Settings.DEAD_FUNCTIONS = [] # Run the same code with argc that uses the dead function, see abort - test(('ReferenceError: _unused is not defined', 'is not a function'), args=['a', 'b'], no_build=True) + test(('abort', 'is not a function'), args=['a', 'b'], no_build=True) # Normal stuff run_all('normal', r''' @@ -7742,6 +7742,44 @@ def process(filename): } ''') + def test_asm_pgo(self): + if not Settings.ASM_JS: return self.skip('this is a test for PGO for asm (NB: not *in* asm)') + + src = open(path_from_root('tests', 'hello_libcxx.cpp')).read() + output = 'hello, world!' + + self.do_run(src, output) + shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('normal.js')) + + self.emcc_args = map(lambda x: 'ASM_JS=0' if x == 'ASM_JS=1' else x, self.emcc_args) + Settings.PGO = 1 + self.do_run(src, output) + Settings.PGO = 0 + self.emcc_args = map(lambda x: 'ASM_JS=1' if x == 'ASM_JS=0' else x, self.emcc_args) + + shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgo.js')) + pgo_output = run_js(self.in_dir('pgo.js')).split('\n')[1] + open('pgo_data', 'w').write(pgo_output) + + # with response file + + self.emcc_args += ['@pgo_data'] + self.do_run(src, output) + self.emcc_args.pop() + shutil.move(self.in_dir('src.cpp.o.js'), self.in_dir('pgoed.js')) + + before = len(open('normal.js').read()) + after = len(open('pgoed.js').read()) + assert after < 0.66 * before, [before, after] # expect a big size reduction + + # with response in settings element itself + + 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) + 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_scriptaclass(self): if self.emcc_args is None: return self.skip('requires emcc') if Settings.ASM_JS: return self.skip('asm does not bindings generator yet') @@ -8608,7 +8646,7 @@ TT = %s # asm.js exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1"])') - exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g"])') + exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1"])') # Make custom runs with various options for compiler, quantum, embetter, typed_arrays, llvm_opts in [ @@ -9039,22 +9077,6 @@ f.close() assert debug_size > unminified_size assert 'function _malloc' in src - def test_asm_pgo(self): - Popen([PYTHON, EMXX, '-O2', '-s', 'ASM_JS=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'normal.js']).communicate() - self.assertContained('hello, world!', run_js(self.in_dir('normal.js'))) - - Popen([PYTHON, EMXX, '-O2', '-s', 'PGO=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'pgo.js']).communicate() - pgo_output = run_js(self.in_dir('pgo.js')) - self.assertContained('hello, world!', pgo_output) - - open('pgo_data', 'w').write(pgo_output.split('\n')[1]) - Popen([PYTHON, EMXX, '-O2', '-s', 'ASM_JS=1', path_from_root('tests', 'hello_libcxx.cpp'), '-o', 'pgoed.js', '@pgo_data']).communicate() - self.assertContained('hello, world!', run_js(self.in_dir('pgoed.js'))) - - before = len(open('normal.js').read()) - after = len(open('pgoed.js').read()) - assert after < 0.66 * before, [before, after] # expect a big size reduction - def test_l_link(self): # Linking with -lLIBNAME and -L/DIRNAME should work @@ -9806,8 +9828,8 @@ f.close() try: os.environ['EMCC_DEBUG'] = '1' for asm, linkable, chunks, js_chunks in [ - (0, 0, 3, 2), (0, 1, 3, 4), - (1, 0, 3, 2), (1, 1, 3, 4) + (0, 0, 3, 2), (0, 1, 4, 4), + (1, 0, 3, 2), (1, 1, 4, 5) ]: print asm, linkable, chunks, js_chunks output, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_libcxx.cpp'), '-O1', '-s', 'LINKABLE=%d' % linkable, '-s', 'ASM_JS=%d' % asm], stdout=PIPE, stderr=PIPE).communicate() @@ -10779,6 +10801,15 @@ elif 'browser' in str(sys.argv): Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio.c'), '--preload-file', 'sound.ogg', '--preload-file', 'sound2.wav', '--preload-file', 'bad.ogg', '-o', 'page.html', '-s', 'EXPORTED_FUNCTIONS=["_main", "_play", "_play2"]']).communicate() self.run_browser('page.html', '', '/report_result?1') + def test_sdl_audio_mix(self): + shutil.copyfile(path_from_root('tests', 'sounds', 'pluck.ogg'), os.path.join(self.get_dir(), 'sound.ogg')) + shutil.copyfile(path_from_root('tests', 'sounds', 'the_entertainer.ogg'), os.path.join(self.get_dir(), 'music.ogg')) + open(os.path.join(self.get_dir(), 'sdl_audio_mix.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_mix.c')).read())) + + # use closure to check for a possible bug with closure minifying away newer Audio() attributes + Popen([PYTHON, EMCC, '-O2', '--minify', '0', os.path.join(self.get_dir(), 'sdl_audio_mix.c'), '--preload-file', 'sound.ogg', '--preload-file', 'music.ogg', '-o', 'page.html']).communicate() + self.run_browser('page.html', '', '/report_result?1') + def test_sdl_audio_quickload(self): open(os.path.join(self.get_dir(), 'sdl_audio_quickload.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_audio_quickload.c')).read())) @@ -10991,11 +11022,12 @@ elif 'browser' in str(sys.argv): self.run_browser('something.html', 'You should see animating gears.', '/report_result?0') def test_glgears_animation(self): - for full_es2 in [0, 1]: + es2_suffix = ['', '_full', '_full_944'] + for full_es2 in [0, 1, 2]: for emulation in [0, 1]: if full_es2 and emulation: continue print full_es2, emulation - Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles%s.c' % ('' if not full_es2 else '_full')), '-o', 'something.html', + Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles%s.c' % es2_suffix[full_es2]), '-o', 'something.html', '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1', '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')] + (['-s', 'FORCE_GL_EMULATION=1'] if emulation else []) + |