]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Improve fuzzer coverage report creation
authorTim Rühsen <tim.ruehsen@gmx.de>
Sat, 3 Mar 2018 17:42:20 +0000 (18:42 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 4 Mar 2018 17:58:38 +0000 (17:58 +0000)
fuzz/Makefile.am
fuzz/README.md
fuzz/view-coverage.sh

index f8225669c508c7bcbefb8c6c2628b28a88fa5cb6..9093034aca206500bcea4edcc6d8dec6d074acca 100644 (file)
@@ -84,18 +84,22 @@ oss-fuzz:
 
 .PHONY: oss-fuzz
 
-LCOV_INFO=coverage.info
-clean-lcov:
+CFLAGS ?=
+LDFLAGS ?=
+LCOV_INFO = coverage.info
+
+coverage-prepare: clean
        rm -rf $(LCOV_INFO) ../*/*.gc?? ../*/.libs/*.gc?? lcov/
        lcov --zerocounters --directory ../lib/
-
-coverage: clean clean-lcov
        $(MAKE) -C .. clean
        $(MAKE) -C ../gl
        $(MAKE) -C ../lib CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
+
+coverage:
+       lcov --capture --initial --directory ../lib/ --output-file $(LCOV_INFO)
        $(MAKE) check CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
-       lcov --capture --initial --directory ../lib/.libs --output-file $(LCOV_INFO)
-       lcov --capture --directory ../lib/.libs --output-file $(LCOV_INFO)
+       lcov --capture --directory ../lib/ --output-file $(LCOV_INFO)
+       lcov --remove $(LCOV_INFO) '/usr/include/*' '*/gl/*' -o $(LCOV_INFO)
        genhtml --prefix . --ignore-errors source $(LCOV_INFO) --legend --title "gnutls-fuzz" --output-directory=lcov
        @echo
        @echo "You can now view the coverage report with 'xdg-open lcov/index.html'"
index 1170cbe5c594ef6b0e9dea9305d08f38ded540c9..5cd42566afea91237abfb24f445d9cd2f404c5bc 100644 (file)
@@ -55,9 +55,11 @@ Code coverage reports currently work best with gcc+lcov+genhtml.
 
 In the top directory:
 ```
-CC=gcc CFLAGS="-O0 -g" ./configure --disable-doc --disable-manywarnings
-make fuzz-coverage
+cd fuzz
+make coverage-prepare
+make coverage
 xdg-open lcov/index.html
+# repeat the last two steps after changing *fuzzer.c
 ```
 
 Each fuzzer target has it's own files/functions to cover, e.g.
index 9461ba6468490b3516066c41cad68427ad9ebc88..7d509605419a5f0ede8ff13f3223c4ef7422ec0c 100755 (executable)
@@ -1,10 +1,10 @@
-#!/bin/bash -eu
+#!/bin/bash -e
 #
-# (C)2017 Tim Ruehsen tim.ruehsen@gmx.de
+# (C)2017-2018 Tim Ruehsen tim.ruehsen@gmx.de
 #
 # View the coverage report for one or more fuzzers.
 
-# 1. execute 'make coverage' in the fuzz/ directory
+# 1. execute 'make coverage-prepare' in the fuzz/ directory
 # 2. execute './view-coverage.sh <fuzz target(s)>
 
 # Example with single fuzzer:
@@ -20,9 +20,11 @@ if test -z "$1"; then
 fi
 
 LCOV_INFO=coverage.info
+
 lcov --zerocounters --directory ../lib/
-lcov --capture --initial --directory ../lib/.libs --directory . --output-file $LCOV_INFO
-make check TESTS="$*" CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
-lcov --capture --directory ../lib/.libs --output-file $LCOV_INFO
+#lcov --capture --initial --directory ../lib/ --directory . --output-file $LCOV_INFO
+make check TESTS="$*" CFLAGS="$CFLAGS --coverage" LDFLAGS="$LDFLAGS --coverage"
+lcov --capture --directory ../lib/ --output-file $LCOV_INFO
+lcov --remove $LCOV_INFO '/usr/include*' '*/gl/*' -o $LCOV_INFO
 genhtml --prefix . --ignore-errors source $LCOV_INFO --legend --title "$*" --output-directory=lcov
 xdg-open lcov/index.html