22set -e
33set -x
44
5+ log_time () {
6+ echo " :::: $( date ' +%Y-%m-%d %H:%M:%S' ) $1 "
7+ }
8+
9+ log_time " Verifying generated targets"
510pushd src/msg_targets
611rm msg_* .rs
712./gen_target.sh
1520
1621export RUSTFLAGS=" --cfg=secp256k1_fuzz --cfg=hashes_fuzz"
1722
23+ log_time " Generating write-seeds"
1824mkdir -p hfuzz_workspace/full_stack_target/input
1925pushd write-seeds
2026RUSTFLAGS=" $RUSTFLAGS --cfg=fuzzing" cargo run ../hfuzz_workspace/full_stack_target/input
2127cargo clean
2228popd
2329
30+ log_time " Installing honggfuzz"
2431cargo install --color always --force honggfuzz --no-default-features
2532
2633# Because we're fuzzing relatively few iterations, the maximum possible
@@ -29,20 +36,24 @@ sed -i 's/lto = true//' Cargo.toml
2936
3037export HFUZZ_BUILD_ARGS=" --features honggfuzz_fuzz"
3138
39+ log_time " Building fuzz targets"
3240cargo --color always hfuzz build -j8
41+
42+ log_time " Starting fuzz runs"
3343for TARGET in src/bin/* .rs; do
3444 FILENAME=$( basename $TARGET )
3545 FILE=" ${FILENAME% .* } "
3646 CORPUS_DIR=" hfuzz_workspace/$FILE /input"
3747 CORPUS_COUNT=$( find " $CORPUS_DIR " -type f 2> /dev/null | wc -l)
38- echo " Fuzzing $FILE (corpus: $CORPUS_COUNT files)"
3948 ITERATIONS=$(( CORPUS_COUNT * 3 + 1000 ))
49+ log_time " Fuzzing $FILE (corpus: $CORPUS_COUNT , iterations: $ITERATIONS )"
4050 HFUZZ_RUN_ARGS=" --exit_upon_crash -n8 -N $ITERATIONS --run_time 300"
4151 if [ " $FILE " = " chanmon_consistency_target" -o " $FILE " = " fs_store_target" ]; then
4252 HFUZZ_RUN_ARGS=" $HFUZZ_RUN_ARGS -F 64"
4353 fi
4454 export HFUZZ_RUN_ARGS
4555 cargo --color always hfuzz run $FILE
56+ log_time " Finished $FILE "
4657 if [ -f hfuzz_workspace/$FILE /HONGGFUZZ.REPORT.TXT ]; then
4758 cat hfuzz_workspace/$FILE /HONGGFUZZ.REPORT.TXT
4859 for CASE in hfuzz_workspace/$FILE /SIG* ; do
5465
5566# On main, minimize the corpus to keep the cache size manageable.
5667if [ " $GITHUB_REF " = " refs/heads/main" ]; then
68+ log_time " Starting corpus minimization"
5769 for TARGET in src/bin/* .rs; do
5870 FILENAME=$( basename $TARGET )
5971 FILE=" ${FILENAME% .* } "
72+ log_time " Minimizing $FILE "
6073 HFUZZ_RUN_ARGS=" -M -n8"
6174 export HFUZZ_RUN_ARGS
6275 cargo --color always hfuzz run $FILE
76+ log_time " Finished minimizing $FILE "
6377 done
78+ log_time " Corpus minimization complete"
6479fi
80+
81+ log_time " Done"
0 commit comments