Skip to content

Commit 4c9cfeb

Browse files
authored
Allow running a portion of binaryen test suite (#2286)
1 parent 7773426 commit 4c9cfeb

3 files changed

Lines changed: 53 additions & 35 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ The `check.py` script supports some options:
383383
* If an interpreter is provided, we run the output through it, checking for
384384
parse errors.
385385
* If tests are provided, we run exactly those. If none are provided, we run
386-
them all.
386+
them all. To see what tests are available, run `./check.py --list-suites`.
387387
* Some tests require `emcc` or `nodejs` in the path. They will not run if the
388388
tool cannot be found, and you'll see a warning.
389389
* We have tests from upstream in `tests/spec`, in git submodules. Running

check.py

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import subprocess
2020
import sys
2121
import unittest
22+
from collections import OrderedDict
2223

2324
from scripts.test.support import run_command, split_wast, write_wast
2425
from scripts.test.shared import (
@@ -254,6 +255,10 @@ def run_wasm_metadce_tests():
254255

255256

256257
def run_wasm_reduce_tests():
258+
if not has_shell_timeout():
259+
print('\n[ skipping wasm-reduce testcases]\n')
260+
return
261+
257262
print('\n[ checking wasm-reduce testcases]\n')
258263

259264
# fixed testcases
@@ -285,13 +290,13 @@ def run_wasm_reduce_tests():
285290
def run_spec_tests():
286291
print('\n[ checking wasm-shell spec testcases... ]\n')
287292

288-
if len(requested) == 0:
293+
if not options.spec_tests:
289294
# FIXME we support old and new memory formats, for now, until 0xc, and so can't pass this old-style test.
290295
BLACKLIST = ['binary.wast']
291296
# FIXME to update the spec to 0xd, we need to implement (register "name") for import.wast
292297
spec_tests = [os.path.join('spec', t) for t in sorted(os.listdir(os.path.join(options.binaryen_test, 'spec'))) if t not in BLACKLIST]
293298
else:
294-
spec_tests = requested[:]
299+
spec_tests = options.spec_tests[:]
295300

296301
for t in spec_tests:
297302
if t.startswith('spec') and t.endswith('.wast'):
@@ -412,6 +417,10 @@ def run_validator_tests():
412417

413418

414419
def run_vanilla_tests():
420+
if not (has_vanilla_emcc and has_vanilla_llvm and 0):
421+
print('\n[ skipping emcc WASM_BACKEND testcases...]\n')
422+
return
423+
415424
print('\n[ checking emcc WASM_BACKEND testcases...]\n')
416425

417426
try:
@@ -522,30 +531,37 @@ def run_unittest():
522531
raise Exception("unittest failed")
523532

524533

534+
TEST_SUITES = OrderedDict([
535+
('help-messages', run_help_tests),
536+
('wasm-opt', run_wasm_opt_tests),
537+
('asm2wasm', asm2wasm.test_asm2wasm),
538+
('asm2wasm-binary', asm2wasm.test_asm2wasm_binary),
539+
('wasm-dis', run_wasm_dis_tests),
540+
('crash', run_crash_tests),
541+
('dylink', run_dylink_tests),
542+
('ctor-eval', run_ctor_eval_tests),
543+
('wasm-metadce', run_wasm_metadce_tests),
544+
('wasm-reduce', run_wasm_reduce_tests),
545+
('spec', run_spec_tests),
546+
('binaryenjs', binaryenjs.test_binaryen_js),
547+
('lld', lld.test_wasm_emscripten_finalize),
548+
('wasm2js', wasm2js.test_wasm2js),
549+
('validator', run_validator_tests),
550+
('vanilla', run_vanilla_tests),
551+
('gcc', run_gcc_tests),
552+
('unit', run_unittest),
553+
])
554+
555+
525556
# Run all the tests
526557
def main():
527-
run_help_tests()
528-
run_wasm_opt_tests()
529-
asm2wasm.test_asm2wasm()
530-
asm2wasm.test_asm2wasm_binary()
531-
run_wasm_dis_tests()
532-
run_crash_tests()
533-
run_dylink_tests()
534-
run_ctor_eval_tests()
535-
run_wasm_metadce_tests()
536-
if has_shell_timeout():
537-
run_wasm_reduce_tests()
538-
run_spec_tests()
539-
binaryenjs.test_binaryen_js()
540-
lld.test_wasm_emscripten_finalize()
541-
wasm2js.test_wasm2js()
542-
run_validator_tests()
543-
if has_vanilla_emcc and has_vanilla_llvm and 0:
544-
run_vanilla_tests()
545-
print('\n[ checking example testcases... ]\n')
546-
if options.run_gcc_tests:
547-
run_gcc_tests()
548-
run_unittest()
558+
if options.list_suites:
559+
for suite in TEST_SUITES.keys():
560+
print(suite)
561+
return 0
562+
563+
for test in requested or TEST_SUITES.keys():
564+
TEST_SUITES[test]()
549565

550566
# Check/display the results
551567
if shared.num_failures == 0:

scripts/test/shared.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from __future__ import print_function
16+
1517
import argparse
1618
import difflib
1719
import glob
@@ -41,13 +43,6 @@ def parse_args(args):
4143
action='store_false',
4244
help=('If set, the whole test suite will run to completion independent of'
4345
' earlier errors.'))
44-
parser.add_argument(
45-
'--run-gcc-tests', dest='run_gcc_tests', action='store_true', default=True,
46-
help=('Chooses whether to run the tests that require building with native'
47-
' GCC. Default: true.'))
48-
parser.add_argument(
49-
'--no-run-gcc-tests', dest='run_gcc_tests', action='store_false',
50-
help='If set, disables the native GCC tests.')
5146

5247
parser.add_argument(
5348
'--interpreter', dest='interpreter', default='',
@@ -73,8 +68,15 @@ def parse_args(args):
7368
help=('If specified, all unfreed (but still referenced) pointers at the'
7469
' end of execution are considered memory leaks. Default: disabled.'))
7570
parser.add_argument(
76-
'positional_args', metavar='tests', nargs=argparse.REMAINDER,
77-
help='Names specific tests to run.')
71+
'--spec-test', action='append', nargs='*', default=[], dest='spec_tests',
72+
help='Names specific spec tests to run.')
73+
parser.add_argument(
74+
'positional_args', metavar='TEST_SUITE', nargs='*',
75+
help=('Names specific test suites to run. Use --list-suites to see a '
76+
'list of all test suites'))
77+
parser.add_argument(
78+
'--list-suites', action='store_true',
79+
help='List the test suites that can be run.')
7880

7981
return parser.parse_args(args)
8082

@@ -89,7 +91,7 @@ def parse_args(args):
8991
def warn(text):
9092
global warnings
9193
warnings.append(text)
92-
print('warning:', text)
94+
print('warning:', text, file=sys.stderr)
9395

9496

9597
# setup

0 commit comments

Comments
 (0)