Skip to content

Commit

Permalink
[test] Port tests in test/ to test/lit/basic/ (WebAssembly#6160)
Browse files Browse the repository at this point in the history
This ports all tests from `test/` to `test/lit/basic/`. The set of
commands and `CHECK` lines used are the same as the ones in WebAssembly#6159. Now
 we use `lit` to test these, this also deletes all `.wast`,
`.wast.from-wast`, `.wast.fromBinary`, and
`.wast.fromBinary.noDebugInfo` files from `test/` and all related test
routines from the python scripts.

All `CHECK` lines are generated by `update_lit_checks.py --all-items`.

This also deletes these three multi-memory tests in `test/lit/`, because
they seem to contain the same code with the ones in `test/`, which have
been ported to `test/lit/basic/` along with other tests.
- `test/lit/multi-memories-atomics64.wast`
- `test/lit/multi-memories-basics.wast`
- `test/lit/multi-memories-simd.wast`

This also adds newlines between `(func`s in case there are none to make
`CHECK` lines easy to view, and removes some extra existing newlines
here and there.
  • Loading branch information
aheejin authored and radekdoulik committed Jul 12, 2024
1 parent 0b3aa1f commit 9a426a4
Show file tree
Hide file tree
Showing 219 changed files with 23,387 additions and 24,231 deletions.
2 changes: 1 addition & 1 deletion check.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def run_wasm_reduce_tests():
if 'fsanitize=thread' not in str(os.environ):
print('\n[ checking wasm-reduce fuzz testcase ]\n')
# TODO: re-enable multivalue once it is better optimized
support.run_command(shared.WASM_OPT + [os.path.join(shared.options.binaryen_test, 'signext.wast'), '-ttf', '-Os', '-o', 'a.wasm', '--detect-features', '--disable-multivalue'])
support.run_command(shared.WASM_OPT + [os.path.join(shared.options.binaryen_test, 'lit/basic/signext.wast'), '-ttf', '-Os', '-o', 'a.wasm', '--detect-features', '--disable-multivalue'])
before = os.stat('a.wasm').st_size
support.run_command(shared.WASM_REDUCE + ['a.wasm', '--command=%s b.wasm --fuzz-exec --detect-features' % shared.WASM_OPT[0], '-t', 'b.wasm', '-w', 'c.wasm'])
after = os.stat('c.wasm').st_size
Expand Down
10 changes: 5 additions & 5 deletions scripts/test/wasm2js.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from . import shared
from . import support

tests = shared.get_tests(shared.options.binaryen_test)
basic_tests = shared.get_tests(os.path.join(shared.options.binaryen_test, 'lit', 'basic'))
# memory64 is not supported in wasm2js yet (but may be with BigInt eventually).
tests = [t for t in tests if '64.wast' not in t]
basic_tests = [t for t in basic_tests if '64.wast' not in t]
spec_tests = shared.options.spec_tests
spec_tests = [t for t in spec_tests if '.fail' not in t]
spec_tests = [t for t in spec_tests if '64.wast' not in t]
Expand All @@ -36,7 +36,7 @@ def check_for_stale_files():

# TODO(sbc): Generalize and apply other test suites
all_tests = []
for t in tests + spec_tests + wasm2js_tests:
for t in basic_tests + spec_tests + wasm2js_tests:
all_tests.append(os.path.basename(os.path.splitext(t)[0]))

all_files = os.listdir(shared.get_test_dir('wasm2js'))
Expand All @@ -50,7 +50,7 @@ def check_for_stale_files():

def test_wasm2js_output():
for opt in (0, 1):
for t in tests + spec_tests + wasm2js_tests:
for t in basic_tests + spec_tests + wasm2js_tests:
basename = os.path.basename(t)
if basename in wasm2js_blacklist:
continue
Expand Down Expand Up @@ -154,7 +154,7 @@ def update_wasm2js_tests():
print('\n[ checking wasm2js ]\n')

for opt in (0, 1):
for wasm in tests + spec_tests + wasm2js_tests:
for wasm in basic_tests + spec_tests + wasm2js_tests:
if not wasm.endswith('.wast'):
continue

Expand Down
61 changes: 3 additions & 58 deletions scripts/test/wasm_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,15 @@ def check():
actual, err = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True).communicate()
shared.fail_if_not_identical(actual.strip(), open(os.path.join(shared.get_test_dir('print'), wasm + '.minified.txt')).read().strip())

print('\n[ checking wasm-opt testcases... ]\n')

for t in shared.get_tests(shared.options.binaryen_test, ['.wast']):
print('..', os.path.basename(t))
f = t + '.from-wast'
cmd = shared.WASM_OPT + [t, '--print', '-all']
actual = support.run_command(cmd)
actual = actual.replace('printing before:\n', '')

shared.fail_if_not_identical_to_file(actual, f)

# FIXME Remove this condition after nullref is implemented in V8
if 'reference-types.wast' not in t:
shared.binary_format_check(t, wasm_as_args=['-g']) # test with debuginfo
shared.binary_format_check(t, wasm_as_args=[], binary_suffix='.fromBinary.noDebugInfo') # test without debuginfo

shared.minify_check(t)

print('\n[ checking wasm-opt debugInfo read-write... ]\n')


def update_wasm_opt_tests():
print('\n[ checking wasm-opt -o notation... ]\n')
print('\n[ updating wasm-opt -o notation... ]\n')
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wat')
cmd = shared.WASM_OPT + [wast, '-o', 'a.wast', '-S']
support.run_command(cmd)
open(wast, 'w').write(open('a.wast').read())

print('\n[ checking wasm-opt parsing & printing... ]\n')
print('\n[ updating wasm-opt parsing & printing... ]\n')
for t in shared.get_tests(shared.get_test_dir('print'), ['.wast']):
print('..', os.path.basename(t))
wasm = t.replace('.wast', '')
Expand All @@ -148,7 +128,7 @@ def update_wasm_opt_tests():
with open(wasm + '.minified.txt', 'wb') as o:
o.write(actual)

print('\n[ checking wasm-opt passes... ]\n')
print('\n[ updating wasm-opt passes... ]\n')
for t in shared.get_tests(shared.get_test_dir('passes'), ['.wast', '.wasm']):
print('..', os.path.basename(t))
# windows has some failures that need to be investigated:
Expand Down Expand Up @@ -183,38 +163,3 @@ def update_wasm_opt_tests():
with open('a.wat') as i:
with open(t + '.wat', 'w') as o:
o.write(i.read())

print('\n[ checking wasm-opt testcases... ]\n')
for t in shared.get_tests(shared.options.binaryen_test, ['.wast']):
print('..', os.path.basename(t))
f = t + '.from-wast'
cmd = shared.WASM_OPT + [t, '--print', '-all']
actual = support.run_command(cmd)
actual = actual.replace('printing before:\n', '')
open(f, 'w').write(actual)

print('\n[ checking binary format testcases... ]\n')
for wast in shared.get_tests(shared.options.binaryen_test, ['.wast']):
for debug_info in [0, 1]:
cmd = shared.WASM_AS + [wast, '-o', 'a.wasm', '-all']
if debug_info:
cmd += ['-g']
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 = shared.WASM_DIS + ['a.wasm', '-o', 'a.wast', '-all']
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')
actual = open('a.wast').read()
binary_file = wast + '.fromBinary'
if not debug_info:
binary_file += '.noDebugInfo'
with open(binary_file, 'w') as o:
print('writey', binary_file)
o.write(actual)
10 changes: 0 additions & 10 deletions test/atomics-unshared.wast

This file was deleted.

13 changes: 0 additions & 13 deletions test/atomics-unshared.wast.from-wast

This file was deleted.

14 changes: 0 additions & 14 deletions test/atomics-unshared.wast.fromBinary

This file was deleted.

14 changes: 0 additions & 14 deletions test/atomics-unshared.wast.fromBinary.noDebugInfo

This file was deleted.

184 changes: 0 additions & 184 deletions test/atomics.wast

This file was deleted.

Loading

0 comments on commit 9a426a4

Please sign in to comment.