From 52550241b7cf230571322dfa7dcc37de5761f74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ber=C4=8Di=C4=8D?= Date: Mon, 5 Oct 2020 18:31:32 +0200 Subject: [PATCH] go: Fix fuzzer building to fail on error --- .buildkite/code.pipeline.yml | 1 + go/Makefile | 6 +++--- go/consensus/tendermint/fuzz/fuzz.go | 13 +++++++------ go/storage/fuzz/fuzz.go | 5 ++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.buildkite/code.pipeline.yml b/.buildkite/code.pipeline.yml index f44a46626c1..0adb8b4d733 100644 --- a/.buildkite/code.pipeline.yml +++ b/.buildkite/code.pipeline.yml @@ -184,6 +184,7 @@ steps: # TODO: Consider making this a part of the development Docker image. - go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build - make -C go build-fuzz + soft_fail: true retry: <<: *retry_agent_failure plugins: diff --git a/go/Makefile b/go/Makefile index 0c29638992a..8cdf045262a 100644 --- a/go/Makefile +++ b/go/Makefile @@ -92,7 +92,7 @@ if [ "$(FUZZ_NO_BUILD)" != "1" ]; then \ mkdir -p "$$WORKDIR"; \ pushd $$TARGETDIR >/dev/null; \ $(ECHO) "$(CYAN)*** Building fuzzer for $@...$(OFF)"; \ - go-fuzz-build -o $$WORKDIR/fuzz.zip; \ + go-fuzz-build -o $$WORKDIR/fuzz.zip || exit 1; \ popd >/dev/null; \ fi; \ if [ "$(FUZZ_BUILD_ONLY)" != "1" ]; then \ @@ -100,9 +100,9 @@ if [ "$(FUZZ_BUILD_ONLY)" != "1" ]; then \ cd "$$WORKDIR"; \ $(ECHO) "$(CYAN)*** Running fuzzer for $@...$(OFF)"; \ if [ "$(@D)" == "." ]; then \ - go-fuzz -bin=$$WORKDIR/fuzz.zip -workdir=$$WORKDIR; \ + go-fuzz -bin=$$WORKDIR/fuzz.zip -workdir=$$WORKDIR || exit 1; \ else \ - go-fuzz -bin=$$WORKDIR/fuzz.zip -workdir=$$WORKDIR -func Fuzz$(@F); \ + go-fuzz -bin=$$WORKDIR/fuzz.zip -workdir=$$WORKDIR -func Fuzz$(@F) || exit 1; \ fi; \ fi; endef diff --git a/go/consensus/tendermint/fuzz/fuzz.go b/go/consensus/tendermint/fuzz/fuzz.go index 7971d8e6723..91268d089d5 100644 --- a/go/consensus/tendermint/fuzz/fuzz.go +++ b/go/consensus/tendermint/fuzz/fuzz.go @@ -14,6 +14,7 @@ import ( "github.com/oasisprotocol/oasis-core/go/common/fuzz" "github.com/oasisprotocol/oasis-core/go/consensus/api/transaction" "github.com/oasisprotocol/oasis-core/go/consensus/tendermint/abci" + "github.com/oasisprotocol/oasis-core/go/consensus/tendermint/api" epochtimemock "github.com/oasisprotocol/oasis-core/go/consensus/tendermint/apps/epochtime_mock" registryApp "github.com/oasisprotocol/oasis-core/go/consensus/tendermint/apps/registry" stakingApp "github.com/oasisprotocol/oasis-core/go/consensus/tendermint/apps/staking" @@ -24,7 +25,7 @@ var ( txSigner signature.Signer = memory.NewTestSigner("consensus-fuzz") // FuzzableApps is a list of ABCI apps the fuzzer can fuzz. - FuzzableApps []abci.Application = []abci.Application{ + FuzzableApps []api.Application = []api.Application{ epochtimemock.New(), registryApp.New(), stakingApp.New(), @@ -48,11 +49,11 @@ func Fuzz(data []byte) int { var pruneCfg abci.PruneConfig appConfig := &abci.ApplicationConfig{ - DataDir: "/tmp/oasis-node-fuzz-consensus", - Pruning: pruneCfg, - HaltEpochHeight: 1000000, - MinGasPrice: 1, - CheckpointInterval: 1 * time.Minute, + DataDir: "/tmp/oasis-node-fuzz-consensus", + Pruning: pruneCfg, + HaltEpochHeight: 1000000, + MinGasPrice: 1, + CheckpointerCheckInterval: 1 * time.Minute, } // The muxer will start with the previous state, if it exists (the state database isn't cleared). diff --git a/go/storage/fuzz/fuzz.go b/go/storage/fuzz/fuzz.go index b721756a52b..cd6e82c8ca1 100644 --- a/go/storage/fuzz/fuzz.go +++ b/go/storage/fuzz/fuzz.go @@ -26,7 +26,10 @@ var ( ) func init() { - signerFactory := file.NewFactory(identityDir, signature.SignerNode, signature.SignerP2P, signature.SignerConsensus) + signerFactory, err := file.NewFactory(identityDir, signature.SignerNode, signature.SignerP2P, signature.SignerConsensus) + if err != nil { + panic(err) + } identity, err := identity.Load(identityDir, signerFactory) if err != nil { panic(err)