From 50014560fd6efc4ce15baca20bc4b08018c95232 Mon Sep 17 00:00:00 2001 From: Dongge Liu Date: Tue, 7 Feb 2023 03:31:31 +1100 Subject: [PATCH] Centipede skips seed corpus in build test (#9587) In #9427, some projects [failed on `bad_build_check`](https://pantheon.corp.google.com/cloud-build/builds;region=us-central1/31a7e835-32aa-49c8-81f1-f8d2eab9e3c1;step=20?project=oss-fuzz) (e.g., [`matio`](https://github.com/google/oss-fuzz/tree/master/projects/matio) has seed corpus) without explicit reason. This is because `Centipede` [does not skip seed corpus in `run_fuzzer`](https://github.com/google/oss-fuzz/blob/a5ee351ed1cfb97b73eab96787c0a86434cfd99e/infra/base-images/base-runner/run_fuzzer#L89) like [other fuzzers](https://github.com/google/oss-fuzz/blob/master/infra/base-images/base-runner/bad_build_check#L147). This PR sets the environment variable so that `Centipede` also skips seeds and pass the `bad_build_check`. --- infra/base-images/base-runner/bad_build_check | 2 +- infra/base-images/base-runner/run_fuzzer | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/infra/base-images/base-runner/bad_build_check b/infra/base-images/base-runner/bad_build_check index 412175b19b5a..3ee7a0416c26 100755 --- a/infra/base-images/base-runner/bad_build_check +++ b/infra/base-images/base-runner/bad_build_check @@ -122,7 +122,7 @@ function check_engine { # binaries if they are from trial build and production build. # TODO(Dongge): Support run test with sanitized binaries for trial and # production build. - timeout --preserve-status -s INT 20s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT + SKIP_SEED_CORPUS=1 timeout --preserve-status -s INT 20s run_fuzzer $FUZZER_NAME &>$FUZZER_OUTPUT CHECK_PASSED=$(egrep "\[0] begin-fuzz: ft: 0 cov: 0" -c $FUZZER_OUTPUT) if (( $CHECK_PASSED == 0 )); then echo "BAD BUILD: fuzzing $FUZZER with centipede failed." diff --git a/infra/base-images/base-runner/run_fuzzer b/infra/base-images/base-runner/run_fuzzer index fadda953da5b..b089dbeb56bc 100755 --- a/infra/base-images/base-runner/run_fuzzer +++ b/infra/base-images/base-runner/run_fuzzer @@ -86,6 +86,9 @@ rm -rf $FUZZER_OUT && mkdir -p $FUZZER_OUT SEED_CORPUS="${FUZZER}_seed_corpus.zip" +# TODO: Investigate why this code block is skipped +# by all default fuzzers in bad_build_check. +# They all set SKIP_SEED_CORPUS=1. if [ -f $SEED_CORPUS ] && [ -z ${SKIP_SEED_CORPUS:-} ]; then echo "Using seed corpus: $SEED_CORPUS" unzip -o -d ${CORPUS_DIR}/ $SEED_CORPUS > /dev/null