llvm_nvme_fuzz: enable running llvm nvmf test in parallel

Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
Change-Id: Iad129c1bc62116a93701a5f68c78351f01a4c878
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16249
Reviewed-by: Michal Berger <michal.berger@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Sebastian Brzezinka 2023-01-11 12:28:01 +01:00 committed by Ben Walker
parent 4f7ab50650
commit 1fa3b4f72d
2 changed files with 33 additions and 44 deletions

View File

@ -53,15 +53,6 @@
{ {
"subsystem": "nvmf", "subsystem": "nvmf",
"config": [ "config": [
{
"method": "nvmf_set_config",
"params": {
"poll_groups_mask": "0x1",
"admin_cmd_passthru": {
"identify_ctrlr": false
}
}
},
{ {
"method": "nvmf_create_transport", "method": "nvmf_create_transport",
"params": { "params": {

View File

@ -3,6 +3,8 @@
# Copyright (C) 2021 Intel Corporation # Copyright (C) 2021 Intel Corporation
# All rights reserved. # All rights reserved.
# #
FUZZER=nvmf
if [[ $SPDK_TEST_FUZZER_SHORT -eq 0 ]]; then if [[ $SPDK_TEST_FUZZER_SHORT -eq 0 ]]; then
TIME=60000 TIME=60000
else else
@ -19,54 +21,50 @@ done
function start_llvm_fuzz() { function start_llvm_fuzz() {
local fuzzer_type=$1 local fuzzer_type=$1
local corpus_dir local timen=$2
corpus_dir=/tmp/llvm_fuzz$fuzzer_type local core=$3
mkdir -p $corpus_dir local corpus_dir=$rootdir/../corpus/llvm_nvmf_$fuzzer_type
$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 local nvmf_cfg=/tmp/fuzz_json_$fuzzer_type.conf
}
function run_fuzz() { port="44$(printf "%02d" $fuzzer_type)"
local startday mkdir -p $corpus_dir
local today
local interval=0 trid="trtype:tcp adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode1 traddr:127.0.0.1 trsvcid:$port"
local weekloop sed -e "s/\"trsvcid\": \"4420\"/\"trsvcid\": \"$port\"/" $testdir/fuzz_json.conf > $nvmf_cfg
# Get the date number, format is like '22078'
# The purpose is when Jenkins schedule one fuzz in Saturday $rootdir/test/app/fuzz/llvm_nvme_fuzz/llvm_nvme_fuzz \
# We can decide which one fuzz will be run , there are lots of fuzz, but only run one of them in Saturday each time -m $core \
# 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 .... -s $mem_size \
startday=$(date -d '2022-03-19' '+%y%j') -F "$trid" \
today=$(date '+%y%j') -c $nvmf_cfg \
interval=$(((today - startday) / 7)) -t $timen \
weekloop=$((interval / fuzz_num)) -D $corpus_dir \
if [[ $weekloop -lt 1 ]]; then # The first loop of fuzz -Z $fuzzer_type \
fuzzer_type=$interval -r /var/tmp/spdk$fuzzer_type.sock
else
fuzzer_type=$((interval % fuzz_num)) rm -rf $nvmf_cfg
fi
start_llvm_fuzz $fuzzer_type &> $output_dir/fuzzer_${fuzzer_type}.log
} }
testdir=$(readlink -f $(dirname $0)) testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../../../../) rootdir=$(readlink -f $testdir/../../../../)
source $rootdir/test/common/autotest_common.sh source $rootdir/test/common/autotest_common.sh
source $rootdir/test/setup/common.sh
source $testdir/../common.sh
fuzzfile=$rootdir/test/app/fuzz/llvm_nvme_fuzz/llvm_nvme_fuzz.c fuzzfile=$rootdir/test/app/fuzz/llvm_nvme_fuzz/llvm_nvme_fuzz.c
fuzz_num=$(($(grep -c "fn =" $fuzzfile) - 1)) fuzz_num=$(($(grep -c "\.fn =" $fuzzfile) - 1))
[[ $fuzz_num -ne 0 ]] ((fuzz_num != 0))
trap 'process_shm --id 0; rm -rf /tmp/llvm_fuzz*; exit 1' SIGINT SIGTERM EXIT trap 'cleanup /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"
mem_size=512
if [[ $SPDK_TEST_FUZZER_SHORT -eq 1 ]]; then if [[ $SPDK_TEST_FUZZER_SHORT -eq 1 ]]; then
for ((i = 0; i < fuzz_num; i++)); do start_llvm_fuzz_short $fuzz_num $TIME
start_llvm_fuzz $i
done
elif [[ $SPDK_TEST_FUZZER -eq 1 ]]; then elif [[ $SPDK_TEST_FUZZER -eq 1 ]]; then
run_fuzz get_testn $fuzz_num $mem_size
start_llvm_fuzz_all $TESTN $fuzz_num $TIME
else else
start_llvm_fuzz $1 start_llvm_fuzz $1 $TIME 0x1
fi fi
rm -rf /tmp/llvm_fuzz*
trap - SIGINT SIGTERM EXIT trap - SIGINT SIGTERM EXIT