Skip to content

Commit 1743b99

Browse files
authored
Merge pull request #4626 from joostjager/fuzz-corpus-symlink-count-fix
fuzz: count symlinked fuzz corpus files
2 parents e087519 + 04808cb commit 1743b99

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

fuzz/ci-fuzz.sh

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ check_crash() {
4141
fi
4242
}
4343

44+
corpus_count() {
45+
local CORPUS_DIR=$1
46+
# CI links cloned corpus directories into hfuzz_workspace.
47+
find -L "$CORPUS_DIR" -type f 2>/dev/null | wc -l
48+
}
49+
50+
check_linked_corpus() {
51+
local CORPUS_DIR=$1
52+
local FILE=$2
53+
local CORPUS_COUNT=$3
54+
55+
if [ -L "$CORPUS_DIR" ] && [ "$CORPUS_COUNT" -eq 0 ]; then
56+
echo "Linked corpus for $FILE has no visible input files: $CORPUS_DIR"
57+
exit 1
58+
fi
59+
}
60+
4461
run_targets() {
4562
local CRATE_DIR=$1
4663
local TARGET_RUSTFLAGS=$2
@@ -55,7 +72,8 @@ run_targets() {
5572
FILENAME=$(basename "$TARGET")
5673
FILE="${FILENAME%.*}"
5774
CORPUS_DIR="$HFUZZ_WORKSPACE/$FILE/input"
58-
CORPUS_COUNT=$(find "$CORPUS_DIR" -type f 2>/dev/null | wc -l)
75+
CORPUS_COUNT=$(corpus_count "$CORPUS_DIR")
76+
check_linked_corpus "$CORPUS_DIR" "$FILE" "$CORPUS_COUNT"
5977
# Run 8x the corpus size plus a baseline, ensuring full corpus replay
6078
# with room for new mutations. The 10-minute hard cap (--run_time 600)
6179
# prevents slow-per-iteration targets from running too long.
@@ -69,7 +87,7 @@ run_targets() {
6987
cargo --color always hfuzz run "$FILE"
7088
FUZZ_END=$(date +%s)
7189
FUZZ_TIME=$((FUZZ_END - FUZZ_START))
72-
FUZZ_CORPUS_COUNT=$(find "$CORPUS_DIR" -type f 2>/dev/null | wc -l)
90+
FUZZ_CORPUS_COUNT=$(corpus_count "$CORPUS_DIR")
7391
check_crash "$HFUZZ_WORKSPACE" "$FILE"
7492
if [ "$GITHUB_REF" = "refs/heads/main" ] || [ "$FUZZ_MINIMIZE" = "true" ]; then
7593
HFUZZ_RUN_ARGS="-M -q -n8 -t 3"
@@ -78,7 +96,7 @@ run_targets() {
7896
cargo --color always hfuzz run "$FILE"
7997
MIN_END=$(date +%s)
8098
MIN_TIME=$((MIN_END - MIN_START))
81-
MIN_CORPUS_COUNT=$(find "$CORPUS_DIR" -type f 2>/dev/null | wc -l)
99+
MIN_CORPUS_COUNT=$(corpus_count "$CORPUS_DIR")
82100
check_crash "$HFUZZ_WORKSPACE" "$FILE"
83101
SUMMARY="${SUMMARY}${FILE}|${ITERATIONS}|${CORPUS_COUNT}|${FUZZ_CORPUS_COUNT}|${FUZZ_TIME}|${MIN_CORPUS_COUNT}|${MIN_TIME}\n"
84102
else

0 commit comments

Comments
 (0)