From ca54ec7a9b445fa15ed798a1052c250c15ba9941 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Mon, 29 Jun 2015 19:06:50 -0700 Subject: [PATCH] [test suite] integrate afl-cov with afl-fuzz wrapper scripts Here is an example for the client-rc.sh wrapper script to have it also generate code coverage results for afl-fuzz (afl-cov is enabled via two environmental variables AFL_COV and CODE_DIR). $ cd /tmp/afl-ramdisk/fwknop.git/test/afl/ $ AFL_COV=1 CODE_DIR=/home/mbr/git/fwknop.git ./fuzzing-wrappers/client-rc.sh --- test/afl/fuzzing-wrappers/client-rc.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/afl/fuzzing-wrappers/client-rc.sh b/test/afl/fuzzing-wrappers/client-rc.sh index d7fd6db5..3f92d56a 100755 --- a/test/afl/fuzzing-wrappers/client-rc.sh +++ b/test/afl/fuzzing-wrappers/client-rc.sh @@ -20,6 +20,22 @@ BANNER="$TSTR$GIT_STR" ### set up directories dir_init $ARCHIVE_DIR $FDIR $OUT_DIR PREV_OUT_DIR +### see if we're going to enable code coverage with afl-cov +if [ "$AFL_COV" != "" ] +then + echo "[+] Enabling afl-cov coverage mode..." + if [ "$CODE_DIR" = "" ] + then + echo "[*] Must set CODE_DIR with path to gcov compiled code" + exit 1 + fi + + ### kick off afl-cov in --background mode + afl-cov -d $OUT_DIR --live --background --sleep 10 --coverage-cmd \ + "LD_LIBRARY_PATH=$CODE_DIR/test/afl/$LIB_DIR $CODE_DIR/test/afl/$CLIENT --rc-file AFL_FILE -T -a 1.1.1.1 -n testhost2.com" \ + --code-dir $CODE_DIR +fi + ### make sure the client rc file can be parsed (a failure ### exit status is expected though) ./fuzzing-wrappers/helpers/fwknop-rc-test.sh && exit $?