Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run_opt_test(wast, stdout=None):
def check_expected(actual, expected, stdout=None):
if expected and os.path.exists(expected):
expected = open(expected).read()
print(' (using expected output)', file=stdout)
shared.verbose_log(' (using expected output)', file=stdout)
actual = actual.strip()
expected = expected.strip()
if actual != expected:
Expand Down Expand Up @@ -229,7 +229,7 @@ def run_one_spec_test(wast: Path, stdout=None):
actual = run_spec_test(str(wast), stdout=stdout)
except Exception as e:
if ('wasm-validator error' in str(e) or 'error: ' in str(e)) and '.fail.' in test_name:
print('<< test failed as expected >>', file=stdout)
shared.verbose_log('<< test failed as expected >>', file=stdout)
return # don't try all the binary format stuff TODO
else:
shared.fail_with_error(str(e))
Expand All @@ -249,7 +249,7 @@ def run_one_spec_test(wast: Path, stdout=None):
if not module:
# Skip any initial assertions that don't have a module
continue
print(f' testing split module {i}', file=stdout)
shared.verbose_log(f' testing split module {i}', file=stdout)
split_name = base_name + f'_split{i}.wast'
support.write_wast(split_name, module)
run_opt_test(split_name, stdout=stdout) # also that our optimizer doesn't break on it
Expand Down
16 changes: 12 additions & 4 deletions scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def parse_args(args):
action='store_false', default=True,
help='Disables the automatic selection of important initial contents '
'in fuzzer.')
parser.add_argument(
'--verbose', action='store_true', default=False,
help='Enables verbose logging.')

return parser.parse_args(args)

Expand All @@ -118,6 +121,11 @@ def print_heading(msg):
print(f'[ {msg} ]')


def verbose_log(*args, **kwargs):
if options.verbose:
print(*args, **kwargs)


# setup

# Locate Binaryen build artifacts directory (bin/ by default)
Expand Down Expand Up @@ -472,24 +480,24 @@ def binary_format_check(wast, verify_final_result=True, base_name=None, stdout=N
as_file = f"{base_name}-a.wasm" if base_name is not None else "a.wasm"
disassembled_file = f"{base_name}-ab.wast" if base_name is not None else "ab.wast"

print(' (binary format check)', file=stdout)
verbose_log(' (binary format check)', file=stdout)
cmd = WASM_AS + [wast, '-o', as_file, '-all', '-g']
print(' ', ' '.join(cmd), file=stdout)
verbose_log(' ', ' '.join(cmd), file=stdout)
if os.path.exists(as_file):
os.unlink(as_file)
subprocess.check_call(cmd, stdout=subprocess.PIPE)
assert os.path.exists(as_file)

cmd = WASM_DIS + [as_file, '-o', disassembled_file, '-all']
print(' ', ' '.join(cmd), file=stdout)
verbose_log(' ', ' '.join(cmd), file=stdout)
if os.path.exists(disassembled_file):
os.unlink(disassembled_file)
subprocess.check_call(cmd, stdout=subprocess.PIPE)
assert os.path.exists(disassembled_file)

# make sure it is a valid wast
cmd = WASM_OPT + [disassembled_file, '-all', '-q']
print(' ', ' '.join(cmd), file=stdout)
verbose_log(' ', ' '.join(cmd), file=stdout)
subprocess.check_call(cmd, stdout=subprocess.PIPE)

if verify_final_result:
Expand Down
Loading