summaryrefslogtreecommitdiff
path: root/scripts/clusterfuzz
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-12-16 15:21:10 -0800
committerGitHub <noreply@github.com>2024-12-16 15:21:10 -0800
commitaa0550e28002183dd7ea9c2a48ec3533ba70f862 (patch)
tree56566cbe1c03ef9477171651cb8514289c16a65e /scripts/clusterfuzz
parent353b759b230dff8fb82aeb157aeb6db360d74a49 (diff)
downloadbinaryen-aa0550e28002183dd7ea9c2a48ec3533ba70f862.tar.gz
binaryen-aa0550e28002183dd7ea9c2a48ec3533ba70f862.tar.bz2
binaryen-aa0550e28002183dd7ea9c2a48ec3533ba70f862.zip
Fuzz JSPI (#7148)
* Add a new "sleep" fuzzer import, that does a sleep for some ms. * Add JSPI support in fuzz_shell.js. This is in the form of commented-out async/await keywords - commented out so that normal fuzzing is not impacted. When we want to fuzz JSPI, we uncomment them. We also apply the JSPI operations of marking imports and exports as suspending/promising. JSPI fuzzing is added to both fuzz_opt.py and ClusterFuzz's run.py.
Diffstat (limited to 'scripts/clusterfuzz')
-rwxr-xr-xscripts/clusterfuzz/run.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/clusterfuzz/run.py b/scripts/clusterfuzz/run.py
index 8ac880e0d..2fedb6510 100755
--- a/scripts/clusterfuzz/run.py
+++ b/scripts/clusterfuzz/run.py
@@ -200,6 +200,15 @@ def get_js_file_contents(i, output_dir):
print(f'Created {bytes} wasm bytes')
+ # Some of the time, fuzz JSPI (similar to fuzz_opt.py, see details there).
+ if system_random.random() < 0.25:
+ # Prepend the flag to enable JSPI.
+ js = 'var JSPI = 1;\n\n' + js
+
+ # Un-comment the async and await keywords.
+ js = js.replace('/* async */', 'async')
+ js = js.replace('/* await */', 'await')
+
return js