From 5303e1bd541323b975ff514a152df25b6592bdd3 Mon Sep 17 00:00:00 2001 From: Sebastian Brzezinka Date: Fri, 21 Oct 2022 11:48:37 +0200 Subject: [PATCH] llvm_vfio_fuzz: keep corpus files Keep corpus directory that trigers new code coverage. Signed-off-by: Sebastian Brzezinka Change-Id: I2a5154472588669fddd87c97cc952da1a92ae0ee Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15105 Tested-by: SPDK CI Jenkins Reviewed-by: Michal Berger Reviewed-by: Jim Harris Reviewed-by: Tomasz Zawadzki --- test/fuzz/llvm.sh | 2 ++ test/fuzz/llvm/vfio/run.sh | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/test/fuzz/llvm.sh b/test/fuzz/llvm.sh index 4095ee051..48e4958e0 100755 --- a/test/fuzz/llvm.sh +++ b/test/fuzz/llvm.sh @@ -10,6 +10,8 @@ source "$rootdir/test/common/autotest_common.sh" fuzzers=($(get_fuzzer_targets)) +mkdir -p $rootdir/../corpus/ + for fuzzer in "${fuzzers[@]}"; do case "$fuzzer" in nvmf) run_test "nvmf_fuzz" "$testdir/llvm/$fuzzer/run.sh" ;; diff --git a/test/fuzz/llvm/vfio/run.sh b/test/fuzz/llvm/vfio/run.sh index e7fdf7dd1..05f67e729 100755 --- a/test/fuzz/llvm/vfio/run.sh +++ b/test/fuzz/llvm/vfio/run.sh @@ -25,9 +25,18 @@ mkdir -p $VFIOUSER_IO_DIR function start_llvm_fuzz() { local fuzzer_type=$1 local corpus_dir - corpus_dir=/tmp/llvm_fuzz$fuzzer_type + + corpus_dir=$rootdir/../corpus/llvm_vfio_$fuzzer_type mkdir -p $corpus_dir - $rootdir/test/app/fuzz/llvm_vfio_fuzz/llvm_vfio_fuzz -m 0x1 -i 0 -F $VFIOUSER_DIR -c $testdir/fuzz_vfio_json.conf -t $TIME -D $corpus_dir -Y $VFIOUSER_IO_DIR -Z $fuzzer_type + + $rootdir/test/app/fuzz/llvm_vfio_fuzz/llvm_vfio_fuzz -m 0x1 \ + -i 0 \ + -F $VFIOUSER_DIR \ + -c $testdir/fuzz_vfio_json.conf \ + -t $TIME \ + -D $corpus_dir \ + -Y $VFIOUSER_IO_DIR \ + -Z $fuzzer_type } function run_fuzz() { @@ -59,7 +68,7 @@ fuzzfile=$rootdir/test/app/fuzz/llvm_vfio_fuzz/llvm_vfio_fuzz.c fuzz_num=$(($(grep -c "fn =" $fuzzfile) - 1)) [[ $fuzz_num -ne 0 ]] -trap 'process_shm --id 0; rm -rf /tmp/llvm_fuzz* $VFIOUSER_DIR $VFIOUSER_IO_DIR; exit 1' SIGINT SIGTERM EXIT +trap 'process_shm --id 0; rm -rf $VFIOUSER_DIR $VFIOUSER_IO_DIR; exit 1' SIGINT SIGTERM EXIT if [[ $SPDK_TEST_FUZZER_SHORT -eq 1 ]]; then for ((i = 0; i < fuzz_num; i++)); do @@ -71,5 +80,5 @@ else start_llvm_fuzz $1 fi -rm -rf /tmp/llvm_fuzz* $VFIOUSER_DIR $VFIOUSER_IO_DIR +rm -rf $VFIOUSER_DIR $VFIOUSER_IO_DIR trap - SIGINT SIGTERM EXIT