xref: /spdk/test/fuzz/autofuzz_vhost.sh (revision 79c52a64269385b9a8b53c2fe03e2343160d38b3)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2019 Intel Corporation
4#  All rights reserved.
5#
6rootdir=$(readlink -f $(dirname $0))/../..
7source $rootdir/test/common/autotest_common.sh
8source "$rootdir/scripts/common.sh"
9
10TEST_TIMEOUT=1200
11
12VHOST_APP+=(-p 0)
13FUZZ_RPC_SOCK="/var/tmp/spdk_fuzz.sock"
14VHOST_FUZZ_APP+=(-r "$FUZZ_RPC_SOCK" -g -s 256 -m 0x2 --wait-for-rpc)
15
16vhost_rpc_py="$rootdir/scripts/rpc.py"
17fuzz_generic_rpc_py="$rootdir/scripts/rpc.py -s $FUZZ_RPC_SOCK"
18fuzz_specific_rpc_py="$rootdir/test/app/fuzz/common/fuzz_rpc.py -s $FUZZ_RPC_SOCK"
19
20# This argument is used in addition to the test arguments in autotest_common.sh
21for i in "$@"; do
22	case "$i" in
23		--timeout=*)
24			TEST_TIMEOUT="${i#*=}"
25			;;
26	esac
27done
28
29timing_enter vhost_fuzz_test
30
31#todo refactor this to use the vhosttestinit function when it becomes available.
32timing_enter setup
33$rootdir/scripts/setup.sh
34timing_exit setup
35
36"${VHOST_APP[@]}" &> "$output_dir/vhost_fuzz_tgt_output.txt" &
37vhostpid=$!
38waitforlisten $vhostpid
39
40trap 'killprocess $vhostpid; exit 1' SIGINT SIGTERM exit
41
42"${VHOST_FUZZ_APP[@]}" -t $TEST_TIMEOUT 2> "$output_dir/vhost_autofuzz_output1.txt" &
43fuzzpid=$!
44waitforlisten $fuzzpid $FUZZ_RPC_SOCK
45
46trap 'killprocess $vhostpid; killprocess $fuzzpid; exit 1' SIGINT SIGTERM exit
47
48if [ "$TEST_TRANSPORT" == "bdev" ] || [ "$TEST_TRANSPORT" == "all" ]; then
49	$vhost_rpc_py bdev_malloc_create -b Malloc0 64 512
50	$vhost_rpc_py vhost_create_blk_controller Vhost.1 Malloc0
51
52	# test the vhost blk controller with valid data buffers.
53	$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v
54fi
55
56if [ "$TEST_TRANSPORT" == "scsi" ] || [ "$TEST_TRANSPORT" == "all" ]; then
57	$vhost_rpc_py bdev_malloc_create -b Malloc1 64 512
58	$vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.1
59	$vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.1 0 Malloc1
60
61	$vhost_rpc_py bdev_malloc_create -b Malloc2 64 512
62	$vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.2
63	$vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.2 0 Malloc2
64
65	# test the vhost scsi I/O queue with valid data buffers on a valid lun.
66	$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v
67	# test the vhost scsi management queue with valid data buffers.
68	$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m
69fi
70
71# The test won't actually begin until this option is passed in.
72$fuzz_generic_rpc_py framework_start_init
73
74wait $fuzzpid
75
76trap - SIGINT SIGTERM exit
77killprocess $vhostpid
78timing_exit vhost_fuzz_test
79