xref: /spdk/test/fuzz/autofuzz.sh (revision 06b537bfdb4393dea857e204b85d8df46a351d8a)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../..)
5
6source "$rootdir/test/common/autotest_common.sh"
7
8TEST_TIMEOUT=1200
9
10# The term transport is used a bit loosely for vhost tests.
11allowed_nvme_transports=("rdma" "tcp")
12allowed_vhost_transports=("scsi" "blk" "all")
13bad_transport=true
14config_params="--enable-asan --enable-ubsan --enable-debug --without-isal"
15
16# These arguments are used in addition to the test arguments in autotest_common.sh
17for i in "$@"; do
18	case "$i" in
19		--module=*)
20			TEST_MODULE="${i#*=}"
21			;;
22		--timeout=*)
23			TEST_TIMEOUT="${i#*=}"
24			;;
25	esac
26done
27
28timing_enter autofuzz
29if [ "$TEST_MODULE" == "nvmf" ]; then
30	allowed_transports=("${allowed_nvme_transports[@]}")
31	if [ $TEST_TRANSPORT == "rdma" ]; then
32		config_params="$config_params --with-rdma"
33	fi
34elif [ "$TEST_MODULE" == "vhost" ]; then
35	allowed_transports=("${allowed_vhost_transports[@]}")
36	config_params="$config_params --with-vhost --with-virtio"
37else
38	echo "Invalid module specified. Please specify either nvmf or vhost."
39	exit 1
40fi
41
42for transport in "${allowed_transports[@]}"; do
43	if [ $transport == "$TEST_TRANSPORT" ]; then
44		bad_transport=false
45	fi
46done
47
48if $bad_transport; then
49	echo "invalid transport. Please supply one of the following for module: $TEST_MODULE."
50	echo "${allowed_transports[@]}"
51	exit 1
52fi
53
54timing_enter make
55cd $rootdir
56./configure $config_params
57$MAKE $MAKEFLAGS
58timing_exit make
59
60# supply --iso to each test module so that it can run setup.sh.
61timing_enter fuzz_module
62if [ "$TEST_MODULE" == "nvmf" ]; then
63	sudo $testdir/autofuzz_nvmf.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
64fi
65
66if [ "$TEST_MODULE" == "vhost" ]; then
67	sudo $testdir/autofuzz_vhost.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
68fi
69
70if [ "$TEST_MODULE" == "iscsi" ]; then
71	sudo $testdir/autofuzz_iscsi.sh --iso --transport=$TEST_TRANSPORT --timeout=$TEST_TIMEOUT
72fi
73timing_exit fuzz_module
74timing_exit autofuzz
75