Skip to content

Commit 7d0b064

Browse files
committed
skip coverage extraction if lcov_info_final file does not exist, better error tracking for commands with non-zero exit status
1 parent cc40a88 commit 7d0b064

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

afl-cov

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ def coverage_diff(cycle_num, fuzz_dir, cov_paths, afl_file, cov, cargs):
313313

314314
new_cov = extract_coverage(cov_paths['lcov_info_final'], cargs)
315315

316+
if not new_cov:
317+
return
318+
316319
### We aren't interested in the number of times AFL has executed
317320
### a line or function (since we can't really get this anyway because
318321
### gcov stats aren't influenced by AFL directly) - what we want is
@@ -457,6 +460,10 @@ def extract_coverage(lcov_file, cargs):
457460
search_rv = False
458461
tmp_cov = {}
459462

463+
if not os.path.exists(lcov_file):
464+
logr("[-] Coverage file '%s' does not exist, skipping." % lcov_file)
465+
return tmp_cov
466+
460467
### populate old lcov output for functions/lines that were called
461468
### zero times
462469
with open(lcov_file, 'r') as f:
@@ -708,10 +715,12 @@ def run_cmd(cmd, log_file, cargs, collect):
708715
out.append(line.rstrip('\n'))
709716
os.unlink(fh.name)
710717

711-
if (es != 0) and (collect == LOG_ERRORS):
718+
if (es != 0) and (collect == LOG_ERRORS or collect == WANT_OUTPUT):
712719
if log_file:
713720
logr(" Non-zero exit status '%d' for CMD: %s" % (es, cmd),
714721
log_file, cargs)
722+
for line in out:
723+
logr(line, log_file, cargs)
715724
else:
716725
print " Non-zero exit status '%d' for CMD: %s" % (es, cmd)
717726

0 commit comments

Comments
 (0)