Skip to content

Commit c07320f

Browse files
committed
Fail coverage run when libFuzzer reports an error not only when exit
code is non-zero. Additionally, add a small log file to indicate the fuzzer target for which the coverage measurement did not complete succesfully.
1 parent fbdc5da commit c07320f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

infra/base-images/base-runner/coverage

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ function run_fuzz_target {
9999

100100
export LLVM_PROFILE_FILE=$profraw_file
101101
timeout $TIMEOUT $OUT/$target $args &> $LOGS_DIR/$target.log
102-
if (( $? != 0 )); then
102+
cov_retcode=$?
103+
104+
target_error_log="$LOGS_DIR/${target}_error.log"
105+
grep -E "==[0-9]+== ERROR: libFuzzer:" "$LOGS_DIR/$target.log" > "$target_error_log"
106+
grep_retcode=$?
107+
108+
echo "Cov returncode: $cov_retcode, grep returncode: $grep_retcode"
109+
if (( $cov_retcode != 0 || $grep_retcode == 0 )); then
103110
echo "Error occured while running $target:"
104111
cat $LOGS_DIR/$target.log
105112
fi
@@ -126,6 +133,12 @@ function run_fuzz_target {
126133
llvm-cov export -summary-only -instr-profile=$profdata_file -object=$target \
127134
$shared_libraries $LLVM_COV_COMMON_ARGS > $FUZZER_STATS_DIR/$target.json
128135

136+
# If grep returned zero an error was matched.
137+
echo "Coverage error, creating log file: $FUZZER_STATS_DIR/${target}_error.log"
138+
if (( $cov_retcode != 0 || $grep_retcode == 0 )); then
139+
mv "$target_error_log" "$FUZZER_STATS_DIR/${target}_error.log";
140+
fi
141+
129142
# For introspector.
130143
llvm-cov show -instr-profile=$profdata_file -object=$target -line-coverage-gt=0 $shared_libraries $BRANCH_COV_ARGS $LLVM_COV_COMMON_ARGS > ${TEXTCOV_REPORT_DIR}/$target.covreport
131144
}

0 commit comments

Comments
 (0)