summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-11-07 16:15:50 -0800
committerGitHub <noreply@github.com>2024-11-07 16:15:50 -0800
commit12ef2030ad2e7ceb5d208d4a24f25142d8a5f556 (patch)
tree480ae846b890d31358a1fb785778ea1ac1aa96f5 /scripts
parenta3d940ff8020ad8adb525b4ab018fcd86d08c54a (diff)
downloadbinaryen-12ef2030ad2e7ceb5d208d4a24f25142d8a5f556.tar.gz
binaryen-12ef2030ad2e7ceb5d208d4a24f25142d8a5f556.tar.bz2
binaryen-12ef2030ad2e7ceb5d208d4a24f25142d8a5f556.zip
[NFC] Refactor fuzzer's can_run_on_feature_opts() (#7066)
It never used the parameter, so remove that (we always access the features using a global anyhow). But add a new parameter, the wasm file, which does need to be passed in for a later PR (so in this PR it is just for future use).
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fuzz_opt.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index c465fbcf3..7522dce8c 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -766,7 +766,7 @@ class TestCaseHandler:
self.handle(before_wasm)
self.handle(after_wasm)
- def can_run_on_feature_opts(self, feature_opts):
+ def can_run_on_wasm(self, wasm):
return True
def increment_runs(self):
@@ -1167,7 +1167,7 @@ class Wasm2JS(TestCaseHandler):
f.write(wrapper)
return run_vm([shared.NODEJS, js_file, abspath('a.wasm')])
- def can_run_on_feature_opts(self, feature_opts):
+ def can_run_on_wasm(self, wasm):
# TODO: properly handle memory growth. right now the wasm2js handler
# uses --emscripten which assumes the Memory is created before, and
# wasm2js.js just starts with a size of 1 and no limit. We should switch
@@ -1522,7 +1522,7 @@ class Split(TestCaseHandler):
if not (NANS and optimized):
compare_between_vms(output, linked_output, 'Split')
- def can_run_on_feature_opts(self, feature_opts):
+ def can_run_on_wasm(self, wasm):
# to run the split wasm we use JS, that is, JS links the exports of one
# to the imports of the other, etc. since we run in JS, the wasm must be
# valid for JS.
@@ -1623,8 +1623,9 @@ def test_one(random_input, given_wasm):
bytes += wasm_size
print('post wasm size:', wasm_size)
- # first, find which handlers can even run here
- relevant_handlers = [handler for handler in testcase_handlers if not hasattr(handler, 'get_commands') and handler.can_run_on_feature_opts(FEATURE_OPTS)]
+ # First, find which handlers can even run here. Note that we check a.wasm
+ # and not b.wasm (optimizations do not change fuzzability).
+ relevant_handlers = [handler for handler in testcase_handlers if not hasattr(handler, 'get_commands') and handler.can_run_on_wasm('a.wasm')]
if len(relevant_handlers) == 0:
return 0
# filter by frequency
@@ -1642,7 +1643,7 @@ def test_one(random_input, given_wasm):
if testcase_handler in used_handlers:
continue
used_handlers.add(testcase_handler)
- assert testcase_handler.can_run_on_feature_opts(FEATURE_OPTS)
+ assert testcase_handler.can_run_on_wasm('a.wasm')
print('running testcase handler:', testcase_handler.__class__.__name__)
testcase_handler.increment_runs()