Exemple #1
0
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']
            actual += run_command(cmd)
            # also check debug mode output is valid
            debugged = run_command(cmd + ['--debug'], stderr=subprocess.PIPE)
            fail_if_not_contained(actual, debugged)
        fail_if_not_identical(
            actual,
            open(os.path.join('test', 'passes', passname + '.txt')).read())

print '[ checking asm2wasm testcases... ]\n'
Exemple #2
0
    print '    ', ' '.join(cmd)
    actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
    with open(os.path.join('test', 'print', wasm + '.txt'), 'w') as o: o.write(actual)
    cmd = [os.path.join('bin', 'wasm-shell'), os.path.join('test', 'print', t), '--print-minified']
    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'