summaryrefslogtreecommitdiffstats
path: root/src/spdk/test/fuzz
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/test/fuzz
parentInitial commit. (diff)
downloadceph-b26c4052f3542036551aa9dec9caa4226e456195.tar.xz
ceph-b26c4052f3542036551aa9dec9caa4226e456195.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/test/fuzz')
-rwxr-xr-xsrc/spdk/test/fuzz/autofuzz.sh74
-rwxr-xr-xsrc/spdk/test/fuzz/autofuzz_iscsi.sh75
-rwxr-xr-xsrc/spdk/test/fuzz/autofuzz_nvmf.sh52
-rwxr-xr-xsrc/spdk/test/fuzz/autofuzz_vhost.sh75
4 files changed, 276 insertions, 0 deletions
diff --git a/src/spdk/test/fuzz/autofuzz.sh b/src/spdk/test/fuzz/autofuzz.sh
new file mode 100755
index 000000000..92766bb06
--- /dev/null
+++ b/src/spdk/test/fuzz/autofuzz.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../..)
+
+source "$rootdir/test/common/autotest_common.sh"
+
+TEST_TIMEOUT=1200
+
+# The term transport is used a bit loosely for vhost tests.
+allowed_nvme_transports=("rdma" "tcp")
+allowed_vhost_transports=("scsi" "blk" "all")
+bad_transport=true
+config_params="--enable-asan --enable-ubsan --enable-debug --without-isal"
+
+# These arguments are used in addition to the test arguments in autotest_common.sh
+for i in "$@"; do
+ case "$i" in
+ --module=*)
+ TEST_MODULE="${i#*=}"
+ ;;
+ --timeout=*)
+ TEST_TIMEOUT="${i#*=}"
+ ;;
+ esac
+done
+
+timing_enter autofuzz
+if [ "$TEST_MODULE" == "nvmf" ]; then
+ allowed_transports=("${allowed_nvme_transports[@]}")
+ if [ $TEST_TRANSPORT == "rdma" ]; then
+ config_params="$config_params --with-rdma"
+ fi
+elif [ "$TEST_MODULE" == "vhost" ]; then
+ allowed_transports=("${allowed_vhost_transports[@]}")
+ config_params="$config_params --with-vhost --with-virtio"
+else
+ echo "Invalid module specified. Please specify either nvmf or vhost."
+ exit 1
+fi
+
+for transport in "${allowed_transports[@]}"; do
+ if [ $transport == "$TEST_TRANSPORT" ]; then
+ bad_transport=false
+ fi
+done
+
+if $bad_transport; then
+ echo "invalid transport. Please supply one of the following for module: $TEST_MODULE."
+ echo "${allowed_transports[@]}"
+ exit 1
+fi
+
+timing_enter make
+cd $rootdir
+./configure $config_params
+$MAKE $MAKEFLAGS
+timing_exit make
+
+# supply --iso to each test module so that it can run setup.sh.
+timing_enter fuzz_module
+if [ "$TEST_MODULE" == "nvmf" ]; then
+ sudo $testdir/autofuzz_nvmf.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
+fi
+
+if [ "$TEST_MODULE" == "vhost" ]; then
+ sudo $testdir/autofuzz_vhost.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
+fi
+
+if [ "$TEST_MODULE" == "iscsi" ]; then
+ sudo $testdir/autofuzz_iscsi.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
+fi
+timing_exit fuzz_module
+timing_exit autofuzz
diff --git a/src/spdk/test/fuzz/autofuzz_iscsi.sh b/src/spdk/test/fuzz/autofuzz_iscsi.sh
new file mode 100755
index 000000000..8793e8bf1
--- /dev/null
+++ b/src/spdk/test/fuzz/autofuzz_iscsi.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../..)
+source $rootdir/test/common/autotest_common.sh
+source $rootdir/test/iscsi_tgt/common.sh
+
+# $1 = "iso" - triggers isolation mode (setting up required environment).
+# $2 = test type posix or vpp. defaults to posix.
+iscsitestinit $1 $2
+
+if [ -z "$TARGET_IP" ]; then
+ echo "TARGET_IP not defined in environment"
+ exit 1
+fi
+
+if [ -z "$INITIATOR_IP" ]; then
+ echo "INITIATOR_IP not defined in environment"
+ exit 1
+fi
+
+timing_enter iscsi_fuzz_test
+
+MALLOC_BDEV_SIZE=64
+MALLOC_BLOCK_SIZE=4096
+
+rpc_py="$rootdir/scripts/rpc.py"
+
+TEST_TIMEOUT=1200
+
+# This argument is used in addition to the test arguments in autotest_common.sh
+for i in "$@"; do
+ case "$i" in
+ --timeout=*)
+ TEST_TIMEOUT="${i#*=}"
+ ;;
+ esac
+done
+
+timing_enter start_iscsi_tgt
+
+"${ISCSI_APP[@]}" -m $ISCSI_TEST_CORE_MASK &> $output_dir/iscsi_autofuzz_tgt_output.txt &
+iscsipid=$!
+
+trap 'killprocess $iscsipid; exit 1' SIGINT SIGTERM EXIT
+
+waitforlisten $iscsipid
+# Fuzz initiator do not support nop-in yet. So we increase nop-in timeout value for now.
+$rpc_py iscsi_set_options -o 60 -a 16
+$rpc_py framework_start_init
+echo "iscsi_tgt is listening. Running tests..."
+timing_exit start_iscsi_tgt
+
+$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
+$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
+$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE
+$rpc_py iscsi_create_target_node disk1 disk1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 256 -d
+sleep 1
+
+trap 'killprocess $iscsipid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
+
+$rootdir/test/app/fuzz/iscsi_fuzz/iscsi_fuzz -m 0xF0 -T $TARGET_IP -t $TEST_TIMEOUT 2> $output_dir/iscsi_autofuzz_logs.txt
+
+$rpc_py iscsi_delete_target_node 'iqn.2016-06.io.spdk:disk1'
+
+# Delete malloc device
+$rpc_py bdev_malloc_delete Malloc0
+
+trap - SIGINT SIGTERM EXIT
+
+killprocess $iscsipid
+
+iscsitestfini $1 $2
+
+timing_exit iscsi_fuzz_test
diff --git a/src/spdk/test/fuzz/autofuzz_nvmf.sh b/src/spdk/test/fuzz/autofuzz_nvmf.sh
new file mode 100755
index 000000000..6fc36e23b
--- /dev/null
+++ b/src/spdk/test/fuzz/autofuzz_nvmf.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+testdir=$(readlink -f $(dirname $0))
+rootdir=$(readlink -f $testdir/../..)
+source $rootdir/test/common/autotest_common.sh
+source $rootdir/test/nvmf/common.sh
+
+rpc_py="$rootdir/scripts/rpc.py"
+
+TEST_TIMEOUT=1200
+
+# This argument is used in addition to the test arguments in autotest_common.sh
+for i in "$@"; do
+ case "$i" in
+ --timeout=*)
+ TEST_TIMEOUT="${i#*=}"
+ ;;
+ esac
+done
+
+nvmftestinit
+
+timing_enter nvmf_fuzz_test
+
+echo "[Nvme]" > $testdir/nvmf_fuzz.conf
+echo " TransportID \"trtype:$TEST_TRANSPORT adrfam:IPv4 subnqn:nqn.2016-06.io.spdk:cnode1 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT\" Nvme0" >> $testdir/nvmf_fuzz.conf
+
+"${NVMF_APP[@]}" -m 0xF &> "$output_dir/nvmf_autofuzz_tgt_output.txt" &
+nvmfpid=$!
+
+trap 'process_shm --id $NVMF_APP_SHM_ID; rm -f $testdir/nvmf_fuzz.conf; killprocess $nvmfpid; nvmftestfini $1; exit 1' SIGINT SIGTERM EXIT
+
+waitforlisten $nvmfpid
+$rpc_py nvmf_create_transport -t $TEST_TRANSPORT -u 8192
+
+$rpc_py bdev_malloc_create -b Malloc0 64 512
+
+$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
+$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Malloc0
+$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
+
+# Note that we chose a consistent seed to ensure that this test is consistent in nightly builds.
+$rootdir/test/app/fuzz/nvme_fuzz/nvme_fuzz -m 0xF0 -r "/var/tmp/nvme_fuzz" -t $TEST_TIMEOUT -C $testdir/nvmf_fuzz.conf -N -a 2> $output_dir/nvmf_autofuzz_logs.txt
+
+rm -f $testdir/nvmf_fuzz.conf
+$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1
+
+trap - SIGINT SIGTERM EXIT
+
+nvmfcleanup
+nvmftestfini
+timing_exit nvmf_fuzz_test
diff --git a/src/spdk/test/fuzz/autofuzz_vhost.sh b/src/spdk/test/fuzz/autofuzz_vhost.sh
new file mode 100755
index 000000000..4b040ba82
--- /dev/null
+++ b/src/spdk/test/fuzz/autofuzz_vhost.sh
@@ -0,0 +1,75 @@
+#!/usr/bin/env bash
+
+rootdir=$(readlink -f $(dirname $0))/../..
+source $rootdir/test/common/autotest_common.sh
+source "$rootdir/scripts/common.sh"
+
+TEST_TIMEOUT=1200
+
+VHOST_APP+=(-p 0)
+FUZZ_RPC_SOCK="/var/tmp/spdk_fuzz.sock"
+VHOST_FUZZ_APP+=(-r "$FUZZ_RPC_SOCK" --wait-for-rpc)
+
+vhost_rpc_py="$rootdir/scripts/rpc.py"
+fuzz_generic_rpc_py="$rootdir/scripts/rpc.py -s $FUZZ_RPC_SOCK"
+fuzz_specific_rpc_py="$rootdir/test/app/fuzz/common/fuzz_rpc.py -s $FUZZ_RPC_SOCK"
+
+# This argument is used in addition to the test arguments in autotest_common.sh
+for i in "$@"; do
+ case "$i" in
+ --timeout=*)
+ TEST_TIMEOUT="${i#*=}"
+ ;;
+ esac
+done
+
+timing_enter vhost_fuzz_test
+
+#todo refactor this to use the vhosttestinit function when it becomes available.
+timing_enter setup
+$rootdir/scripts/setup.sh
+timing_exit setup
+
+"${VHOST_APP[@]}" &> "$output_dir/vhost_fuzz_tgt_output.txt" &
+vhostpid=$!
+waitforlisten $vhostpid
+
+trap 'killprocess $vhostpid; exit 1' SIGINT SIGTERM exit
+
+"${VHOST_FUZZ_APP[@]}" -t $TEST_TIMEOUT 2> "$output_dir/vhost_autofuzz_output1.txt" &
+fuzzpid=$!
+waitforlisten $fuzzpid $FUZZ_RPC_SOCK
+
+trap 'killprocess $vhostpid; killprocess $fuzzpid; exit 1' SIGINT SIGTERM exit
+
+if [ "$TEST_TRANSPORT" == "bdev" ] || [ "$TEST_TRANSPORT" == "all" ]; then
+ $vhost_rpc_py bdev_malloc_create -b Malloc0 64 512
+ $vhost_rpc_py vhost_create_blk_controller Vhost.1 Malloc0
+
+ # test the vhost blk controller with valid data buffers.
+ $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v
+fi
+
+if [ "$TEST_TRANSPORT" == "scsi" ] || [ "$TEST_TRANSPORT" == "all" ]; then
+ $vhost_rpc_py bdev_malloc_create -b Malloc1 64 512
+ $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.1
+ $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.1 0 Malloc1
+
+ $vhost_rpc_py bdev_malloc_create -b Malloc2 64 512
+ $vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.2
+ $vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.2 0 Malloc2
+
+ # test the vhost scsi I/O queue with valid data buffers on a valid lun.
+ $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v
+ # test the vhost scsi management queue with valid data buffers.
+ $fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m
+fi
+
+# The test won't actually begin until this option is passed in.
+$fuzz_generic_rpc_py framework_start_init
+
+wait $fuzzpid
+
+trap - SIGINT SIGTERM exit
+killprocess $vhostpid
+timing_exit vhost_fuzz_test