summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2017-08-21 15:16:55 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-08-24 16:39:21 +0200
commit2ccf497e918cf1d78e8cd650e4554b5551c902e2 (patch)
tree06f1baed9f536400a51c66f67d9afa2222b2e842
parentefdede1b1dcc6d82fe68e0ee2fc0ab8b87e29537 (diff)
downloadgnutls-2ccf497e918cf1d78e8cd650e4554b5551c902e2.tar.gz
fuzzer: Add script 'view-coverage'
This helper script is for viewing the code coverage of single (or combined) fuzzers running with all his corpora. It helps optimizing the code coverage by hand-crafting corpora and/or dictionaries. Signed-off-by: Tim Rühsen <tim.ruehsen@gmx.de>
-rwxr-xr-xfuzz/view-coverage.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/fuzz/view-coverage.sh b/fuzz/view-coverage.sh
new file mode 100755
index 0000000000..9461ba6468
--- /dev/null
+++ b/fuzz/view-coverage.sh
@@ -0,0 +1,28 @@
+#!/bin/bash -eu
+#
+# (C)2017 Tim Ruehsen tim.ruehsen@gmx.de
+#
+# View the coverage report for one or more fuzzers.
+
+# 1. execute 'make coverage' in the fuzz/ directory
+# 2. execute './view-coverage.sh <fuzz target(s)>
+
+# Example with single fuzzer:
+# ./view-coverage.sh gnutls_client_fuzzer
+
+# Example with two fuzzers:
+# ./view-coverage.sh gnutls_base64_decoder_fuzzer gnutls_base64_encoder_fuzzer
+
+if test -z "$1"; then
+ echo "Usage: $0 <fuzz target(s)>"
+ echo "Example: $0 gnutls_client_fuzzer"
+ exit 1
+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
+genhtml --prefix . --ignore-errors source $LCOV_INFO --legend --title "$*" --output-directory=lcov
+xdg-open lcov/index.html