summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-08-24 09:58:43 -0700
committerGitHub <noreply@github.com>2022-08-24 09:58:43 -0700
commitcee1c8681b3ae6bf5836999bd4df3d1d0997a138 (patch)
tree51aac51e21a2bb3842ad96b3c0afc7269679b6cd
parent892ebbe8a11417d0ffd3a5c798fb8bdab89d6634 (diff)
downloadbinaryen-cee1c8681b3ae6bf5836999bd4df3d1d0997a138.tar.gz
binaryen-cee1c8681b3ae6bf5836999bd4df3d1d0997a138.tar.bz2
binaryen-cee1c8681b3ae6bf5836999bd4df3d1d0997a138.zip
Simplify TrapsNeverHappen fuzzing (#4957)
Also fix a small logic error - call lines can be prefixes of each other, so use the full line (including newline) to differentiate.
-rwxr-xr-xscripts/fuzz_opt.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index 57b1c0400..3ff1cb554 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -1082,15 +1082,16 @@ class TrapsNeverHappen(TestCaseHandler):
# operations, etc.). in that case there is nothing for us to
# compare here; just leave.
return
- call_end = before.index('\n', call_start)
+ # include the line separator in the index, as function names may
+ # be prefixes of each other
+ call_end = before.index(os.linesep, call_start) + 1
# we now know the contents of the call line after which the trap
# happens, which is something like "[fuzz-exec] calling bar", and
# it is unique since it contains the function being called.
call_line = before[call_start:call_end]
- # find that call line, and remove everything from it onward.
- before_index = before.index(call_line)
+ # remove everything from that call line onward.
lines_pre = before.count(os.linesep)
- before = before[:before_index]
+ before = before[:call_start]
lines_post = before.count(os.linesep)
print(f'ignoring code due to trap (from "{call_line}"), lines to compare goes {lines_pre} => {lines_post} ')