diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 69 |
1 files changed, 43 insertions, 26 deletions
diff --git a/tests/runner.py b/tests/runner.py index 17b359a3..e6d5b330 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -266,6 +266,13 @@ process(sys.argv[1]) if output_processor is not None: output_processor(open(filename + '.o.js').read()) + if 0:# XXX TODO self.emcc_args is not None: + if '--memory-init-file' in self.emcc_args: + memory_init_file = int(self.emcc_args[self.emcc_args.index('--memory-init-file')+1]) + else: + memory_init_file = 1 + assert ('/* memory initializer */' in open(filename + '.o.js').read()) == (not memory_init_file) + 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') @@ -1977,7 +1984,6 @@ cat |umber one top notchfi FI FO FUM WHEN WHERE WHY HOW WHO|''', ['wowie', 'too' if self.emcc_args == []: gen = open(self.in_dir('src.cpp.o.js')).read() assert ('var __str1;' in gen) == named - assert (gen.count('ALLOC_NONE') < 8) == named def test_strcmp_uni(self): src = ''' @@ -6664,8 +6670,8 @@ localhost : 1 : 4 def test_799(self): src = open(path_from_root('tests', '799.cpp'), 'r').read() - self.do_run(src, '''Set PORT family: 100, port: 3979 -Get PORT family: 100 + self.do_run(src, '''Set PORT family: 0, port: 3979 +Get PORT family: 0 PORT: 3979 ''') @@ -8930,11 +8936,11 @@ TT = %s exec('o1 = make_run("o1", compiler=CLANG, emcc_args=["-O1", "-s", "SAFE_HEAP=1"])') # Make one run with -O2, but without closure (we enable closure in specific tests, otherwise on everything it is too slow) - exec('o2 = make_run("o2", compiler=CLANG, emcc_args=["-O2"])') + exec('o2 = make_run("o2", compiler=CLANG, emcc_args=["-O2", "-s", "JS_CHUNK_SIZE=1024"])') # 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", "-s", "ASSERTIONS=1"])') + exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "0"])') # Make custom runs with various options for compiler, quantum, embetter, typed_arrays, llvm_opts in [ @@ -9037,20 +9043,23 @@ Options that are modified or new in %s include: # emcc [..] -o [path] ==> should work with absolute paths try: - os.mkdir('a_dir') - os.chdir('a_dir') - os.mkdir('b_dir') for path in [os.path.abspath(os.path.join('..', 'file1.js')), os.path.join('b_dir', 'file2.js')]: + print path self.clear(in_curr=True) + os.chdir(self.get_dir()) + if not os.path.exists('a_dir'): os.mkdir('a_dir') + os.chdir('a_dir') + if not os.path.exists('b_dir'): os.mkdir('b_dir') output = Popen([PYTHON, compiler, path_from_root('tests', 'hello_world.ll'), '-o', path], stdout=PIPE, stderr=PIPE).communicate() + print output assert os.path.exists(path), path + ' does not exist; ' + '\n'.join(output) - self.assertContained('hello, world!', run_js(path)) + last = os.getcwd() + os.chdir(os.path.dirname(path)) + self.assertContained('hello, world!', run_js(os.path.basename(path))) + os.chdir(last) finally: os.chdir(self.get_dir()) - try: - shutil.rmtree('a_dir') - except: - pass + self.clear() # dlmalloc. dlmalloc is special in that it is the only part of libc that is (1) hard to write well, and # very speed-sensitive. So we do not implement it in JS in library.js, instead we compile it from source @@ -9994,7 +10003,8 @@ f.close() if no_initial_run: # Calling main later should still work, filesystem etc. must be set up. - src = open(os.path.join(self.get_dir(), 'a.out.js')).read() + '\n_main();\n'; + print 'call main later' + src = open(os.path.join(self.get_dir(), 'a.out.js')).read() + '\nModule.callMain();\n'; open(os.path.join(self.get_dir(), 'a.out.js'), 'w').write(src) assert 'hello from main' in run_js(os.path.join(self.get_dir(), 'a.out.js')), 'main should print when called manually' @@ -10113,12 +10123,14 @@ f.close() def test_chunking(self): if os.environ.get('EMCC_DEBUG'): return self.skip('cannot run in debug mode') + if os.environ.get('EMCC_CORES'): return self.skip('cannot run if cores are altered') if multiprocessing.cpu_count() < 2: return self.skip('need multiple cores') try: os.environ['EMCC_DEBUG'] = '1' + os.environ['EMCC_CORES'] = '2' for asm, linkable, chunks, js_chunks in [ - (0, 0, 3, 2), (0, 1, 4, 4), - (1, 0, 3, 2), (1, 1, 4, 4) + (0, 0, 3, 2), (0, 1, 3, 4), + (1, 0, 3, 2), (1, 1, 3, 4) ]: 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, '-s', 'UNRESOLVED_AS_DEAD=1'] + (['-O2'] if asm else []), stdout=PIPE, stderr=PIPE).communicate() @@ -10132,6 +10144,7 @@ f.close() assert ok, err finally: del os.environ['EMCC_DEBUG'] + del os.environ['EMCC_CORES'] def test_debuginfo(self): if os.environ.get('EMCC_DEBUG'): return self.skip('cannot run in debug mode') @@ -10350,11 +10363,11 @@ seeked= file. assert (' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' in err) == optimize_normally for last in ['both.o', 'both2.o']: - out, err = Popen([PYTHON, EMCC, self.in_dir('both.o'), '-O2', '-o', last + '.js'], stdout=PIPE, stderr=PIPE).communicate() + out, err = Popen([PYTHON, EMCC, self.in_dir('both.o'), '-O2', '-o', last + '.js', '--memory-init-file', '0'], stdout=PIPE, stderr=PIPE).communicate() assert ("emcc: LLVM opts: ['-O3']" not in err) == optimize_normally assert ' with -O3 since EMCC_OPTIMIZE_NORMALLY defined' not in err output = run_js(last + '.js') - assert 'yello' in output, 'code works' + assert 'yello' in output, 'code works ' + err assert open('both.o.js').read() == open('both2.o.js').read() finally: @@ -11259,6 +11272,18 @@ elif 'browser' in str(sys.argv): Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'openal_playback.cpp'), '--preload-file', 'audio.wav', '-o', 'page.html']).communicate() self.run_browser('page.html', '', '/report_result?1') + def test_glfw(self): + open(os.path.join(self.get_dir(), 'glfw.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'glfw.c')).read())) + + Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'glfw.c'), '-o', 'page.html']).communicate() + self.run_browser('page.html', '', '/report_result?1') + + def test_freealut(self): + programs = self.get_library('freealut', os.path.join('examples', 'hello_world.bc'), make_args=['EXEEXT=.bc']) + for program in programs: + Popen([PYTHON, EMCC, '-O2', program, '-o', 'page.html']).communicate() + self.run_browser('page.html', 'You should hear "Hello World!"') + def test_worker(self): # Test running in a web worker output = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_worker.cpp'), '-o', 'worker.js'], stdout=PIPE, stderr=PIPE).communicate() @@ -11416,14 +11441,6 @@ elif 'browser' in str(sys.argv): self.run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true') assert ('var GLEmulation' in open(self.in_dir('something.html')).read()) == emulation, "emulation code should be added when asked for" - def test_glgears_bad(self): - # Make sure that OpenGL ES is not available if typed arrays are not used - Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html', - '-DHAVE_BUILTIN_SINCOS', '-s', 'GL_TESTING=1', - '-s', 'USE_TYPED_ARRAYS=0', - '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')]).communicate() - self.run_browser('something.html', 'You should not see animating gears.', '/report_gl_result?false') - def test_glgears_deriv(self): self.reftest(path_from_root('tests', 'gears.png')) Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world_gles_deriv.c'), '-o', 'something.html', '-s', 'GL_TESTING=1', |