summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-12-16 14:42:31 -0800
committerGitHub <noreply@github.com>2022-12-16 22:42:31 +0000
commit746c66521cae137ae36ef1c349873ec74d613a67 (patch)
tree0915ae21fd34e589cfa7c91ac4471aef82ee806e
parent6adc3aeee21391849ad2f2a6f2508cb9ab9e58c3 (diff)
downloadbinaryen-746c66521cae137ae36ef1c349873ec74d613a67.tar.gz
binaryen-746c66521cae137ae36ef1c349873ec74d613a67.tar.bz2
binaryen-746c66521cae137ae36ef1c349873ec74d613a67.zip
Fixed fuzzing of closed-world after #5347 (#5359)
An initial content testcase may only work in open world, so check for that using the existing mechanism of checking if such testcases work with out feature flags.
-rwxr-xr-xscripts/fuzz_opt.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index 72bb5e9c3..9da15cd64 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -56,6 +56,8 @@ PRINT_WATS = False
given_seed = None
+CLOSED_WORLD_FLAG = '--closed-world'
+
# utilities
@@ -131,6 +133,14 @@ def randomize_feature_opts():
if '--disable-gc' not in FEATURE_OPTS:
FEATURE_OPTS.append(TYPE_SYSTEM_FLAG)
+ # Pick closed or open with equal probability as both matter.
+ #
+ # Closed world is not a feature flag, technically, since it only makes sense
+ # to pass to wasm-opt (and not other tools). But decide on whether we'll
+ # be fuzzing in that mode now, as it determinies how we set other things up.
+ global CLOSED_WORLD
+ CLOSED_WORLD = random.random() < 0.5
+
ALL_FEATURE_OPTS = ['--all-features', '-all', '--mvp-features', '-mvp']
@@ -402,9 +412,14 @@ def pick_initial_contents():
return
test_name = temp_test_name
- # next, test the wasm.
+ # Next, test the wasm. Note that we must check for closed world explicitly
+ # here, as a testcase may only work in an open world, which means we need to
+ # skip it.
+ args = FEATURE_OPTS
+ if CLOSED_WORLD:
+ args.append(CLOSED_WORLD_FLAG)
try:
- run([in_bin('wasm-opt'), test_name] + FEATURE_OPTS,
+ run([in_bin('wasm-opt'), test_name] + args,
stderr=subprocess.PIPE,
silent=True)
except Exception:
@@ -1381,8 +1396,8 @@ def randomize_opt_flags():
if random.random() < 0.5:
ret += ['-fimfs=99999999']
# test both closed and open world
- if random.random() < 0.5:
- ret += ['--closed-world']
+ if CLOSED_WORLD:
+ ret += [CLOSED_WORLD_FLAG]
assert ret.count('--flatten') <= 1
return ret