diff options
Diffstat (limited to 'check.py')
-rwxr-xr-x | check.py | 74 |
1 files changed, 59 insertions, 15 deletions
@@ -18,12 +18,17 @@ import os, shutil, sys, subprocess, difflib, json, time interpreter = None requested = [] +torture = True for arg in sys.argv[1:]: if arg.startswith('--interpreter='): interpreter = arg.split('=')[1] print '[ using wasm interpreter at "%s" ]' % interpreter assert os.path.exists(interpreter), 'interpreter not found' + elif arg == '--torture': + torture = True + elif arg == '--no-torture': + torture = False else: requested.append(arg) @@ -256,22 +261,61 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']: actual, err = proc.communicate() assert proc.returncode == 0, err -print '\n[ checking torture testcases... ]\n' - -import test.waterfall.src.link_assembly_files as link_assembly_files -s2wasm_torture_out = os.path.abspath(os.path.join('test', 's2wasm-torture-out')) -if os.path.isdir(s2wasm_torture_out): +if torture: + + print '\n[ checking torture testcases... ]\n' + + import test.waterfall.src.link_assembly_files as link_assembly_files + s2wasm_torture_out = os.path.abspath(os.path.join('test', 's2wasm-torture-out')) + if os.path.isdir(s2wasm_torture_out): + shutil.rmtree(s2wasm_torture_out) + os.mkdir(s2wasm_torture_out) + unexpected_result_count = link_assembly_files.run( + linker=os.path.abspath(os.path.join('bin', 's2wasm')), + files=os.path.abspath(os.path.join('test', 'torture-s', '*.s')), + fails=os.path.abspath(os.path.join('test', 's2wasm_known_gcc_test_failures.txt')), + out=s2wasm_torture_out) + assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out + # execute it TODO: parallelize, use waterfall + known_failures = set(open(os.path.join('test', 's2wasm_known_binaryen_shell_test_failures.txt')).read().split('\n')) + total = 0 + bad_failures = [] + for wast in sorted(os.listdir(s2wasm_torture_out)): + total += 1 + cmd = [os.path.join('bin', 'binaryen-shell'), os.path.join(s2wasm_torture_out, wast), '--entry=main'] + print ' '.join(cmd) + try: + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except: + if wast not in known_failures: + bad_failures.append(wast) + if len(bad_failures) > 0: + print '\nbad failures:\n' + print '\n'.join(bad_failures) + raise Exception('bad failures :( %d out of %d' % (len(bad_failures), total)) shutil.rmtree(s2wasm_torture_out) -os.mkdir(s2wasm_torture_out) -unexpected_result_count = link_assembly_files.run( - linker=os.path.abspath(os.path.join('bin', 's2wasm')), - files=os.path.abspath(os.path.join('test', 'torture-s', '*.s')), - fails=os.path.abspath(os.path.join('test', 's2wasm_known_gcc_test_failures.txt')), - out=s2wasm_torture_out) -assert os.path.isdir(s2wasm_torture_out), 'Expected output directory %s' % s2wasm_torture_out -shutil.rmtree(s2wasm_torture_out) -if unexpected_result_count: - fail(unexpected_result_count, 0) + if unexpected_result_count: + fail(unexpected_result_count, 0) + +print '\n[ checking binary format testcases... ]\n' + +for wast in tests: + if wast.endswith('.wast') and not wast in ['unit.wast']: # blacklist some known failures + cmd = [os.path.join('bin', 'wasm-as'), os.path.join('test', wast), '-o', 'a.wasm'] + print ' '.join(cmd) + if os.path.exists('a.wasm'): os.unlink('a.wasm') + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + assert os.path.exists('a.wasm') + + cmd = [os.path.join('bin', 'wasm-dis'), 'a.wasm', '-o', 'a.wast'] + print ' '.join(cmd) + if os.path.exists('a.wast'): os.unlink('a.wast') + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + assert os.path.exists('a.wast') + expected = open(os.path.join('test', wast + '.fromBinary')).read() + actual = open('a.wast').read() + if actual != expected: + fail(actual, expected) print '\n[ checking example testcases... ]\n' |