def run_spec_test(wast): cmd = [os.path.join('bin', 'wasm-shell'), wast] # we must skip the stack machine portions of spec tests or apply other extra args extra = { } cmd = cmd + (extra.get(os.path.basename(wast)) or []) return run_command(cmd, stderr=subprocess.PIPE)
def run_spec_test(wast): cmd = [os.path.join('bin', 'wasm-shell'), wast] # we must skip the stack machine portions of spec tests or apply other extra args extra = { 'call.wast': ['--skip=207'], 'call_indirect.wast': ['--skip=302'], 'nop.wast': ['--skip=3'], 'stack.wast': ['--skip=0'], } cmd = cmd + (extra.get(os.path.basename(wast)) or []) return run_command(cmd, stderr=subprocess.PIPE)
def execute(): if has_node: cmd = [has_node, 'a.' + which + '.js'] + args out = run_command(cmd) if out.strip() != expected.strip(): fail(out, expected)
os.listdir('bin'))) for e in executables: print '.. %s --help' % e out, err = subprocess.Popen([os.path.join('bin', e), '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() assert len(out) == 0, 'Expected no stdout, got:\n%s' % out assert e in err, 'Expected help to contain program name, got:\n%s' % err assert len(err.split('\n')) > 8, 'Expected some help, got:\n%s' % err print '\n[ checking wasm-opt -o notation... ]\n' wast = os.path.join('test', 'hello_world.wast') delete_from_orbit('a.wast') cmd = [os.path.join('bin', 'wasm-opt'), wast, '-o', 'a.wast'] run_command(cmd) fail_if_not_identical(open('a.wast').read(), open(wast).read()) print '\n[ checking wasm-opt passes... ]\n' for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t passname = os.path.basename(t).replace('.wast', '') opts = ['-O'] if passname == 'O' else [ '--' + p for p in passname.split('_') ] t = os.path.join('test', 'passes', t) actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0
wasm = asm.replace('.asm.js', '.fromasm') if not precise: cmd += ['--imprecise'] wasm += '.imprecise' if not opts: cmd += ['--no-opts'] wasm += '.no-opts' if precise and opts: # test mem init importing open('a.mem', 'wb').write(asm) cmd += ['--mem-init=a.mem'] if 'i64' in asm or 'wasm-only' in asm: cmd += ['--wasm-only'] print '..', asm, wasm print ' ', ' '.join(cmd) actual = run_command(cmd) with open(os.path.join('test', wasm), 'w') as o: o.write(actual) for dot_s_dir in ['dot_s', 'llvm_autogenerated']: for s in sorted(os.listdir(os.path.join('test', dot_s_dir))): if not s.endswith('.s'): continue print '..', s wasm = s.replace('.s', '.wast') full = os.path.join('test', dot_s_dir, s) stack_alloc = ['--allocate-stack=1024'] if dot_s_dir == 'llvm_autogenerated' else [] cmd = [os.path.join('bin', 's2wasm'), full, '--emscripten-glue'] + stack_alloc if s.startswith('start_'): cmd.append('--start') actual = run_command(cmd, stderr=subprocess.PIPE, expected_err='') expected_file = os.path.join('test', dot_s_dir, wasm)
def run_spec_test(wast): cmd = WASM_SHELL + [wast] # we must skip the stack machine portions of spec tests or apply other extra args extra = {} cmd = cmd + (extra.get(os.path.basename(wast)) or []) return run_command(cmd, stderr=subprocess.PIPE)
def execute(): if NODEJS: cmd = [NODEJS, 'a.' + which + '.js'] + args out = run_command(cmd) if out.strip() != expected.strip(): fail(out, expected)
def run_spec_test(wast): print ' run wasm-shell on', wast cmd = [os.path.join('bin', 'wasm-shell'), wast] return run_command(cmd, stderr=subprocess.PIPE)
print ' ', ' '.join(cmd) actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w') as o: o.write(actual) for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t passname = os.path.basename(t).replace('.wast', '') opts = ['-O'] if passname == 'O' else ['--' + p for p in passname.split('_')] t = os.path.join('test', 'passes', t) actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0 with open('split.wast', 'w') as o: o.write(module) cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print'] actual += run_command(cmd) with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual) print '\n[ checking wasm-opt -o notation... ]\n' wast = os.path.join('test', 'hello_world.wast') cmd = [os.path.join('bin', 'wasm-opt'), wast, '-o', 'a.wast'] run_command(cmd) open(wast, 'w').write(open('a.wast').read()) print '\n[ checking binary format testcases... ]\n' for wast in sorted(os.listdir('test')): 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)
print ' ', ' '.join(cmd) actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() with open(os.path.join('test', 'print', wasm + '.minified.txt'), 'w') as o: o.write(actual) for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t passname = os.path.basename(t).replace('.wast', '') opts = ['-O'] if passname == 'O' else ['--' + p for p in passname.split('_')] t = os.path.join('test', 'passes', t) actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0 with open('split.wast', 'w') as o: o.write(module) cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print'] actual += run_command(cmd) with open(os.path.join('test', 'passes', passname + '.txt'), 'w') as o: o.write(actual) print '\n[ checking binary format testcases... ]\n' for wast in sorted(os.listdir('test')): 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')
os.listdir('bin'))) for e in executables: print '.. %s --help' % e out, err = subprocess.Popen([os.path.join('bin', e), '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() assert len(out) == 0, 'Expected no stdout, got:\n%s' % out assert e in err, 'Expected help to contain program name, got:\n%s' % err assert len(err.split('\n')) > 8, 'Expected some help, got:\n%s' % err print '\n[ checking wasm-opt -o notation... ]\n' wast = os.path.join('test', 'hello_world.wast') delete_from_orbit('a.wast') cmd = [os.path.join('bin', 'wasm-opt'), wast, '-o', 'a.wast'] run_command(cmd) fail_if_not_identical(open('a.wast').read(), open(wast).read()) print '\n[ checking wasm-opt passes... ]\n' for t in sorted(os.listdir(os.path.join('test', 'passes'))): if t.endswith('.wast'): print '..', t passname = os.path.basename(t).replace('.wast', '') opts = ['-O'] if passname == 'O' else ['--' + p for p in passname.split('_')] t = os.path.join('test', 'passes', t) actual = '' for module, asserts in split_wast(t): assert len(asserts) == 0 with open('split.wast', 'w') as o: o.write(module) cmd = [os.path.join('bin', 'wasm-opt')] + opts + ['split.wast', '--print']