Skip to content

Commit

Permalink
Improve fuzzer helper scripts
Browse files Browse the repository at this point in the history
* fuzz/get_ossfuzz_corpora: Improve description text
* fuzz/view-coverage.sh: Allow 1+ arguments
  • Loading branch information
rockdaboot committed Aug 23, 2017
1 parent f7fcbe0 commit 6f742a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
10 changes: 2 additions & 8 deletions fuzz/get_ossfuzz_corpora
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/bin/sh -eu

# First step. In the top directory execute:
# export CC=clang-5.0
# export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp"
# ./configure --enable-static --disable-doc
# make clean
# make -j$(nproc) LIB_FUZZING_ENGINE="-lFuzzer"
# cd fuzz
# make -j$(nproc) check
# As a first step see README.md and follow the steps under "Running a fuzzer using clang".

# You might need 'gsutil' to download new corpora from the Google cloud:
# Read the docs at https://github.com/google/oss-fuzz/blob/master/docs/corpora.md
# then install 'google-cloud-sdk' and execute 'gcloud init'.
# Now 'gsutil' should be ready to use.
Expand Down
32 changes: 24 additions & 8 deletions fuzz/view-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
#!/bin/bash -eu
#
# (C)2017 Tim Ruehsen tim.ruehsen@gmx.de
#
# View the coverage report for one or more fuzzers.

# 1. execute 'make fuzz-coverage' in the top directory
# 2. execute './view-coverage.sh <fuzz target>
# example: ./view-coverage.sh libwget_xml_parse_buffer_fuzzer
# 2. execute './view-coverage.sh <fuzz target(s)>

# Example with single fuzzer:
# ./view-coverage.sh libwget_xml_parse_buffer_fuzzer

# Example with two fuzzers:
# ./view-coverage.sh libwget_xml_parse_buffer_fuzzer libwget_metalink_parse_fuzzer

if test -z "$1"; then
echo "Usage: $0 <fuzz target>"
echo "Usage: $0 <fuzz target(s)>"
echo "Example: $0 libwget_xml_parse_buffer_fuzzer"
exit 1
fi

fuzzer="./"$1
#fuzzer="./"$1
LCOV_INFO=coverage.info
#make fuzz-coverage CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
./coverage.sh $fuzzer
#./coverage.sh $fuzzer
#lcov --capture --initial --directory ../libwget/.libs --directory . --output-file $LCOV_INFO
#lcov --capture --directory ../libwget/.libs --output-file $LCOV_INFO
#lcov --remove $LCOV_INFO '*/test_linking.c' '*/css_tokenizer.lex' '*/<stdout>' '*/*.h' -o $LCOV_INFO
#genhtml --prefix . --ignore-errors source $LCOV_INFO --legend --title "$1" --output-directory=lcov

lcov --zerocounters --directory ../libwget/
lcov --capture --initial --directory ../libwget/.libs --directory . --output-file $LCOV_INFO
make check TESTS="$*" CFLAGS="$(CFLAGS) --coverage" LDFLAGS="$(LDFLAGS) --coverage"
lcov --capture --directory ../libwget/.libs --output-file $LCOV_INFO
lcov --remove $LCOV_INFO '*/test_linking.c' '*/css_tokenizer.lex' '*/<stdout>' '*/*.h' -o $LCOV_INFO
genhtml --prefix . --ignore-errors source $LCOV_INFO --legend --title "$1" --output-directory=lcov
lcov --remove $LCOV_INFO '*/test_linking.c' '*/css_tokenizer.lex' '*/*.h' -o $LCOV_INFO
genhtml --prefix . --ignore-errors source $LCOV_INFO --legend --title "$*" --output-directory=lcov

xdg-open lcov/index.html

0 comments on commit 6f742a2

Please sign in to comment.