Skip to content

Commit

Permalink
Improve error reporting in fuzzer.
Browse files Browse the repository at this point in the history
Remove time limit from a flaky test.
  • Loading branch information
donkirkby committed Oct 13, 2023
1 parent aa38b91 commit 7c6cacd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
35 changes: 19 additions & 16 deletions test/PySrc/tests/live_coding_fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
Check that the source code display matches the original source code, and you
haven't hit some weird failure.
This gets run by the OSS-Fuzz project at https://github.com/google/oss-fuzz
It gets pulled from GitHub into the projects/live-py-plugin folder in that repo.
To test it locally, you can clone oss-fuzz, then copy this file into that
folder, build the docker image, and run the fuzzer.
This gets run by the ClusterFuzzLite project at
https://google.github.io/clusterfuzzlite/ To test it locally, you can clone
oss-fuzz, then build an external fuzzer and run it.
git clone https://github.com/donkirkby/oss-fuzz.git
git checkout live-py-plugin
git clone https://github.com/google/oss-fuzz.git
git clone https://github.com/donkirkby/live-py-plugin.git
cd oss-fuzz
cp /path/to/live-py-plugin/test/PySrc/tests/live_coding_fuzzer.py projects/live-py-plugin/
python3 infra/helper.py build_image live-py-plugin
python3 infra/helper.py build_fuzzers --sanitizer address live-py-plugin
python3 infra/helper.py check_build live-py-plugin
python3 infra/helper.py run_fuzzer --corpus-dir build/corpus/live-py-plugin/ live-py-plugin live_coding_fuzzer -- -runs=10000
python3 infra/helper.py build_image --external ../live-py-plugin/
python3 infra/helper.py build_fuzzers --external ../live-py-plugin/ --sanitizer address
python3 infra/helper.py check_build --external ../live-py-plugin/ --sanitizer address
python3 infra/helper.py run_fuzzer --external --corpus-dir=../live-py-plugin/corpus/ ../live-py-plugin/ live_coding_fuzzer -- -runs=10000
Then you can repeat the steps with --sanitizer undefined. Add -help=1 to the
last command, if you want to see libfuzzer options.
Expand Down Expand Up @@ -120,11 +118,16 @@ def test_one_input(data):

with replace_input(source):
runner = TraceRunner()
report = runner.trace_command(['space_tracer',
'--live',
'--trace_offset=1000000',
'--trace_width=0', # no limit
'-'])
try:
report = runner.trace_command(['space_tracer',
'--live',
'--trace_offset=1000000',
'--trace_width=0', # no limit
'-'])
except BaseException:
print("!!! Source !!!")
print(source)
raise
trimmed_report = re.sub(r'\s*\|\s*$', '', report, flags=re.MULTILINE)
if source != trimmed_report:
with replace_input(source):
Expand Down
1 change: 1 addition & 0 deletions test/PySrc/tests/test_traced.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ def bar(n): | n = 3
report = tracer.trace_command([
'space_tracer',
'--traced_file', 'example.py',
'--millisecond_limit', '0',
'example.py'])

assert report == expected_report
Expand Down

0 comments on commit 7c6cacd

Please sign in to comment.