summaryrefslogtreecommitdiff
path: root/fuzz/view-coverage.sh
blob: 7d509605419a5f0ede8ff13f3223c4ef7422ec0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash -e
#
# (C)2017-2018 Tim Ruehsen tim.ruehsen@gmx.de
#
# View the coverage report for one or more fuzzers.

# 1. execute 'make coverage-prepare' 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/ --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