summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-09-24 10:52:16 -0700
committerGitHub <noreply@github.com>2021-09-24 10:52:16 -0700
commita6dbadb8d180aff3c481ad8fd3009a712c11b449 (patch)
tree659a10152ac7cd872df52c525cf4f102e7c16b42 /scripts
parent75e4e53292a5c6bf9736b0483de96667ba92774f (diff)
downloadbinaryen-a6dbadb8d180aff3c481ad8fd3009a712c11b449.tar.gz
binaryen-a6dbadb8d180aff3c481ad8fd3009a712c11b449.tar.bz2
binaryen-a6dbadb8d180aff3c481ad8fd3009a712c11b449.zip
[Fuzzer] Don't prompt user when seed is given (#4185)
Fuzzer shows the initial contents and prompts the user if they want to proceed after #4173, but when the fuzzer is used within a script called from `wasm-reduce`, we shouldn't pause for the user input. This shows the prompt only when there is no seed given. To do that, we now initialize the important initial contents from `main`. We used to assign those variables before we start `main`.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fuzz_opt.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index b72a81c13..5b4198ba9 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -44,6 +44,8 @@ INPUT_SIZE_MAX = 5 * INPUT_SIZE_MEAN
PRINT_WATS = False
+given_seed = None
+
# utilities
@@ -164,7 +166,7 @@ def randomize_fuzz_settings():
print('randomized settings (NaNs, OOB, legalize):', NANS, OOB, LEGALIZE)
-def get_important_initial_contents():
+def init_important_initial_contents():
FIXED_IMPORTANT_INITIAL_CONTENTS = [
# Perenially-important passes
os.path.join('lit', 'passes', 'optimize-instructions.wast'),
@@ -238,15 +240,18 @@ def get_important_initial_contents():
for test in recent_contents:
print(' ' + test)
print()
- ret = input('Do you want to proceed with these initial contents? (Y/n) ').lower()
- if ret != 'y' and ret != '':
- sys.exit(1)
-
- initial_contents = FIXED_IMPORTANT_INITIAL_CONTENTS + recent_contents
- return [os.path.join(shared.get_test_dir('.'), t) for t in initial_contents]
+ # We prompt the user only when there is no seed given. This fuzz_opt.py is
+ # often used with seed in a script called from wasm-reduce, in which case we
+ # should not pause for a user input.
+ if given_seed is None:
+ ret = input('Do you want to proceed with these initial contents? (Y/n) ').lower()
+ if ret != 'y' and ret != '':
+ sys.exit(1)
-IMPORTANT_INITIAL_CONTENTS = get_important_initial_contents()
+ initial_contents = FIXED_IMPORTANT_INITIAL_CONTENTS + recent_contents
+ global IMPORTANT_INITIAL_CONTENTS
+ IMPORTANT_INITIAL_CONTENTS = [os.path.join(shared.get_test_dir('.'), t) for t in initial_contents]
def pick_initial_contents():
@@ -1246,6 +1251,9 @@ if __name__ == '__main__':
else:
given_seed = None
print('checking infinite random inputs')
+
+ init_important_initial_contents()
+
seed = time.time() * os.getpid()
raw_input_data = 'input.dat'
counter = 0