From 38fa2fe0b1abdf693e197da5dd83fdc5c6772634 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 22 Mar 2020 09:32:13 +0100 Subject: add commit test script test/checkcommit.sh --- test/checkcommit.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 test/checkcommit.sh (limited to 'test/checkcommit.sh') diff --git a/test/checkcommit.sh b/test/checkcommit.sh new file mode 100755 index 00000000..ec75d516 --- /dev/null +++ b/test/checkcommit.sh @@ -0,0 +1,39 @@ +#!/bin/sh +CMDLINE="/prg/tests/normal/tiff-4.0.4/tools/thumbnail @@ /dev/null" +INDIR="/prg/tests/normal/tiff-4.0.4/in-small" + +test -z "$1" -o -n "$4" && { + echo "Syntax: $0 commit-id \"\"" + echo + echo "Switches to the defined commit ID, compiles with profiling and runs" + echo "afl-fuzz on a defind target and input directory, saving timing," + echo "fuzzer_stats and profiling output to \".out\"" + echo + echo "Defaults:" + echo " indir: \"$INDIR\"" + echo " cmdline: \"$CMDLINE\"" + exit 1 +} + +C=$1 +test -n "$2" && INDIR=$2 +test -n "$3" && CMDLINE=$3 + +git checkout "$C" || { echo "CHECKOUT FAIL $C" > $C.out ; exit 1 ; } +export AFL_BENCH_JUST_ONE=1 +export CFLAGS="-O3 -funroll-loops -pg" +export LDFLAGS=-pg +make >/dev/null 2>&1 || echo ERROR: BUILD FAILURE +test -x ./afl-fuzz || { echo "BUILD FAIL $C" > $C.out ; make clean ; exit 1 ; } + +START=`date +%s` +echo $START > $C.out +time ./afl-fuzz -i "$INDIR" -s 123 -o out-profile -- $CMDLINE 2>> $C.out +STOP=`date +%s` +echo $STOP >> $C.out +echo RUNTIME: `expr $STOP - $START` >> $C.out +cat out-profile/fuzzer_stats >> $C.out +gprof ./afl-fuzz gmon.out >> $C.out + +make clean >/dev/null 2>&1 +rm -rf out-profile gmon.out -- cgit 1.4.1 From bd239d7e3db137b8ba4ea3c354c621785da7b586 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 22 Mar 2020 11:28:09 +0100 Subject: nice -n -20 to commit test script --- test/checkcommit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/checkcommit.sh') diff --git a/test/checkcommit.sh b/test/checkcommit.sh index ec75d516..e36a31a2 100755 --- a/test/checkcommit.sh +++ b/test/checkcommit.sh @@ -28,7 +28,7 @@ test -x ./afl-fuzz || { echo "BUILD FAIL $C" > $C.out ; make clean ; exit 1 ; } START=`date +%s` echo $START > $C.out -time ./afl-fuzz -i "$INDIR" -s 123 -o out-profile -- $CMDLINE 2>> $C.out +time nice -n -20 ./afl-fuzz -i "$INDIR" -s 123 -o out-profile -- $CMDLINE 2>> $C.out STOP=`date +%s` echo $STOP >> $C.out echo RUNTIME: `expr $STOP - $START` >> $C.out -- cgit 1.4.1 From 5b646818670c7f8a7a22503883a37c758d7acd64 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 22 Mar 2020 18:27:04 +0100 Subject: a little bit more performance --- src/afl-fuzz.c | 8 ++++---- test/checkcommit.sh | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'test/checkcommit.sh') diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index cc22fd5c..550bd255 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1051,9 +1051,9 @@ int main(int argc, char **argv_orig, char **envp) { } - show_stats(afl); + //show_stats(afl); - if (afl->not_on_tty) { + if (unlikely(afl->not_on_tty)) { ACTF("Entering queue cycle %llu.", afl->queue_cycle); fflush(stdout); @@ -1124,7 +1124,7 @@ int main(int argc, char **argv_orig, char **envp) { } - if (afl->queue_cur) show_stats(afl); + //if (afl->queue_cur) show_stats(afl); /* * ATTENTION - the following 10 lines were copied from a PR to Google's afl @@ -1149,12 +1149,12 @@ int main(int argc, char **argv_orig, char **envp) { } write_bitmap(afl); - write_stats_file(afl, 0, 0, 0); maybe_update_plot_file(afl, 0, 0); save_auto(afl); stop_fuzzing: + write_stats_file(afl, 0, 0, 0); afl->force_ui_update = 1; // ensure the screen is reprinted show_stats(afl); // print the screen one last time diff --git a/test/checkcommit.sh b/test/checkcommit.sh index e36a31a2..27d08d36 100755 --- a/test/checkcommit.sh +++ b/test/checkcommit.sh @@ -8,6 +8,7 @@ test -z "$1" -o -n "$4" && { echo "Switches to the defined commit ID, compiles with profiling and runs" echo "afl-fuzz on a defind target and input directory, saving timing," echo "fuzzer_stats and profiling output to \".out\"" + echo "Honors CFLAGS and LDFLAGS" echo echo "Defaults:" echo " indir: \"$INDIR\"" @@ -21,8 +22,9 @@ test -n "$3" && CMDLINE=$3 git checkout "$C" || { echo "CHECKOUT FAIL $C" > $C.out ; exit 1 ; } export AFL_BENCH_JUST_ONE=1 -export CFLAGS="-O3 -funroll-loops -pg" -export LDFLAGS=-pg +test -z "$CFLAGS" && CFLAGS="-O3 -funroll-loops" +export CFLAGS="$CFLAGS -pg" +export LDFLAGS="$LDFLAGS -pg" make >/dev/null 2>&1 || echo ERROR: BUILD FAILURE test -x ./afl-fuzz || { echo "BUILD FAIL $C" > $C.out ; make clean ; exit 1 ; } -- cgit 1.4.1