rules_fuzzing icon indicating copy to clipboard operation
rules_fuzzing copied to clipboard

How do you run a cc_fuzz_test() against a specific input?

Open haberman opened this issue 3 years ago • 2 comments

Expected Behavior

I can run the fuzz test against a known input, as described here: https://google.github.io/oss-fuzz/advanced-topics/reproducing/#fuzz-target-bugs

Actual Behavior

When I run the fuzz test, I get the following output:

mkdir: cannot create directory ‘/corpus’: Permission denied
mkdir: cannot create directory ‘/artifacts’: Permission denied
bazel-bin/upb/fuzz/file_descriptor_parsenew_fuzzer: line 12: /usr/local/google/home/haberman/code/upb/../rules_fuzzing/fuzzing/engines/libfuzzer_launcher.sh: No such file or directory

Steps to Reproduce the Problem

$ git clone https://github.com/protocolbuffers/upb.git
$ cd upb
$ bazel build -c opt --config=asan-libfuzzer upb/fuzz:file_descriptor_parsenew_fuzzer
$ bazel-bin/upb/fuzz/file_descriptor_parsenew_fuzzer /dev/null
mkdir: cannot create directory ‘/corpus’: Permission denied
mkdir: cannot create directory ‘/artifacts’: Permission denied
bazel-bin/upb/fuzz/file_descriptor_parsenew_fuzzer: line 12: /usr/local/google/home/haberman/code/upb/../rules_fuzzing/fuzzing/engines/libfuzzer_launcher.sh: No such file or directory

Specifications

  • Version: 0.3.1: https://github.com/protocolbuffers/upb/blob/main/WORKSPACE#L52
  • Platform: Linux

cc @ericsalo

haberman avatar Oct 14 '22 17:10 haberman

Either of the following should work:

bazel run -c opt --config=asan-libfuzzer upb/fuzz:file_descriptor_parsenew_fuzzer_run -- --regression=true --corpus_dir= /some/file
bazel run -c opt --config=asan-libfuzzer upb/fuzz:file_descriptor_parsenew_fuzzer_bin /some/file

The *_run target is a Python launcher that accepts engine-agnostic arguments, *_bin gives you the raw libFuzzer binary.

fmeum avatar Oct 14 '22 18:10 fmeum

Can documentation be added to the user guide for this?

haberman avatar Oct 14 '22 20:10 haberman