1#!/bin/bash -eu 2# Copyright 2021 Google LLC. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18make 19 20# Not all fuzzers can be compiled with --sanitizer=coverage. 21# The specific issue is that gofuzz.NewFromGofuzz is not supported when compiling with coverage. 22# The current status of the coverage build is that we do not break it for the fuzzers that cannot be compiled. 23#The reason that we don't break the build script is to create coverage reports for the fuzzers that compile. 24if [[ $SANITIZER = *coverage* ]]; then 25 compile_go_fuzzer github.com/filecoin-project/lotus/chain/types FuzzMessage fuzz_message gofuzz 26 mkdir fuzzing 27 cp ../fuzzing-lotus/fuzz/fuzz.go fuzzing/ 28 compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockMsg fuzz_block_msg || true 29 compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockMsgStructural fuzz_block_msg_structural || true 30 compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzBlockHeader fuzz_block_header || true 31 compile_go_fuzzer github.com/filecoin-project/lotus/fuzzing FuzzNodesForHeight fuzz_nodes_for_height || true 32 exit 0 33fi 34 35compile_go_fuzzer ./chain/types FuzzMessage fuzz_message gofuzz 36 37 38# Fuzzers from fuzzing-lotus 39cd ../fuzzing-lotus/fuzz 40rm -Rf libfuzzer 41go mod init github.com/filecoin-project/fuzzing-lotus/fuzz 42 43compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockMsg fuzz_block_msg 44compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockMsgStructural fuzz_block_msg_structural 45compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzBlockHeader fuzz_block_header 46compile_go_fuzzer github.com/filecoin-project/fuzzing-lotus/fuzz FuzzNodesForHeight fuzz_nodes_for_height 47exit 0 48