Commit d0d63928 authored by Lev Walkin's avatar Lev Walkin

overrideable fuzzing time

parent 490064f1
...@@ -6,6 +6,9 @@ dist_check_SCRIPTS = check-bundles.sh ...@@ -6,6 +6,9 @@ dist_check_SCRIPTS = check-bundles.sh
#code coverage data for the tests executables #code coverage data for the tests executables
CFLAGS = $(filter-out $(CODE_COVERAGE_CFLAGS), @CFLAGS@) CFLAGS = $(filter-out $(CODE_COVERAGE_CFLAGS), @CFLAGS@)
# Override single test fuzzing time using "make check FUZZ_TIME=1"
FUZZ_TIME=10
TESTS_ENVIRONMENT= \ TESTS_ENVIRONMENT= \
CC="${CC}" \ CC="${CC}" \
MAKE="${MAKE}" \ MAKE="${MAKE}" \
...@@ -13,6 +16,7 @@ TESTS_ENVIRONMENT= \ ...@@ -13,6 +16,7 @@ TESTS_ENVIRONMENT= \
CFLAGS_M32="${CFLAGS_M32}" \ CFLAGS_M32="${CFLAGS_M32}" \
LDFLAGS="${LDFLAGS}" \ LDFLAGS="${LDFLAGS}" \
LIBFUZZER_CFLAGS="${LIBFUZZER_CFLAGS}" \ LIBFUZZER_CFLAGS="${LIBFUZZER_CFLAGS}" \
FUZZ_TIME="${FUZZ_TIME}" \
ASAN_ENV_FLAGS="@ASAN_ENV_FLAGS@" \ ASAN_ENV_FLAGS="@ASAN_ENV_FLAGS@" \
srcdir=${srcdir} \ srcdir=${srcdir} \
abs_top_srcdir=${abs_top_srcdir} \ abs_top_srcdir=${abs_top_srcdir} \
......
...@@ -31,6 +31,8 @@ RNDTEMP="${RNDTEMP:-.tmp.random}" ...@@ -31,6 +31,8 @@ RNDTEMP="${RNDTEMP:-.tmp.random}"
srcdir="${srcdir:-.}" srcdir="${srcdir:-.}"
abs_top_srcdir="${abs_top_srcdir:-`pwd`/../../}" abs_top_srcdir="${abs_top_srcdir:-`pwd`/../../}"
abs_top_builddir="${abs_top_builddir:-`pwd`/../../}" abs_top_builddir="${abs_top_builddir:-`pwd`/../../}"
MAKE="${MAKE:-make}"
FUZZ_TIME="${FUZZ_TIME:-10}"
tests_succeeded=0 tests_succeeded=0
tests_failed=0 tests_failed=0
...@@ -104,7 +106,7 @@ verify_asn_type() { ...@@ -104,7 +106,7 @@ verify_asn_type() {
} }
Make() { Make() {
${MAKE:-make} -j "${parallelism}" "$@" || return $? ${MAKE} -j "${parallelism}" "$@" || return $?
} }
get_param() { get_param() {
...@@ -128,7 +130,7 @@ compile_and_test() { ...@@ -128,7 +130,7 @@ compile_and_test() {
where="$2" where="$2"
if [ "x$CC" = "x" ]; then CCSTR=""; else CCSTR="CC=${CC} "; fi if [ "x$CC" = "x" ]; then CCSTR=""; else CCSTR="CC=${CC} "; fi
reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${CFLAGS}\" ${MAKE:-make}" reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${CFLAGS}\" ${MAKE}"
env > .test-environment env > .test-environment
set > .test-set set > .test-set
...@@ -176,10 +178,9 @@ compile_and_test() { ...@@ -176,10 +178,9 @@ compile_and_test() {
fi fi
# Do a LibFuzzer based testing # Do a LibFuzzer based testing
fuzz_time=10
fuzz_cmd="${ASAN_ENV_FLAGS} UBSAN_OPTIONS=print_stacktrace=1" fuzz_cmd="${ASAN_ENV_FLAGS} UBSAN_OPTIONS=print_stacktrace=1"
fuzz_cmd="${fuzz_cmd} ./random-test-driver" fuzz_cmd="${fuzz_cmd} ./random-test-driver"
fuzz_cmd="${fuzz_cmd} -timeout=3 -max_total_time=${fuzz_time} -max_len=128" fuzz_cmd="${fuzz_cmd} -timeout=3 -max_total_time=${FUZZ_TIME} -max_len=128"
if grep "^fuzz:" Makefile >/dev/null ; then if grep "^fuzz:" Makefile >/dev/null ; then
echo "No fuzzer defined, skipping fuzzing" echo "No fuzzer defined, skipping fuzzing"
...@@ -198,7 +199,7 @@ compile_and_test() { ...@@ -198,7 +199,7 @@ compile_and_test() {
echo "Recompiling for fuzzing..." echo "Recompiling for fuzzing..."
rm -f random-test-driver.o rm -f random-test-driver.o
rm -f random-test-driver rm -f random-test-driver
reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${LIBFUZZER_CFLAGS} ${CFLAGS}\" ${MAKE:-make}" reproduce_make="cd \"${RNDTEMP}\" && ${CCSTR}CFLAGS=\"${LIBFUZZER_CFLAGS} ${CFLAGS}\" ${MAKE}"
echo "(${reproduce_make})" > .test-reproduce echo "(${reproduce_make})" > .test-reproduce
CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
...@@ -206,7 +207,7 @@ compile_and_test() { ...@@ -206,7 +207,7 @@ compile_and_test() {
return 4 return 4
fi fi
echo "Fuzzing will take a multiple of $fuzz_time seconds..." echo "Fuzzing will take a multiple of ${FUZZ_TIME} seconds..."
echo "(${reproduce_make} fuzz)" > .test-reproduce echo "(${reproduce_make} fuzz)" > .test-reproduce
CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make fuzz CFLAGS="${LIBFUZZER_CFLAGS} ${CFLAGS}" Make fuzz
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment