1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/usr/bin/env python2
import os
from support import run_command
from shared import (WASM2ASM, MOZJS, NODEJS, fail_if_not_identical, tests)
def test_wasm2asm():
print '\n[ checking wasm2asm testcases... ]\n'
# tests with i64s, invokes, etc.
blacklist = ['atomics.wast', 'address.wast']
spec_tests = [os.path.join('spec', t) for t in
sorted(os.listdir(os.path.join('test', 'spec')))]
for wasm in tests + spec_tests:
if not wasm.endswith('.wast') or os.path.basename(wasm) in blacklist:
continue
asm = os.path.basename(wasm).replace('.wast', '.2asm.js')
expected_file = os.path.join('test', asm)
if not os.path.exists(expected_file):
continue
print '..', wasm
cmd = WASM2ASM + [os.path.join('test', wasm)]
out = run_command(cmd)
# verify output
expected = open(expected_file).read()
fail_if_not_identical(out, expected)
open('a.2asm.js', 'w').write(out)
if NODEJS:
# verify asm.js is valid js
out = run_command([NODEJS, 'a.2asm.js'])
fail_if_not_identical(out, '')
if MOZJS:
# verify asm.js validates
# check only subset of err because mozjs emits timing info
out = run_command([MOZJS, '-w', 'a.2asm.js'],
expected_err='Successfully compiled asm.js code',
err_contains=True)
fail_if_not_identical(out, '')
if __name__ == "__main__":
test_wasm2asm()
|