diff options
author | Alon Zakai <azakai@google.com> | 2021-07-15 07:06:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 07:06:04 -0700 |
commit | 1b70f1e1f53084eae86680afd2c97ef034490197 (patch) | |
tree | ba1a1ca45ca40c53244f12e3e3ac7495c83b5d31 | |
parent | 3d4f128564a6ae2a378066112138a69b6414e521 (diff) | |
download | binaryen-1b70f1e1f53084eae86680afd2c97ef034490197.tar.gz binaryen-1b70f1e1f53084eae86680afd2c97ef034490197.tar.bz2 binaryen-1b70f1e1f53084eae86680afd2c97ef034490197.zip |
Fuzzer: Fix handling of features with initial contents (#3981)
Now that the features section adds on top of the commandline arguments,
it means the way we test if initial contents are ok to use will not work if
the wasm has a features section - as it will enable a feature, even if
we wanted to see if the wasm can work without that feature. To fix this,
strip the features section there.
-rwxr-xr-x | scripts/fuzz_opt.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index f4c260665..96b142234 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -255,7 +255,22 @@ def pick_initial_contents(): # the given wasm may not work with the chosen feature opts. for example, if # we pick atomics.wast but want to run with --disable-atomics, then we'd - # error. test the wasm. + # error, so we need to test the wasm. first, make sure it doesn't have a + # features section, as that would enable a feature that we might want to + # be disabled, and our test would not error as we want it to. + if test_name.endswith('.wasm'): + temp_test_name = 'initial.wasm' + try: + run([in_bin('wasm-opt'), test_name, '-all', '--strip-target-features', + '-o', temp_test_name]) + except Exception: + # the input can be invalid if e.g. it is raw data that is used with + # -ttf as fuzzer input + print('(initial contents are not valid wasm, ignoring)') + return + test_name = temp_test_name + + # next, test the wasm. try: run([in_bin('wasm-opt'), test_name] + FEATURE_OPTS, stderr=subprocess.PIPE, |