aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdamKorcz <44787359+AdamKorcz@users.noreply.github.com>2021-04-01 02:48:35 +0100
committerGitHub <noreply@github.com>2021-03-31 18:48:35 -0700
commit5ed972de757799839c638d469aa96b9c9d2353fc (patch)
tree3cb2d18d7f14e1daf0dc0bc51b02ca4a9183e917
parentdf561687f6f31fd53a239864a36e9586cdd80106 (diff)
downloadoss-fuzz-5ed972de757799839c638d469aa96b9c9d2353fc.tar.gz
[lotus] Fix coverage build (#5544)
-rw-r--r--projects/lotus/Dockerfile6
-rw-r--r--projects/lotus/build.sh21
2 files changed, 22 insertions, 5 deletions
diff --git a/projects/lotus/Dockerfile b/projects/lotus/Dockerfile
index 1a4b2df6a..08dccff6a 100644
--- a/projects/lotus/Dockerfile
+++ b/projects/lotus/Dockerfile
@@ -17,7 +17,7 @@
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y mesa-opencl-icd ocl-icd-opencl-dev gcc \
git bzr jq pkg-config curl clang build-essential hwloc libhwloc-dev
-RUN git clone --depth 1 https://github.com/filecoin-project/lotus $GOPATH/src/github.com/filecoin-project/lotus
-RUN git clone --depth 1 https://github.com/filecoin-project/fuzzing-lotus $GOPATH/src/github.com/filecoin-project/fuzzing-lotus
+RUN git clone --depth 1 https://github.com/filecoin-project/lotus
+RUN git clone --depth 1 https://github.com/filecoin-project/fuzzing-lotus
COPY build.sh $SRC/
-WORKDIR $GOPATH/src/github.com/filecoin-project/lotus
+WORKDIR $SRC/lotus
diff --git a/projects/lotus/build.sh b/projects/lotus/build.sh
index d0de20761..64603099b 100644
--- a/projects/lotus/build.sh
+++ b/projects/lotus/build.sh
@@ -17,10 +17,26 @@
make
-compile_go_fuzzer github.com/filecoin-project/lotus/chain/types FuzzMessage fuzz_message gofuzz
+# Not all fuzzers can be compiled with --sanitizer=coverage.
+# The specific issue is that gofuzz.NewFromGofuzz is not supported when compiling with coverage.
+# The current status of the coverage build is that we do not break it for the fuzzers that cannot be compiled.
+#The reason that we don't break the build script is to create coverage reports for the fuzzers that compile.
+if [[ $SANITIZER = *coverage* ]]; then
+ compile_go_fuzzer github.com/filecoin-project/lotus/chain/types FuzzMessage fuzz_message gofuzz
+ mkdir fuzzing
+ cp ../fuzzing-lotus/fuzz/fuzz.go fuzzing/
+ compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockMsg fuzz_block_msg || true
+ compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockMsgStructural fuzz_block_msg_structural || true
+ compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockHeader fuzz_block_header || true
+ compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzNodesForHeight fuzz_nodes_for_height || true
+ exit 0
+fi
+compile_go_fuzzer ./chain/types FuzzMessage fuzz_message gofuzz
+
+
+# Fuzzers from fuzzing-lotus
cd ../fuzzing-lotus/fuzz
-# obsolete modules referenced
rm -Rf libfuzzer
go mod init github.com/filecoin-project/fuzzing-lotus/fuzz
@@ -28,3 +44,4 @@ compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockMsg fu
compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockMsgStructural fuzz_block_msg_structural
compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockHeader fuzz_block_header
compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzNodesForHeight fuzz_nodes_for_height
+exit 0