diff options
author | Alon Zakai <azakai@google.com> | 2019-03-11 14:39:36 -0700 |
---|---|---|
committer | Alon Zakai <azakai@google.com> | 2019-03-11 14:39:36 -0700 |
commit | fec88b85e44b49ac3273b0b7d4e06fba060df36f (patch) | |
tree | 54ff425dfa91d92f70f6d9774ca9202ea7a75f5a | |
parent | d8bcf64e48f2c33dc785b16c8d3c0b8f5ccc63ef (diff) | |
download | binaryen-fec88b85e44b49ac3273b0b7d4e06fba060df36f.tar.gz binaryen-fec88b85e44b49ac3273b0b7d4e06fba060df36f.tar.bz2 binaryen-fec88b85e44b49ac3273b0b7d4e06fba060df36f.zip |
don't compare vms if fuzzing nans, since they are nondeterministic
-rw-r--r-- | scripts/fuzz_opt.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index 58751a72e..2346e2ee7 100644 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -26,8 +26,9 @@ from test.shared import options # parameters +NANS = True -FUZZ_OPTS = ['--mvp-features'] # may want to add '--no-fuzz-nans' for cross-VM testing +FUZZ_OPTS = ['--mvp-features'] INPUT_SIZE_LIMIT = 250 * 1024 @@ -134,9 +135,11 @@ def run_vms(prefix): if len(results) == 0: results = [0] - first = results[0] - for i in range(len(results)): - compare(first, results[i], 'comparing between vms at ' + str(i)) + # NaNs are a source of nondeterminism between VMs; don't compare them + if not NANS: + first = results[0] + for i in range(len(results)): + compare(first, results[i], 'comparing between vms at ' + str(i)) return results @@ -170,6 +173,12 @@ def test_one(infile, opts): run([in_bin('wasm-opt'), 'a.wasm', '-o', 'c.wasm'] + opts) assert open('b.wasm').read() == open('c.wasm').read(), 'output must be deterministic' + os.environ['OLD'] = '1' + run([in_bin('wasm-opt'), 'a.wasm', '-o', 'b.wasm', '-O']) + del os.environ['OLD'] + run([in_bin('wasm-opt'), 'a.wasm', '-o', 'c.wasm', '--ssa', '-O']) + assert os.path.getsize('b.wasm') >= os.path.getsize('c.wasm') + return bytes @@ -241,6 +250,9 @@ def get_multiple_opt_choices(): # main +if not NANS: + FUZZ_OPTS += ['--no-fuzz-nans'] + if __name__ == '__main__': print('checking infinite random inputs') random.seed(time.time() * os.getpid()) |