internal/fuzz: support coverage builds with oss-fuzz

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>
This commit is contained in:
Damien Neil 2020-11-24 10:25:51 -08:00
parent d347099942
commit 81d297c66c

View File

@ -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