mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 17:33:50 +01:00
tests: Improve usability of test_fuzz.sh
Change-Id: I595e15d155dc6aa759671da510198c39b2e9c23a Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
14ba3747b5
commit
ac5a741420
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
usage ()
|
usage ()
|
||||||
{
|
{
|
||||||
|
test_ids=$(echo "${llvm_all_ids[*]}" | sed 's/ /, /g')
|
||||||
cat << EOF
|
cat << EOF
|
||||||
usage: $0 options
|
usage: $0 options
|
||||||
options:
|
options:
|
||||||
@ -9,7 +10,7 @@ options:
|
|||||||
-l, --llvm <n> Use llvm fuzz tests and run n times 0=just build, -1=skip (default $use_llvm).
|
-l, --llvm <n> Use llvm fuzz tests and run n times 0=just build, -1=skip (default $use_llvm).
|
||||||
-a, --afl <n> Use AFL fuzz tests and run n times 0=just build, -1=skip (default $use_afl).
|
-a, --afl <n> Use AFL fuzz tests and run n times 0=just build, -1=skip (default $use_afl).
|
||||||
-t, --time <n> Run each group of max time <n>[s,h,m,d] - n seconds, hours, minutes or days.
|
-t, --time <n> Run each group of max time <n>[s,h,m,d] - n seconds, hours, minutes or days.
|
||||||
-e <exec|rand|all> Run a specific llvm test or [test, rand, all].
|
-e <exec|rand|all> Run a specific llvm test or [$test_ids, rand, all].
|
||||||
-f <file> Use this file as initial raw input. Can be repeated.
|
-f <file> Use this file as initial raw input. Can be repeated.
|
||||||
-d <0,1> Use dump of internal inflate test corpus (default $use_internal_corp).
|
-d <0,1> Use dump of internal inflate test corpus (default $use_internal_corp).
|
||||||
-i <dir> Fuzz input dir (default $fuzzin_dir).
|
-i <dir> Fuzz input dir (default $fuzzin_dir).
|
||||||
@ -22,13 +23,14 @@ exit 0
|
|||||||
use_afl=-1
|
use_afl=-1
|
||||||
use_llvm=1
|
use_llvm=1
|
||||||
samp_files=
|
samp_files=
|
||||||
use_internal_corp=1
|
use_internal_corp=0
|
||||||
fuzzin_dir=fuzzin
|
fuzzin_dir=fuzzin
|
||||||
fuzzout_dir=fuzzout
|
fuzzout_dir=fuzzout
|
||||||
llvm_opts=" -print_final_stats=1"
|
llvm_opts=" -print_final_stats=1"
|
||||||
afl_timeout_cmd=""
|
afl_timeout_cmd=""
|
||||||
run_secs=0
|
run_secs=0
|
||||||
llvm_tests=("igzip_simple_inflate_fuzz_test")
|
llvm_tests=("igzip_simple_inflate_fuzz_test")
|
||||||
|
llvm_all_ids=("simple" "checked" "round_trip")
|
||||||
llvm_all_tests=("igzip_simple_inflate_fuzz_test" "igzip_checked_inflate_fuzz_test" "igzip_simple_round_trip_fuzz_test")
|
llvm_all_tests=("igzip_simple_inflate_fuzz_test" "igzip_checked_inflate_fuzz_test" "igzip_simple_round_trip_fuzz_test")
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
@ -70,7 +72,20 @@ while [ "$1" != "${1##-}" ]; do
|
|||||||
llvm_tests=${llvm_all_tests[$RANDOM % ${#llvm_all_tests[@]} ]}
|
llvm_tests=${llvm_all_tests[$RANDOM % ${#llvm_all_tests[@]} ]}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
llvm_tests[0]="$2"
|
flag=0
|
||||||
|
for id_index in "${!llvm_all_ids[@]}"; do
|
||||||
|
if [[ "${llvm_all_ids[$id_index]}" = "$2" ]]; then
|
||||||
|
flag=1
|
||||||
|
llvm_tests[0]="${llvm_all_tests[$id_index]}"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $flag -eq 0 ]; then
|
||||||
|
test_ids=$(echo "${llvm_all_ids[*]}" | sed 's/ /, /g')
|
||||||
|
echo "Invalid test, valid options: $test_ids, rand, or all"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift 2
|
shift 2
|
||||||
@ -87,7 +102,6 @@ while [ "$1" != "${1##-}" ]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
set -xe #exit on fail
|
set -xe #exit on fail
|
||||||
mkdir -p $fuzzout_dir $fuzzin_dir
|
|
||||||
|
|
||||||
# Optionally build afl fuzz tests
|
# Optionally build afl fuzz tests
|
||||||
if [ $use_afl -ge 0 ]; then
|
if [ $use_afl -ge 0 ]; then
|
||||||
@ -119,6 +133,12 @@ if [ $use_llvm -ge 0 ]; then
|
|||||||
make -f Makefile.unx units=igzip llvm_fuzz_tests igzip_dump_inflate_corpus CC=clang CXX=clang++ ${llvm_link_args}
|
make -f Makefile.unx units=igzip llvm_fuzz_tests igzip_dump_inflate_corpus CC=clang CXX=clang++ ${llvm_link_args}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#Create fuzz input/output directories
|
||||||
|
mkdir -p $fuzzin_dir
|
||||||
|
if [ $use_afl -ge 0 ]; then
|
||||||
|
mkdir -p $fuzzout_dir
|
||||||
|
fi
|
||||||
|
|
||||||
# Optionally fill fuzz input with internal tests corpus
|
# Optionally fill fuzz input with internal tests corpus
|
||||||
[ $use_internal_corp -gt 0 ] && ./igzip_dump_inflate_corpus $fuzzin_dir
|
[ $use_internal_corp -gt 0 ] && ./igzip_dump_inflate_corpus $fuzzin_dir
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user