Spdk/test/nvmf/target/llvm_nvme_fuzz.sh
Jun Wen 59a0d2c60d test/nvmf: Add llvm-nvmf-fuzz test
Add flag "SPDK_TEST_FUZZER" to control building of llvm lib using
CC=clang-$clang_complier
CXX=clang++-$clang_complier

config_params with --with-fuzzer=/usr/lib64/clang/$clangV/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a

Signed-off-by: Jun Wen <junx.wen@intel.com>
Change-Id: Icf3dfe13989d083d22be69b964a54830324a657e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11153
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: <qun.wan@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2022-04-01 08:28:15 +00:00

65 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
TIME=10
RUN_ALL=0
for i in "$@"; do
case "$i" in
--time=*)
TIME="${i#*=}"
;;
--all)
RUN_ALL=1
;;
esac
done
function start_llvm_fuzz() {
local fuzzer_type=$1
local corpus_dir
corpus_dir=/tmp/llvm_fuzz$fuzzer_type
mkdir -p $corpus_dir
$rootdir/test/app/fuzz/llvm_nvme_fuzz/llvm_nvme_fuzz -m 0x1 -i 0 -F "$trid" -c $testdir/fuzz_json.conf -t $TIME -D $corpus_dir -Z $fuzzer_type
}
function run_fuzz() {
local startday
local today
local interval=0
local weekloop
# Get the date number, format is like '22078'
# The purpose is when Jenkins schedule one fuzz in Saturday
# We can decide which one fuzz will be run , there are lots of fuzz, but only run one of them in Saturday each time
# and make sure all fuzz will be tested, so use this function. Such run fuzz 0 in 03/26, and run fuzz 1 in 04/02, run fuzz 2 in 04/09 ....
startday=$(date -d '2022-03-19' '+%y%j')
today=$(date '+%y%j')
interval=$(((today - startday) / 7))
weekloop=$((interval / fuzz_num))
if [[ $weekloop -lt 1 ]]; then # The first loop of fuzz
fuzzer_type=$interval
else
fuzzer_type=$((interval % fuzz_num))
fi
start_llvm_fuzz $fuzzer_type
}
testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
fuzzfile=$rootdir/test/app/fuzz/llvm_nvme_fuzz/llvm_nvme_fuzz.c
fuzz_num=$(($(grep -c "fn =" $fuzzfile) - 1))
[[ $fuzz_num -ne 0 ]]
trap 'process_shm --id 0; rm -rf /tmp/llvm_fuzz*; exit 1' SIGINT SIGTERM EXIT
trid="trtype:tcp adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode1 traddr:127.0.0.1 trsvcid:4420"
if [[ $RUN_ALL -eq 1 ]]; then
run_fuzz
else
start_llvm_fuzz $1
fi
rm -rf /tmp/llvm_fuzz*
trap - SIGINT SIGTERM EXIT