aboutsummaryrefslogtreecommitdiff
path: root/tests/runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-xtests/runner.py98
1 files changed, 78 insertions, 20 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 1f154aee..8a646524 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -428,7 +428,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
if len(sys.argv) == 2 and 'ALL.' in sys.argv[1]:
ignore, test = sys.argv[1].split('.')
print 'Running all test modes on test "%s"' % test
- sys.argv = [sys.argv[0], 'default.'+test, 'o1.'+test, 'o2.'+test, 's_0_0.'+test, 's_0_1.'+test, 's_0_1_q1.'+test, 's_1_0.'+test, 's_1_1.'+test, 's_1_1_q1.'+test]
+ sys.argv = [sys.argv[0], 'default.'+test, 'o1.'+test, 'o2.'+test, 'asm.'+test, 'asm2.'+test, 's_0_0.'+test, 's_0_1.'+test, 's_0_1_q1.'+test, 's_1_0.'+test, 's_1_1.'+test, 's_1_1_q1.'+test]
class T(RunnerCore): # Short name, to make it more fun to use manually on the commandline
## Does a complete test - builds, runs, checks output, etc.
@@ -836,6 +836,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
def test_i64_cmp2(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+
src = r'''
#include <inttypes.h>
#include <stdio.h>
@@ -881,6 +882,8 @@ m_divisor is 1091269979
def test_i64_double(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+
+
src = r'''
#include <stdio.h>
@@ -923,6 +926,7 @@ m_divisor is 1091269979
def test_i64_umul(self):
if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2')
+
src = r'''
#include <inttypes.h>
#include <stdio.h>
@@ -1193,6 +1197,7 @@ c5,de,15,8a
self.do_run(open(path_from_root('tests', 'cube2md5.cpp')).read(), open(path_from_root('tests', 'cube2md5.ok')).read())
def test_cube2hash(self):
+
try:
old_chunk_size = os.environ.get('EMSCRIPT_MAX_CHUNK_SIZE') or ''
os.environ['EMSCRIPT_MAX_CHUNK_SIZE'] = '1' # test splitting out each function to a chunk in emscripten.py (21 functions here)
@@ -1322,7 +1327,7 @@ c5,de,15,8a
# corrections otherwise
if Settings.USE_TYPED_ARRAYS == 2:
Settings.CORRECT_SIGNS = 0
- Settings.CHECK_SIGNS = 1
+ Settings.CHECK_SIGNS = 1 if not Settings.ASM_JS else 0
else:
Settings.CORRECT_SIGNS = 1
Settings.CHECK_SIGNS = 0
@@ -1998,6 +2003,8 @@ c5,de,15,8a
self.do_run(src, 'Assertion failed: 1 == false')
def test_longjmp(self):
+ if Settings.ASM_JS: return self.skip('asm does not support longjmp')
+
src = r'''
#include <stdio.h>
#include <setjmp.h>
@@ -2033,6 +2040,8 @@ c5,de,15,8a
self.do_run(src, 'second\nmain: 0\n')
def test_longjmp2(self):
+ if Settings.ASM_JS: return self.skip('asm does not support longjmp')
+
src = r'''
#include <setjmp.h>
#include <stdio.h>
@@ -2079,6 +2088,8 @@ Exiting stack_manipulate_func, level: 0
''')
def test_longjmp3(self):
+ if Settings.ASM_JS: return self.skip('asm does not support longjmp')
+
src = r'''
#include <setjmp.h>
#include <stdio.h>
@@ -2131,6 +2142,8 @@ Exiting setjmp function, level: 0
''')
def test_longjmp4(self):
+ if Settings.ASM_JS: return self.skip('asm does not support longjmp')
+
src = r'''
#include <setjmp.h>
#include <stdio.h>
@@ -2491,6 +2504,7 @@ Exiting setjmp function, level: 0, prev_jmp: -1
def test_segfault(self):
if self.emcc_args is None: return self.skip('SAFE_HEAP without ta2 means we check types too, which hide segfaults')
+ if Settings.ASM_JS: return self.skip('asm does not support safe heap')
Settings.SAFE_HEAP = 1
@@ -3035,7 +3049,7 @@ Exiting setjmp function, level: 0, prev_jmp: -1
emscripten_run_script("Module.print('hello world' + '!')");
printf("*%d*\n", emscripten_run_script_int("5*20"));
printf("*%s*\n", emscripten_run_script_string("'five'+'six'"));
- emscripten_run_script("_save_me_aimee()");
+ emscripten_run_script("Module['_save_me_aimee']()");
return 0;
}
'''
@@ -3045,7 +3059,7 @@ def process(filename):
src = open(filename, 'r').read()
# TODO: restore this (see comment in emscripten.h) assert '// hello from the source' in src
'''
-
+ Settings.EXPORTED_FUNCTIONS = ['_main', '_save_me_aimee']
self.do_run(src, 'hello world!\n*100*\n*fivesix*\nmann\n', post_build=check)
def test_inlinejs(self):
@@ -3069,6 +3083,7 @@ def process(filename):
def test_memorygrowth(self):
if Settings.USE_TYPED_ARRAYS == 0: return self.skip('memory growth is only supported with typed arrays')
+ if Settings.ASM_JS: return self.skip('asm does not support memory growth yet')
# With typed arrays in particular, it is dangerous to use more memory than TOTAL_MEMORY,
# since we then need to enlarge the heap(s).
@@ -3259,6 +3274,7 @@ def process(filename):
def test_varargs(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('FIXME: Add support for this')
+ if Settings.ASM_JS: return self.skip('varargs by function pointer not yet supported')
src = '''
#include <stdio.h>
@@ -3931,13 +3947,14 @@ The current type of b is: 9
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')
- if Settings.NAMED_GLOBALS == 0: return self.skip('dlopen cannot work without named globals, TODO')
+ if Settings.ASM_JS: return self.skip('asm does not support runtime linking')
main, supp = self.setup_runtimelink_test()
self.banned_js_engines = [NODE_JS] # node's global scope behaves differently than everything else, needs investigation FIXME
Settings.LINKABLE = 1
Settings.BUILD_AS_SHARED_LIB = 2
+ Settings.NAMED_GLOBALS = 1
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'))
@@ -3947,6 +3964,9 @@ The current type of b is: 9
self.do_run(main, 'supp: 54,2\nmain: 56\nsupp see: 543\nmain see: 76\nok.')
def test_dlfcn_basic(self):
+ if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
+
+ Settings.NAMED_GLOBALS = 1
Settings.LINKABLE = 1
lib_src = '''
@@ -3998,7 +4018,10 @@ def process(filename):
post_build=add_pre_run_and_checks)
def test_dlfcn_qsort(self):
+ if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
+
Settings.LINKABLE = 1
+ Settings.NAMED_GLOBALS = 1
if Settings.USE_TYPED_ARRAYS == 2:
Settings.CORRECT_SIGNS = 1 # Needed for unsafe optimizations
@@ -4090,10 +4113,11 @@ def process(filename):
post_build=add_pre_run_and_checks)
def test_dlfcn_data_and_fptr(self):
+ if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
if Building.LLVM_OPTS: return self.skip('LLVM opts will optimize out parent_func')
- if Settings.NAMED_GLOBALS == 0: return self.skip('dlopen cannot work without named globals, TODO')
Settings.LINKABLE = 1
+ Settings.NAMED_GLOBALS = 1
lib_src = '''
#include <stdio.h>
@@ -4193,10 +4217,12 @@ def process(filename):
post_build=add_pre_run_and_checks)
def test_dlfcn_alias(self):
+ if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
+
Settings.LINKABLE = 1
+ Settings.NAMED_GLOBALS = 1
if Building.LLVM_OPTS == 2: return self.skip('LLVM LTO will optimize away stuff we expect from the shared library')
- if Settings.NAMED_GLOBALS == 0: return self.skip('dlopen cannot work without named globals, TODO')
lib_src = r'''
#include <stdio.h>
@@ -4248,7 +4274,10 @@ def process(filename):
Settings.INCLUDE_FULL_LIBRARY = 0
def test_dlfcn_varargs(self):
+ if Settings.ASM_JS: return self.skip('TODO: dlopen in asm')
+
Settings.LINKABLE = 1
+ Settings.NAMED_GLOBALS = 1
if Building.LLVM_OPTS == 2: return self.skip('LLVM LTO will optimize things that prevent shared objects from working')
if Settings.QUANTUM_SIZE == 1: return self.skip('FIXME: Add support for this')
@@ -5379,6 +5408,7 @@ def process(filename):
}
'''
for linkable in [0, 1]:
+ print linkable
Settings.LINKABLE = linkable # regression check for issue #273
self.do_run(src, "1 2 3")
@@ -5958,9 +5988,10 @@ int main(int argc, char **argv) {
def test_dlmalloc(self):
if self.emcc_args is None: self.emcc_args = [] # dlmalloc auto-inclusion is only done if we use emcc
+ self.banned_js_engines = [NODE_JS] # slower, and fail on 64-bit
Settings.CORRECT_SIGNS = 2
Settings.CORRECT_SIGNS_LINES = ['src.cpp:' + str(i+4) for i in [4816, 4191, 4246, 4199, 4205, 4235, 4227]]
- Settings.TOTAL_MEMORY = 100*1024*1024 # needed with typed arrays
+ Settings.TOTAL_MEMORY = 128*1024*1024 # needed with typed arrays
src = open(path_from_root('system', 'lib', 'dlmalloc.c'), 'r').read() + '\n\n\n' + open(path_from_root('tests', 'dlmalloc_test.c'), 'r').read()
self.do_run(src, '*1,0*', ['200', '1'])
@@ -5975,7 +6006,7 @@ int main(int argc, char **argv) {
# emcc should build in dlmalloc automatically, and do all the sign correction etc. for it
try_delete(os.path.join(self.get_dir(), 'src.cpp.o.js'))
- output = Popen([PYTHON, EMCC, path_from_root('tests', 'dlmalloc_test.c'), '-s', 'TOTAL_MEMORY=100000000',
+ output = Popen([PYTHON, EMCC, path_from_root('tests', 'dlmalloc_test.c'), '-s', 'TOTAL_MEMORY=' + str(128*1024*1024),
'-o', os.path.join(self.get_dir(), 'src.cpp.o.js')], stdout=PIPE, stderr=self.stderr_redirect).communicate()
self.do_run('x', '*1,0*', ['200', '1'], no_build=True)
@@ -6162,7 +6193,9 @@ void*:16
self.do_run(src, '*10,22*')
def test_mmap(self):
- Settings.TOTAL_MEMORY = 100*1024*1024
+ self.banned_js_engines = [NODE_JS] # slower, and fail on 64-bit
+
+ Settings.TOTAL_MEMORY = 128*1024*1024
src = '''
#include <stdio.h>
@@ -6213,7 +6246,7 @@ void*:16
self.do_run(path_from_root('tests', 'cubescript'), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp')
def test_gcc_unmangler(self):
- Settings.NAMED_GLOBALS = 0 # test coverage for this
+ Settings.NAMED_GLOBALS = 1 # test coverage for this
Building.COMPILER_TEST_OPTS = ['-I' + path_from_root('third_party')]
@@ -6259,6 +6292,7 @@ void*:16
def test_freetype(self):
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix')
+ if Settings.ASM_JS: return self.skip('asm does not support longjmp')
if Settings.CORRECT_SIGNS == 0: Settings.CORRECT_SIGNS = 1 # Not sure why, but needed
@@ -6315,16 +6349,13 @@ def process(filename):
if self.emcc_args is None: return self.skip('Very slow without ta2, and we would also need to include dlmalloc manually without emcc')
if Settings.QUANTUM_SIZE == 1: return self.skip('TODO FIXME')
- pgo_data = read_pgo_data(path_from_root('tests', 'sqlite', 'sqlite-autooptimize.fails.txt'))
-
Settings.CORRECT_SIGNS = 1 # XXX: in default, we fail with 2 here, even though the pgo_data should be correct (and works in s_0_0). Investigate this.
- Settings.CORRECT_SIGNS_LINES = pgo_data['signs_lines']
Settings.CORRECT_OVERFLOWS = 0
Settings.CORRECT_ROUNDINGS = 0
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # uses time.h to set random bytes, other stuff
Settings.DISABLE_EXCEPTION_CATCHING = 1
Settings.FAST_MEMORY = 4*1024*1024
- Settings.EXPORTED_FUNCTIONS = ['_main', '_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_callback'];
+ Settings.EXPORTED_FUNCTIONS += ['_sqlite3_open', '_sqlite3_close', '_sqlite3_exec', '_sqlite3_free', '_callback'];
self.do_run(r'''
#define SQLITE_DISABLE_LFS
@@ -6370,6 +6401,7 @@ def process(filename):
def test_poppler(self):
if self.emcc_args is None: return self.skip('very slow, we only do this in emcc runs')
+ if Settings.ASM_JS: return self.skip('asm does not support relying on function pointers being cast to different types')
Settings.CORRECT_OVERFLOWS = 1
Settings.CORRECT_SIGNS = 1
@@ -6540,7 +6572,7 @@ def process(filename):
Settings.CHECK_OVERFLOWS = 0
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # Has bitfields which are false positives. Also the PyFloat_Init tries to detect endianness.
Settings.CORRECT_SIGNS = 1 # Not sure why, but needed
- Settings.EXPORTED_FUNCTIONS = ['_main', '_PyRun_SimpleStringFlags'] # for the demo
+ Settings.EXPORTED_FUNCTIONS += ['_PyRun_SimpleStringFlags'] # for the demo
self.do_ll_run(path_from_root('tests', 'python', 'python.small.bc'),
'hello python world!\n[0, 2, 4, 6]\n5\n22\n5.470000',
@@ -6578,6 +6610,9 @@ def process(filename):
if '_ta2' in shortname and not Settings.USE_TYPED_ARRAYS == 2:
print self.skip('case "%s" only relevant for ta2' % shortname)
continue
+ if '_noasm' in shortname and Settings.ASM_JS:
+ print self.skip('case "%s" not relevant for asm.js' % shortname)
+ continue
print >> sys.stderr, "Testing case '%s'..." % shortname
output_file = path_from_root('tests', 'cases', shortname + '.txt')
if Settings.QUANTUM_SIZE == 1:
@@ -6651,6 +6686,8 @@ def process(filename):
self.do_run(src, '''AD:-1,1''', build_ll_hook=self.do_autodebug)
def test_profiling(self):
+ if Settings.ASM_JS: return self.skip('asm does not support profiling')
+
src = '''
#include <emscripten.h>
#include <unistd.h>
@@ -6755,11 +6792,13 @@ def process(filename):
open(filename, 'w').write(src)
'''
- Settings.EXPORTED_FUNCTIONS = ['_get_int', '_get_float', '_get_string', '_print_int', '_print_float', '_print_string', '_multi', '_pointer', '_malloc']
+ Settings.EXPORTED_FUNCTIONS += ['_get_int', '_get_float', '_get_string', '_print_int', '_print_float', '_print_string', '_multi', '_pointer']
self.do_run(src, '*\nnumber,5\nnumber,3.14\nstring,hello world\n12\nundefined\n14.56\nundefined\ncheez\nundefined\narr-ay\nundefined\nmore\nnumber,10\n650\nnumber,21\n*\natr\n10\nbret\n53\n*\nstack is ok.\n', post_build=post)
def test_scriptaclass(self):
+ if Settings.ASM_JS: return self.skip('asm does not bindings generator yet')
+
header_filename = os.path.join(self.get_dir(), 'header.h')
header = '''
struct ScriptMe {
@@ -7004,6 +7043,8 @@ Child2:9
''', post_build=[post2, post3])
def test_scriptaclass_2(self):
+ if Settings.ASM_JS: return self.skip('asm does not bindings generator yet')
+
header_filename = os.path.join(self.get_dir(), 'header.h')
header = '''
#include <stdio.h>
@@ -7207,6 +7248,8 @@ def process(filename):
assert 'Assertion failed: Load-store consistency assumption failure!' in str(e), str(e)
def test_check_overflow(self):
+ if Settings.ASM_JS: return self.skip('asm always corrects, and cannot check')
+
Settings.CHECK_OVERFLOWS = 1
Settings.CORRECT_OVERFLOWS = 0
@@ -7261,6 +7304,8 @@ def process(filename):
assert 'Assertion failed' in str(e), str(e)
def test_linespecific(self):
+ if Settings.ASM_JS: return self.skip('asm always has corrections on')
+
if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
if self.emcc_args: self.emcc_args += ['--llvm-opts', '0'] # llvm full opts make the expected failures here not happen
@@ -7418,6 +7463,8 @@ def process(filename):
Settings.CORRECT_SIGNS = 0
def test_pgo(self):
+ if Settings.ASM_JS: return self.skip('asm does not support pgo')
+
if '-g' not in Building.COMPILER_TEST_OPTS: Building.COMPILER_TEST_OPTS.append('-g')
Settings.PGO = Settings.CHECK_OVERFLOWS = Settings.CORRECT_OVERFLOWS = Settings.CHECK_SIGNS = Settings.CORRECT_SIGNS = 1
@@ -7493,6 +7540,7 @@ def process(filename):
def test_gc(self):
if self.emcc_args == None: return self.skip('needs ta2')
+ if Settings.ASM_JS: return self.skip('asm cannot support generic function table')
Settings.GC_SUPPORT = 1
@@ -7675,6 +7723,10 @@ TT = %s
# 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", "--closure", "0"])')
+ # asm.js
+ exec('asm = make_run("asm", compiler=CLANG, emcc_args=["-O0", "--closure", "0", "-s", "ASM_JS=1"])')
+ exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2", "--closure", "0", "-s", "ASM_JS=1"])')
+
# Make custom runs with various options
for compiler, quantum, embetter, typed_arrays, llvm_opts in [
(CLANG, 1, 1, 0, 0),
@@ -8224,6 +8276,8 @@ f.close()
self.assertContained('hello from lib', run_js(os.path.join(self.get_dir(), 'a.out.js')))
def test_runtimelink_multi(self):
+ if Settings.ASM_JS: return self.skip('asm does not support runtime linking yet')
+
if SPIDERMONKEY_ENGINE not in JS_ENGINES: return self.skip('cannot run without spidermonkey due to node limitations')
open('testa.h', 'w').write(r'''
@@ -8712,6 +8766,10 @@ f.close()
['eliminate']),
(path_from_root('tools', 'eliminator', 'safe-eliminator-test.js'), open(path_from_root('tools', 'eliminator', 'safe-eliminator-test-output.js')).read(),
['eliminateMemSafe']),
+ (path_from_root('tools', 'eliminator', 'asm-eliminator-test.js'), open(path_from_root('tools', 'eliminator', 'asm-eliminator-test-output.js')).read(),
+ ['eliminateAsm']),
+ (path_from_root('tools', 'test-js-optimizer-asm-regs.js'), open(path_from_root('tools', 'test-js-optimizer-asm-regs-output.js')).read(),
+ ['registerizeAsm']),
]:
output = Popen([NODE_JS, path_from_root('tools', 'js-optimizer.js'), input] + passes, stdin=PIPE, stdout=PIPE).communicate()[0]
self.assertIdentical(expected, output.replace('\r\n', '\n').replace('\n\n', '\n'))
@@ -9997,10 +10055,10 @@ elif 'browser' in str(sys.argv):
main, supp = self.setup_runtimelink_test()
open(self.in_dir('supp.cpp'), 'w').write(supp)
- Popen([PYTHON, EMCC, self.in_dir('supp.cpp'), '-o', 'supp.js', '-s', 'LINKABLE=1', '-s', 'BUILD_AS_SHARED_LIB=2', '-O2', '--closure', '0']).communicate()
+ Popen([PYTHON, EMCC, self.in_dir('supp.cpp'), '-o', 'supp.js', '-s', 'LINKABLE=1', '-s', 'NAMED_GLOBALS=1', '-s', 'BUILD_AS_SHARED_LIB=2', '-O2', '--closure', '0']).communicate()
shutil.move(self.in_dir('supp.js'), self.in_dir('supp.so'))
- self.btest(main, args=['-s', 'LINKABLE=1', '-s', 'RUNTIME_LINKED_LIBS=["supp.so"]', '-DBROWSER=1', '-O2', '--closure', '0'], expected='76')
+ self.btest(main, args=['-s', 'LINKABLE=1', '-s', 'NAMED_GLOBALS=1', '-s', 'RUNTIME_LINKED_LIBS=["supp.so"]', '-DBROWSER=1', '-O2', '--closure', '0'], expected='76')
def test_pre_run_deps(self):
# Adding a dependency in preRun will delay run
@@ -10266,7 +10324,7 @@ elif 'benchmark' in str(sys.argv):
try_delete(final_filename)
output = Popen([PYTHON, EMCC, filename, #'-O3',
'-O2', '-s', 'INLINING_LIMIT=0', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0',
- '-s', 'TOTAL_MEMORY=100*1024*1024', '-s', 'FAST_MEMORY=10*1024*1024',
+ '-s', 'TOTAL_MEMORY=128*1024*1024', '-s', 'FAST_MEMORY=10*1024*1024',
'-o', final_filename] + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate()
assert os.path.exists(final_filename), 'Failed to compile file: ' + output[0]