summaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2018-03-03 18:42:20 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-03-04 17:58:38 +0000
commit7b800ea02745df2e40e9f8b09d152902f8abcb4a (patch)
treefd6d42ee3178ea8265dd68fb4e5ae9f80835a61a /fuzz
parentc8d7f94b1a9dab8b97b3277eed8a052adcb89689 (diff)
downloadgnutls-7b800ea02745df2e40e9f8b09d152902f8abcb4a.tar.gz
Improve fuzzer coverage report creation
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/Makefile.am16
-rw-r--r--fuzz/README.md6
-rwxr-xr-xfuzz/view-coverage.sh14
3 files changed, 22 insertions, 14 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am
index f8225669c5..9093034aca 100644
--- a/fuzz/Makefile.am
+++ b/fuzz/Makefile.am
@@ -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'"
diff --git a/fuzz/README.md b/fuzz/README.md
index 1170cbe5c5..5cd42566af 100644
--- a/fuzz/README.md
+++ b/fuzz/README.md
@@ -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.
diff --git a/fuzz/view-coverage.sh b/fuzz/view-coverage.sh
index 9461ba6468..7d50960541 100755
--- a/fuzz/view-coverage.sh
+++ b/fuzz/view-coverage.sh
@@ -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