diff options
-rwxr-xr-x | auto_update_tests.py | 78 | ||||
-rwxr-xr-x | scripts/test/wasm2js.py | 4 |
2 files changed, 41 insertions, 41 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py index c977584ce..cfc29e5f8 100755 --- a/auto_update_tests.py +++ b/auto_update_tests.py @@ -33,11 +33,11 @@ from scripts.test import wasm2js def update_asm_js_tests(): print('[ processing and updating testcases... ]\n') - for asm in sorted(os.listdir('test')): + for asm in sorted(os.listdir(options.binaryen_test)): if asm.endswith('.asm.js'): for precise in [0, 1, 2]: for opts in [1, 0]: - cmd = ASM2WASM + [os.path.join('test', asm)] + cmd = ASM2WASM + [os.path.join(options.binaryen_test, asm)] if 'threads' in asm: cmd += ['--enable-threads'] wasm = asm.replace('.asm.js', '.fromasm') @@ -69,55 +69,55 @@ def update_asm_js_tests(): cmd += ['--wasm-only'] print(' '.join(cmd)) actual = run_command(cmd) - with open(os.path.join('test', wasm), 'w') as o: + with open(os.path.join(options.binaryen_test, wasm), 'w') as o: o.write(actual) if 'debugInfo' in asm: - cmd += ['--source-map', os.path.join('test', wasm + '.map'), '-o', 'a.wasm'] + cmd += ['--source-map', os.path.join(options.binaryen_test, wasm + '.map'), '-o', 'a.wasm'] run_command(cmd) def update_wasm_opt_tests(): print('\n[ checking wasm-opt -o notation... ]\n') - wast = os.path.join('test', 'hello_world.wast') + wast = os.path.join(options.binaryen_test, 'hello_world.wast') cmd = WASM_OPT + [wast, '-o', 'a.wast', '-S'] run_command(cmd) open(wast, 'w').write(open('a.wast').read()) print('\n[ checking wasm-opt parsing & printing... ]\n') - for t in sorted(os.listdir(os.path.join('test', 'print'))): + for t in sorted(os.listdir(os.path.join(options.binaryen_test, 'print'))): if t.endswith('.wast'): print('..', t) wasm = os.path.basename(t).replace('.wast', '') - cmd = WASM_OPT + [os.path.join('test', 'print', t), '--print', '-all'] + cmd = WASM_OPT + [os.path.join(options.binaryen_test, 'print', t), '--print', '-all'] print(' ', ' '.join(cmd)) actual = subprocess.check_output(cmd) print(cmd, actual) - with open(os.path.join('test', 'print', wasm + '.txt'), 'wb') as o: + with open(os.path.join(options.binaryen_test, 'print', wasm + '.txt'), 'wb') as o: o.write(actual) - cmd = WASM_OPT + [os.path.join('test', 'print', t), '--print-minified', '-all'] + cmd = WASM_OPT + [os.path.join(options.binaryen_test, 'print', t), '--print-minified', '-all'] print(' ', ' '.join(cmd)) actual = subprocess.check_output(cmd) - with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'wb') as o: + with open(os.path.join(options.binaryen_test, 'print', wasm + '.minified.txt'), 'wb') as o: o.write(actual) print('\n[ checking wasm-opt passes... ]\n') - for t in sorted(os.listdir(os.path.join('test', 'passes'))): + for t in sorted(os.listdir(os.path.join(options.binaryen_test, 'passes'))): if t.endswith(('.wast', '.wasm')): print('..', t) binary = '.wasm' in t base = os.path.basename(t).replace('.wast', '').replace('.wasm', '') passname = base if passname.isdigit(): - passname = open(os.path.join('test', 'passes', passname + '.passes')).read().strip() + passname = open(os.path.join(options.binaryen_test, 'passes', passname + '.passes')).read().strip() opts = [('--' + p if not p.startswith('O') else '-' + p) for p in passname.split('_')] - t = os.path.join('test', 'passes', t) + t = os.path.join(options.binaryen_test, 'passes', t) actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0 write_wast('split.wast', module) cmd = WASM_OPT + opts + ['split.wast', '--print'] actual += run_command(cmd) - with open(os.path.join('test', 'passes', base + ('.bin' if binary else '') + '.txt'), 'w') as o: + with open(os.path.join(options.binaryen_test, 'passes', base + ('.bin' if binary else '') + '.txt'), 'w') as o: o.write(actual) if 'emit-js-wrapper' in t: with open('a.js') as i: @@ -129,10 +129,10 @@ def update_wasm_opt_tests(): o.write(i.read()) print('\n[ checking wasm-opt testcases... ]\n') - for t in os.listdir('test'): + for t in os.listdir(options.binaryen_test): if t.endswith('.wast') and not t.startswith('spec'): print('..', t) - t = os.path.join('test', t) + t = os.path.join(options.binaryen_test, t) f = t + '.from-wast' cmd = WASM_OPT + [t, '--print', '-all'] actual = run_command(cmd) @@ -140,10 +140,10 @@ def update_wasm_opt_tests(): open(f, 'w').write(actual) print('\n[ checking wasm-opt debugInfo read-write... ]\n') - for t in os.listdir('test'): + for t in os.listdir(options.binaryen_test): if t.endswith('.fromasm') and 'debugInfo' in t: print('..', t) - t = os.path.join('test', t) + t = os.path.join(options.binaryen_test, t) f = t + '.read-written' run_command(WASM_AS + [t, '--source-map=a.map', '-o', 'a.wasm', '-g']) run_command(WASM_OPT + ['a.wasm', '--input-source-map=a.map', '-o', 'b.wasm', '--output-source-map=b.map', '-g']) @@ -153,10 +153,10 @@ def update_wasm_opt_tests(): def update_bin_fmt_tests(): print('\n[ checking binary format testcases... ]\n') - for wast in sorted(os.listdir('test')): + for wast in sorted(os.listdir(options.binaryen_test)): if wast.endswith('.wast') and wast not in []: # blacklist some known failures for debug_info in [0, 1]: - cmd = WASM_AS + [os.path.join('test', wast), '-o', 'a.wasm', '-all'] + cmd = WASM_AS + [os.path.join(options.binaryen_test, wast), '-o', 'a.wasm', '-all'] if debug_info: cmd += ['-g'] print(' '.join(cmd)) @@ -175,19 +175,19 @@ def update_bin_fmt_tests(): binary_name = wast + '.fromBinary' if not debug_info: binary_name += '.noDebugInfo' - with open(os.path.join('test', binary_name), 'w') as o: + with open(os.path.join(options.binaryen_test, binary_name), 'w') as o: o.write(actual) def update_example_tests(): print('\n[ checking example testcases... ]\n') - for t in sorted(os.listdir(os.path.join('test', 'example'))): + for t in sorted(os.listdir(os.path.join(options.binaryen_test, 'example'))): output_file = os.path.join(options.binaryen_bin, 'example') libdir = os.path.join(BINARYEN_INSTALL_DIR, 'lib') - cmd = ['-Isrc', '-g', '-pthread', '-o', output_file] + cmd = ['-I' + os.path.join(options.binaryen_root, 'src'), '-g', '-pthread', '-o', output_file] if t.endswith('.txt'): # check if there is a trace in the file, if so, we should build it - out = subprocess.Popen([os.path.join('scripts', 'clean_c_api_trace.py'), os.path.join('test', 'example', t)], stdout=subprocess.PIPE).communicate()[0] + out = subprocess.Popen([os.path.join(options.binaryen_root, 'scripts', 'clean_c_api_trace.py'), os.path.join(options.binaryen_test, 'example', t)], stdout=subprocess.PIPE).communicate()[0] if len(out) == 0: print(' (no trace in ', t, ')') continue @@ -195,16 +195,16 @@ def update_example_tests(): src = 'trace.cpp' with open(src, 'wb') as o: o.write(out) - expected = os.path.join('test', 'example', t + '.txt') + expected = os.path.join(options.binaryen_test, 'example', t + '.txt') else: - src = os.path.join('test', 'example', t) - expected = os.path.join('test', 'example', '.'.join(t.split('.')[:-1]) + '.txt') + src = os.path.join(options.binaryen_test, 'example', t) + expected = os.path.join(options.binaryen_test, 'example', '.'.join(t.split('.')[:-1]) + '.txt') if not src.endswith(('.c', '.cpp')): continue # build the C file separately extra = [os.environ.get('CC') or 'gcc', src, '-c', '-o', 'example.o', - '-Isrc', '-g', '-L' + libdir, '-pthread'] + '-I' + os.path.join(options.binaryen_root, 'src'), '-g', '-L' + libdir, '-pthread'] print('build: ', ' '.join(extra)) if src.endswith('.cpp'): extra += ['-std=c++11'] @@ -235,10 +235,10 @@ def update_example_tests(): def update_wasm_dis_tests(): print('\n[ checking wasm-dis on provided binaries... ]\n') - for t in os.listdir('test'): + for t in os.listdir(options.binaryen_test): if t.endswith('.wasm') and not t.startswith('spec'): print('..', t) - t = os.path.join('test', t) + t = os.path.join(options.binaryen_test, t) cmd = WASM_DIS + [t] if os.path.isfile(t + '.map'): cmd += ['--source-map', t + '.map'] @@ -258,7 +258,7 @@ def update_binaryen_js_tests(): print('\n[ checking binaryen.js testcases... ]\n') node_has_wasm = NODEJS and node_has_webassembly(NODEJS) - for s in sorted(os.listdir(os.path.join('test', 'binaryen.js'))): + for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))): if not s.endswith('.js'): continue print(s) @@ -266,7 +266,7 @@ def update_binaryen_js_tests(): f.write(open(BINARYEN_JS).read()) if NODEJS: f.write(node_test_glue()) - test_path = os.path.join('test', 'binaryen.js', s) + test_path = os.path.join(options.binaryen_test, 'binaryen.js', s) test_src = open(test_path).read() f.write(test_src) f.close() @@ -277,7 +277,7 @@ def update_binaryen_js_tests(): else: # expect an error - the specific error code will depend on the vm out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None) - with open(os.path.join('test', 'binaryen.js', s + '.txt'), 'w') as o: + with open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt'), 'w') as o: o.write(out) else: print('Skipping ' + test_path + ' because WebAssembly might not be supported') @@ -285,10 +285,10 @@ def update_binaryen_js_tests(): def update_ctor_eval_tests(): print('\n[ checking wasm-ctor-eval... ]\n') - for t in os.listdir(os.path.join('test', 'ctor-eval')): + for t in os.listdir(os.path.join(options.binaryen_test, 'ctor-eval')): if t.endswith(('.wast', '.wasm')): print('..', t) - t = os.path.join('test', 'ctor-eval', t) + t = os.path.join(options.binaryen_test, 'ctor-eval', t) ctors = open(t + '.ctors').read().strip() cmd = WASM_CTOR_EVAL + [t, '-o', 'a.wast', '-S', '--ctors', ctors] run_command(cmd) @@ -300,10 +300,10 @@ def update_ctor_eval_tests(): def update_metadce_tests(): print('\n[ checking wasm-metadce... ]\n') - for t in os.listdir(os.path.join('test', 'metadce')): + for t in os.listdir(os.path.join(options.binaryen_test, 'metadce')): if t.endswith(('.wast', '.wasm')): print('..', t) - t = os.path.join('test', 'metadce', t) + t = os.path.join(options.binaryen_test, 'metadce', t) graph = t + '.graph.txt' cmd = WASM_METADCE + [t, '--graph-file=' + graph, '-o', 'a.wast', '-S'] stdout = run_command(cmd) @@ -319,10 +319,10 @@ def update_reduce_tests(): if not has_shell_timeout(): return print('\n[ checking wasm-reduce ]\n') - for t in os.listdir(os.path.join('test', 'reduce')): + for t in os.listdir(os.path.join(options.binaryen_test, 'reduce')): if t.endswith('.wast'): print('..', t) - t = os.path.join('test', 'reduce', t) + t = os.path.join(options.binaryen_test, 'reduce', t) # convert to wasm run_command(WASM_AS + [t, '-o', 'a.wasm']) print(run_command(WASM_REDUCE + ['a.wasm', '--command=%s b.wasm --fuzz-exec' % WASM_OPT[0], '-t', 'b.wasm', '-w', 'c.wasm'])) diff --git a/scripts/test/wasm2js.py b/scripts/test/wasm2js.py index c1abaa8f9..2395778bd 100755 --- a/scripts/test/wasm2js.py +++ b/scripts/test/wasm2js.py @@ -173,8 +173,8 @@ def update_wasm2js_tests(): asserts = os.path.basename(wasm).replace('.wast.asserts', '.asserts.js') traps = os.path.basename(wasm).replace('.wast.asserts', '.traps.js') - asserts_expected_file = os.path.join('test', asserts) - traps_expected_file = os.path.join('test', traps) + asserts_expected_file = os.path.join(options.binaryen_test, asserts) + traps_expected_file = os.path.join(options.binaryen_test, traps) cmd = WASM2JS + [os.path.join(wasm2js_dir, wasm), '--allow-asserts'] out = run_command(cmd) |