Skip to content

Commit e9e13be

Browse files
committed
f copy to canonical name, drop guard and always replay via tests
1 parent 7f68e1e commit e9e13be

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

contrib/generate_fuzz_coverage.sh

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,22 @@ else
6666
cargo llvm-cov clean --workspace
6767

6868
# Import honggfuzz corpus if the artifact was downloaded.
69-
imported=0
7069
if [ -d "hfuzz_workspace" ]; then
7170
echo "Importing corpus from hfuzz_workspace..."
7271
for target_dir in hfuzz_workspace/*; do
7372
[ -d "$target_dir" ] || continue
7473
src_name="$(basename "$target_dir")"
75-
for dest in "$src_name" "${src_name%_target}"; do
76-
mkdir -p "test_cases/$dest"
77-
# Copy corpus files into the test_cases directory
78-
find "$target_dir" -maxdepth 2 -type f \
79-
\( -path "$target_dir/CORPUS/*" -o -path "$target_dir/INPUT/*" -o -path "$target_dir/NEW/*" -o -path "$target_dir/input/*" \) \
80-
-print0 | xargs -0 -I{} cp -n {} "test_cases/$dest/" 2>/dev/null || true
81-
done
74+
dest="${src_name%_target}"
75+
mkdir -p "test_cases/$dest"
76+
# Copy corpus files into the test_cases directory
77+
find "$target_dir" -maxdepth 2 -type f -path "$target_dir/input/*" \
78+
-print0 | xargs -0 -I{} cp -n {} "test_cases/$dest/"
8279
done
83-
# Check if any files were actually imported
84-
if [ -n "$(find test_cases -type f -print -quit 2>/dev/null)" ]; then
85-
imported=1
86-
fi
8780
fi
8881

89-
# Generate coverage based on whether a corpus was imported.
90-
if [ "$imported" = "1" ]; then
91-
echo "Replaying imported corpus via tests to generate coverage..."
92-
cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \
93-
--output-path "$OUTPUT_DIR/fuzz-codecov.json" --tests
94-
else
95-
echo "No corpus found; generating no-corpus coverage JSON..."
96-
cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \
97-
--output-path "$OUTPUT_DIR/fuzz-codecov.json" --no-run
98-
fi
82+
echo "Replaying imported corpus (if found) via tests to generate coverage..."
83+
cargo llvm-cov -j8 --codecov --ignore-filename-regex "fuzz/" \
84+
--output-path "$OUTPUT_DIR/fuzz-codecov.json" --tests
9985

10086
echo "Fuzz codecov report available at $OUTPUT_DIR/fuzz-codecov.json"
10187
fi

0 commit comments

Comments
 (0)