Skip to content

Commit deb5af9

Browse files
committed
tests: don't fail check-fuzz-harnesses on an absent corpus
The guard required tests/fuzz/corpus/<name>/ to exist for each harness, and .gitignore excludes that directory — deliberately, since it holds hundreds of SHA-named files libFuzzer generates. So the check could only pass on a machine that had already fuzzed, and had to fail on every fresh checkout: green here, red in CI, on untracked local state. The corpus pairing is now reported rather than enforced, the same way the guard already treats a missing sanitizer toolchain — loudly, so it reads as unchecked rather than as clean. What it still gates on is the part a checkout can actually verify, and the reason it exists: that the harnesses build and link against the tree, after five of six had silently stopped compiling.
1 parent ce210d9 commit deb5af9

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

tests/check-fuzz-harnesses

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#
1919
# The check drives `make fuzz` rather than reassembling its command line, so it
2020
# cannot pass while the target it is guarding fails. It also pairs each harness
21-
# with its seed corpus: a harness with no corpus starts from nothing every run.
21+
# with its corpus and says which have none -- a note, not a verdict: a corpus is
22+
# grown by fuzzing and is untracked, so a fresh checkout has none of them.
2223
#
2324
# Soft dependency: without a compiler that can link -fsanitize=fuzzer this
2425
# SKIPs, loudly, so a missing toolchain reads as unchecked rather than as
@@ -87,12 +88,16 @@ for f in "$FUZZ_DIR"/fuzz_*.c; do
8788
fi
8889
done
8990

91+
# Reported, never fatal. A corpus is grown by running the fuzzer and is
92+
# untracked by design (.gitignore), so it exists only on a machine that has
93+
# fuzzed -- a checkout has none, and failing on that would mean this guard could
94+
# only ever pass where it was not needed. What it says here is a note to whoever
95+
# is about to fuzz, not a claim about the tree.
9096
if [ -n "$no_corpus" ]; then
91-
printf '%scheck-fuzz-harnesses: FAIL%s — harness with no seed corpus:%s\n' \
92-
"$RED" "$RESET" "$no_corpus"
93-
printf ' expected %s/<name>/ for each tests/fuzz/fuzz_<name>.c\n' \
97+
printf '%scheck-fuzz-harnesses: note%s — no local corpus yet:%s\n' \
98+
"$YELLOW" "$RESET" "$no_corpus"
99+
printf ' %s/<name>/ is grown by running the fuzzer; these start from nothing\n' \
94100
"$CORPUS_DIR"
95-
exit 1
96101
fi
97102

98103
guard_scope "check-fuzz-harnesses" "$n" 4
@@ -127,6 +132,9 @@ if [ -n "$missing" ]; then
127132
exit 1
128133
fi
129134

130-
printf '%scheck-fuzz-harnesses: OK%s (%d harnesses build and link, each seeded)\n' \
131-
"$GREEN" "$RESET" "$n"
135+
_nc=0
136+
for _b in $no_corpus; do _nc=$((_nc + 1)); done
137+
_seeded="$((n - _nc)) of $n have a local corpus"
138+
printf '%scheck-fuzz-harnesses: OK%s (%d harnesses build and link; %s)\n' \
139+
"$GREEN" "$RESET" "$n" "$_seeded"
132140
exit 0

0 commit comments

Comments
 (0)