Skip to content

Commit

Permalink
internal/fuzz: support coverage builds with oss-fuzz
Browse files Browse the repository at this point in the history
Use OSS-Fuzz's new compile_go_fuzzer script, which enables code
coverage.

Change-Id: Iff07ac09d054e8c881d819b4ce6d016ad2808978
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/272768
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Joe Tsai <joetsai@google.com>
  • Loading branch information
neild committed Nov 24, 2020
1 parent d347099 commit 81d297c
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions internal/fuzz/oss-fuzz-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@

# This script is executed by OSS-Fuzz's build to create fuzzer binaries.

function compile_fuzzer {
path=$1
function=$2
fuzzer=$3

# Instrument all Go files relevant to this fuzzer
go-fuzz -tags=protolegacy -func $function -o $fuzzer.a $path

# Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
}

for x in internal/fuzz/*; do
if [ -d $x/corpus ]; then
name=$(basename $x)
compile_fuzzer google.golang.org/protobuf/$x Fuzz $name
compile_go_fuzzer google.golang.org/protobuf/$x Fuzz $name protolegacy
zip -jr $OUT/${name}_seed_corpus.zip $x/corpus
fi
done

0 comments on commit 81d297c

Please sign in to comment.