diff options
Diffstat (limited to 'check.py')
-rwxr-xr-x | check.py | 62 |
1 files changed, 35 insertions, 27 deletions
@@ -150,6 +150,29 @@ if not has_emcc: if not has_vanilla_emcc: warn('no functional emcc submodule found') +# check utilities + +def binary_format_check(wast, verify_final_result=True): + # checks we can convert the wast to binary and back + + print ' (binary format check)' + cmd = [os.path.join('bin', 'wasm-as'), 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', 'ab.wast'] + print ' ', ' '.join(cmd) + if os.path.exists('ab.wast'): os.unlink('ab.wast') + subprocess.check_call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + assert os.path.exists('ab.wast') + + if verify_final_result: + expected = open(wast + '.fromBinary').read() + actual = open('ab.wast').read() + if actual != expected: + fail(actual, expected) # tests @@ -238,6 +261,8 @@ for t in tests: if actual != expected: fail(actual, expected) + binary_format_check(t) + print '\n[ checking binaryen-shell spec testcases... ]\n' if len(requested) == 0: @@ -266,12 +291,14 @@ for t in spec_tests: return '(' + t + '.const ' + v + ')' expected = '\n'.join(map(fix, expected.split('\n'))) print ' (using expected output)' - else: - continue - actual = actual.strip() - expected = expected.strip() - if actual != expected: - fail(actual, expected) + actual = actual.strip() + expected = expected.strip() + if actual != expected: + fail(actual, expected) + + # check binary format. here we can verify execution of the final result, no need for an output verification + if os.path.basename(wast) not in ['has_feature.wast']: # avoid some tests with things still in spec tests, but likely to be taken out soon + binary_format_check(wast, verify_final_result=False) print '\n[ checking wasm2asm testcases... ]\n' @@ -361,32 +388,13 @@ if torture: runner=os.path.abspath(os.path.join('bin', 'binaryen-shell')), files=os.path.abspath(os.path.join(s2wasm_torture_out, '*.wast')), fails=os.path.abspath(os.path.join('test', 's2wasm_known_binaryen_shell_test_failures.txt')), - out='') + out='', + wasmjs='') shutil.rmtree(s2wasm_torture_out) if unexpected_result_count: fail('%s failures' % unexpected_result_count, '0 failures') -print '\n[ checking binary format testcases... ]\n' - -for wast in tests: - if wast.endswith('.wast') and not wast in []: # 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) - if has_vanilla_emcc: print '\n[ checking emcc WASM_BACKEND testcases...]\n' |