diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 155 |
1 files changed, 118 insertions, 37 deletions
diff --git a/tests/runner.py b/tests/runner.py index 0d8878c3..6db4609e 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -291,7 +291,7 @@ process(sys.argv[1]) out = open(stdout, 'r').read() err = open(stderr, 'r').read() if engine == SPIDERMONKEY_ENGINE and Settings.ASM_JS: - if 'Successfully compiled asm.js code' in err and 'asm.js link error' not in err: + if 'successfully 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") @@ -447,6 +447,8 @@ process(sys.argv[1]) sys.argv = map(lambda arg: arg if not arg.startswith('test_') else 'default.' + arg, sys.argv) +test_modes = ['default', 'o1', 'o2', 'asm1', 'asm2', 'asm2g', 'asm2x86', 's_0_0', 's_0_1', 's_1_0', 's_1_1'] + test_index = 0 if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'browser' not in str(sys.argv): @@ -454,10 +456,10 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows print "Running Emscripten tests..." - if len(sys.argv) == 2 and 'ALL.' in sys.argv[1]: + if len(sys.argv) == 2 and sys.argv[1].startswith('ALL.'): 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, 'asm1.'+test, 'asm2.'+test, 'asm2g.'+test, 'asm2le32.'+test, 's_0_0.'+test, 's_0_1.'+test, 's_1_0.'+test, 's_1_1.'+test] + sys.argv = [sys.argv[0]] + map(lambda mode: mode+'.'+test, test_modes) 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. @@ -509,7 +511,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows post_build=None) # post_build was already done in ll_to_js, this do_run call is just to test the output def is_le32(self): - return 'le32-unknown-nacl' in COMPILER_OPTS or self.env.get('EMCC_LLVM_TARGET') == 'le32-unknown-nacl' + return not ('i386-pc-linux-gnu' in COMPILER_OPTS or self.env.get('EMCC_LLVM_TARGET') == 'i386-pc-linux-gnu') def test_hello_world(self): src = ''' @@ -3309,10 +3311,10 @@ Exiting setjmp function, level: 0, prev_jmp: -1 #include <stdio.h> int - main(void) { - float (*fn)(float) = &sqrtf; - float (*fn2)(float) = &fabsf; - float (*fn3)(float) = &erff; + main(int argc, char **argv) { + float (*fn)(float) = argc != 12 ? &sqrtf : &fabsf; + float (*fn2)(float) = argc != 13 ? &fabsf : &sqrtf; + float (*fn3)(float) = argc != 14 ? &erff : &fabsf; printf("fn2(-5) = %d, fn(10) = %.2f, erf(10) = %.2f\\n", (int)fn2(-5), fn(10), fn3(10)); return 0; } @@ -5618,7 +5620,7 @@ at function.:blag open(path_from_root('tests', 'printf', 'output_i64_1.txt'), 'r').read()] self.do_run(src, expected) - def test_printf_types(self): + def test_printf_2(self): src = r''' #include <stdio.h> @@ -5631,11 +5633,12 @@ at function.:blag double d = 6.6; printf("%c,%hd,%d,%lld,%.1f,%.1llf\n", c, s, i, l, f, d); + printf("%#x,%#x\n", 1, 0); return 0; } ''' - self.do_run(src, '1,2,3,4,5.5,6.6\n') + self.do_run(src, '1,2,3,4,5.5,6.6\n0x1,0\n') def test_vprintf(self): src = r''' @@ -6039,6 +6042,40 @@ Pass: 0.000012 0.000012''') ''' self.do_run(src, '''0:173,16 1:16,173 2:183,173 3:17,287 4:98,123''') + def test_sscanf_other_whitespace(self): + Settings.SAFE_HEAP = 0 # use i16s in printf + + src = r''' + #include<stdio.h> + + int main() { + short int x; + short int y; + + const char* buffer[] = { + "\t2\t3\t", /* TAB - horizontal tab */ + "\t\t5\t\t7\t\t", + "\n11\n13\n", /* LF - line feed */ + "\n\n17\n\n19\n\n", + "\v23\v29\v", /* VT - vertical tab */ + "\v\v31\v\v37\v\v", + "\f41\f43\f", /* FF - form feed */ + "\f\f47\f\f53\f\f", + "\r59\r61\r", /* CR - carrage return */ + "\r\r67\r\r71\r\r" + }; + + for (int i=0; i<10; ++i) { + x = 0; y = 0; + sscanf(buffer[i], " %d %d ", &x, &y); + printf("%d, %d, ", x, y); + } + + return 0; + } + ''' + self.do_run(src, '''2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ''') + def test_sscanf_3(self): # i64 if not Settings.USE_TYPED_ARRAYS == 2: return self.skip('64-bit sscanf only supported in ta2') @@ -7390,6 +7427,10 @@ extern "C" { src = open(path_from_root('tests', 'fasta.cpp'), 'r').read() self.do_run(src, j, [str(i)], lambda x, err: x.replace('\n', '*'), no_build=i>1) + def test_whets(self): + if not Settings.ASM_JS: return self.skip('mainly a test for asm validation here') + self.do_run(open(path_from_root('tests', 'whets.cpp')).read(), 'Single Precision C Whetstone Benchmark') + def test_dlmalloc(self): if self.emcc_args is None: self.emcc_args = [] # dlmalloc auto-inclusion is only done if we use emcc @@ -7828,15 +7869,29 @@ def process(filename): Settings.SAFE_HEAP_LINES = ['btVoronoiSimplexSolver.h:40', 'btVoronoiSimplexSolver.h:41', 'btVoronoiSimplexSolver.h:42', 'btVoronoiSimplexSolver.h:43'] - self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(), - [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings - open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read(), - open(path_from_root('tests', 'bullet', 'output3.txt'), 'r').read()], - libraries=self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'), - os.path.join('src', '.libs', 'libBulletCollision.a'), - os.path.join('src', '.libs', 'libLinearMath.a')], - configure_args=['--disable-demos','--disable-dependency-tracking']), - includes=[path_from_root('tests', 'bullet', 'src')]) + def test(): + self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(), + [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings + open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read(), + open(path_from_root('tests', 'bullet', 'output3.txt'), 'r').read()], + libraries=self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletDynamics.a'), + os.path.join('src', '.libs', 'libBulletCollision.a'), + os.path.join('src', '.libs', 'libLinearMath.a')], + configure_args=['--disable-demos','--disable-dependency-tracking']), + includes=[path_from_root('tests', 'bullet', 'src')]) + test() + + assert 'asm2g' in test_modes + if self.run_name == 'asm2g': + # Test forced alignment + print >> sys.stderr, 'testing FORCE_ALIGNED_MEMORY' + old = open('src.cpp.o.js').read() + Settings.FORCE_ALIGNED_MEMORY = 1 + test() + new = open('src.cpp.o.js').read() + print len(old), len(new), old.count('tempBigInt'), new.count('tempBigInt') + assert len(old) > len(new) + assert old.count('tempBigInt') > new.count('tempBigInt') def test_poppler(self): if self.emcc_args is None: return self.skip('very slow, we only do this in emcc runs') @@ -9265,6 +9320,7 @@ finalizing 3 (global == 0) def make_run(fullname, name=-1, compiler=-1, llvm_opts=0, embetter=0, quantum_size=0, typed_arrays=0, emcc_args=None, env='{}'): exec(''' class %s(T): + run_name = '%s' env = %s def tearDown(self): @@ -9329,7 +9385,7 @@ class %s(T): Building.pick_llvm_opts(3) TT = %s -''' % (fullname, env, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname)) +''' % (fullname, fullname, env, fullname, fullname, compiler, str(emcc_args), llvm_opts, embetter, quantum_size, typed_arrays, fullname)) return TT # Make one run with the defaults @@ -9345,7 +9401,7 @@ TT = %s exec('asm1 = make_run("asm1", compiler=CLANG, emcc_args=["-O1", "-s", "CHECK_HEAP_ALIGN=1"])') exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2"])') exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1"])') - exec('''asm2le32 = make_run("asm2le32", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "CHECK_HEAP_ALIGN=1"], env='{"EMCC_LLVM_TARGET": "le32-unknown-nacl"}')''') + exec('''asm2x86 = make_run("asm2x86", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "CHECK_HEAP_ALIGN=1"], env='{"EMCC_LLVM_TARGET": "i386-pc-linux-gnu"}')''') # Make custom runs with various options for compiler, quantum, embetter, typed_arrays, llvm_opts in [ @@ -12525,7 +12581,16 @@ elif 'benchmark' in str(sys.argv): print ' JavaScript: mean: %.3f (+-%.3f) secs median: %.3f range: %.3f-%.3f (noise: %3.3f%%) (%d runs)' % (mean, std, median, min(times), max(times), 100*std/mean, reps) print ' Native : mean: %.3f (+-%.3f) secs median: %.3f range: %.3f-%.3f (noise: %3.3f%%) JS is %.2f X slower' % (mean_native, std_native, median_native, min(native_times), max(native_times), 100*std_native/mean_native, final) - def do_benchmark(self, name, src, args=[], expected_output='FAIL', emcc_args=[], native_args=[], shared_args=[], force_c=False, reps=TEST_REPS): + def do_benchmark(self, name, src, expected_output='FAIL', args=[], emcc_args=[], native_args=[], shared_args=[], force_c=False, reps=TEST_REPS): + # standard arguments for timing: + # 0: no runtime, just startup + # 1: very little runtime + # 2: 0.5 seconds + # 3: 1 second + # 4: 5 seconds + # 5: 10 seconds + args = args or ['3'] + dirname = self.get_dir() filename = os.path.join(dirname, name + '.c' + ('' if force_c else 'pp')) f = open(filename, 'w') @@ -12549,7 +12614,8 @@ elif 'benchmark' in str(sys.argv): for i in range(reps): start = time.time() js_output = run_js(final_filename, engine=JS_ENGINE, args=args, stderr=PIPE, full_output=True) - if i == 0 and 'Successfully compiled asm.js code' in js_output: + + if i == 0 and 'successfully compiled asm.js code' in js_output: if 'asm.js link error' not in js_output: print "[%s was asm.js'ified]" % name curr = time.time()-start @@ -12614,7 +12680,7 @@ elif 'benchmark' in str(sys.argv): return 0; } ''' - self.do_benchmark('primes', src, [], 'lastprime: 3043739.') + self.do_benchmark('primes', src, 'lastprime: 3043739.') def test_memops(self): src = ''' @@ -12647,7 +12713,7 @@ elif 'benchmark' in str(sys.argv): return 0; } ''' - self.do_benchmark('memops', src, [], 'final: 400.') + self.do_benchmark('memops', src, 'final: 400.') def zzztest_files(self): src = r''' @@ -12690,7 +12756,7 @@ elif 'benchmark' in str(sys.argv): return 0; } ''' - self.do_benchmark(src, [], 'ok') + self.do_benchmark(src, 'ok') def test_copy(self): src = r''' @@ -12744,7 +12810,7 @@ elif 'benchmark' in str(sys.argv): return 0; } ''' - self.do_benchmark('copy', src, [], 'sum:2836\n') + self.do_benchmark('copy', src, 'sum:2836\n') def test_fannkuch(self): src = open(path_from_root('tests', 'fannkuch.cpp'), 'r').read().replace( @@ -12764,7 +12830,7 @@ elif 'benchmark' in str(sys.argv): ''' ) assert 'switch(arg)' in src - self.do_benchmark('fannkuch', src, [], 'Pfannkuchen(11) = 51.') + self.do_benchmark('fannkuch', src, 'Pfannkuchen(11) = 51.') def test_corrections(self): src = r''' @@ -12797,7 +12863,7 @@ elif 'benchmark' in str(sys.argv): return 0; } ''' - self.do_benchmark('corrections', src, [], 'final: 40006013:10225.', emcc_args=['-s', 'CORRECT_SIGNS=1', '-s', 'CORRECT_OVERFLOWS=1', '-s', 'CORRECT_ROUNDINGS=1']) + self.do_benchmark('corrections', src, 'final: 40006013:10225.', emcc_args=['-s', 'CORRECT_SIGNS=1', '-s', 'CORRECT_OVERFLOWS=1', '-s', 'CORRECT_ROUNDINGS=1']) def fasta(self, name, double_rep, emcc_args=[]): src = open(path_from_root('tests', 'fasta.cpp'), 'r').read().replace('double', double_rep) @@ -12815,7 +12881,7 @@ elif 'benchmark' in str(sys.argv): } ''') assert 'switch(arg)' in src - self.do_benchmark('fasta', src, [], '''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA\nTCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT\nAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG\nGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG\nCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT\nGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA\nGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA\nTTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG\nAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA\nGCCTGGGCGA''') + self.do_benchmark('fasta', src, '''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA\nTCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT\nAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG\nGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG\nCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT\nGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA\nGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA\nTTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG\nAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA\nGCCTGGGCGA''') def test_fasta_float(self): self.fasta('fasta_float', 'float') @@ -12828,11 +12894,11 @@ elif 'benchmark' in str(sys.argv): def test_skinning(self): src = open(path_from_root('tests', 'skinning_test_no_simd.cpp'), 'r').read() - self.do_benchmark('skinning', src, [], 'blah=0.000000') + self.do_benchmark('skinning', src, 'blah=0.000000') def test_life(self): src = open(path_from_root('tests', 'life.c'), 'r').read() - self.do_benchmark('life', src, [], '''-------------------------------- + self.do_benchmark('life', src, '''-------------------------------- [][] [] [] [][] [][] [] [] [][] [] [] @@ -12867,13 +12933,19 @@ elif 'benchmark' in str(sys.argv): [] [][] [][][] --------------------------------''', shared_args=['-std=c99'], force_c=True) + def test_nbody_java(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')] + self.do_benchmark('nbody_java', '', '''Time(s)''', + force_c=True, emcc_args=args + ['-s', 'PRECISE_I64_MATH=1', '--llvm-lto', '0'], native_args=args + ['-lgc', '-std=c99', '-target', 'x86_64-pc-linux-gnu', '-lm']) + def test_zlib(self): src = open(path_from_root('tests', 'zlib', 'benchmark.c'), 'r').read() emcc_args = self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']) + \ ['-I' + path_from_root('tests', 'zlib')] native_args = self.get_library('zlib_native', os.path.join('libz.a'), make_args=['libz.a'], native=True) + \ ['-I' + path_from_root('tests', 'zlib')] - self.do_benchmark('zlib', src, [], '''sizes: 100000,25906 + self.do_benchmark('zlib', src, '''sizes: 100000,25906 ok. ''', force_c=True, emcc_args=emcc_args, native_args=native_args) @@ -12887,7 +12959,7 @@ ok. emcc_args = js_lib + ['-I' + path_from_root('tests', 'box2d')] native_args = native_lib + ['-I' + path_from_root('tests', 'box2d')] - self.do_benchmark('box2d', src, [], 'frame averages', emcc_args=emcc_args, native_args=native_args) + self.do_benchmark('box2d', src, 'frame averages', emcc_args=emcc_args, native_args=native_args) def test_zzz_bullet(self): # Called thus so it runs late in the alphabetical cycle... it is long src = open(path_from_root('tests', 'bullet', 'Demos', 'Benchmarks', 'BenchmarkDemo.cpp'), 'r').read() + \ @@ -12909,7 +12981,7 @@ ok. native_args = native_lib + ['-I' + path_from_root('tests', 'bullet', 'src'), '-I' + path_from_root('tests', 'bullet', 'Demos', 'Benchmarks')] - self.do_benchmark('bullet', src, [], '\nok.\n', emcc_args=emcc_args, native_args=native_args) + self.do_benchmark('bullet', src, '\nok.\n', emcc_args=emcc_args, native_args=native_args) elif 'sanity' in str(sys.argv): @@ -13413,8 +13485,17 @@ if __name__ == '__main__': arg = sys.argv[i] if arg.startswith('skip:'): which = arg.split('skip:')[1] - print >> sys.stderr, 'will skip "%s"' % which - exec(which + ' = RunnerCore.skipme') + if which.startswith('ALL.'): + ignore, test = which.split('.') + which = map(lambda mode: mode+'.'+test, test_modes) + else: + which = [which] + + print >> sys.stderr, ','.join(which) + for test in which: + print >> sys.stderr, 'will skip "%s"' % test + exec(test + ' = RunnerCore.skipme') + sys.argv[i] = '' sys.argv = filter(lambda arg: arg, sys.argv) |