Skip to content

Commit b2ea4c4

Browse files
committed
fuzz: add timestamp logging to ci-fuzz.sh
Log timestamps at each phase (target verification, write-seeds, honggfuzz install, build, per-target fuzz start/finish, and corpus minimization) to identify where time is spent. AI tools were used in preparing this commit.
1 parent b12c25f commit b2ea4c4

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

fuzz/ci-fuzz.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
set -e
33
set -x
44

5+
log_time() {
6+
echo ":::: $(date '+%Y-%m-%d %H:%M:%S') $1"
7+
}
8+
9+
log_time "Verifying generated targets"
510
pushd src/msg_targets
611
rm msg_*.rs
712
./gen_target.sh
@@ -15,12 +20,14 @@ popd
1520

1621
export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
1722

23+
log_time "Generating write-seeds"
1824
mkdir -p hfuzz_workspace/full_stack_target/input
1925
pushd write-seeds
2026
RUSTFLAGS="$RUSTFLAGS --cfg=fuzzing" cargo run ../hfuzz_workspace/full_stack_target/input
2127
cargo clean
2228
popd
2329

30+
log_time "Installing honggfuzz"
2431
cargo 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

3037
export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz"
3138

39+
log_time "Building fuzz targets"
3240
cargo --color always hfuzz build -j8
41+
42+
log_time "Starting fuzz runs"
3343
for 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
@@ -54,11 +65,17 @@ done
5465

5566
# On main, minimize the corpus to keep the cache size manageable.
5667
if [ "$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"
6479
fi
80+
81+
log_time "Done"

0 commit comments

Comments
 (0)