xref: /spdk/test/vhost/fuzz/fuzz.sh (revision eb53c23236cccb6b698b7ca70ee783da1c574b5f)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2019 Intel Corporation
4#  All rights reserved.
5#
6set -e
7
8rootdir=$(readlink -f $(dirname $0))/../../..
9source $rootdir/test/common/autotest_common.sh
10source "$rootdir/scripts/common.sh"
11
12# This test fails, if second VHOST_FUZZ_APP call is run on
13# a different core than VHOST_APP. This problem has been
14# explained in GitHub issue #2732.
15VHOST_APP+=(-p 0 --disable-cpumask-locks)
16FUZZ_RPC_SOCK="/var/tmp/spdk_fuzz.sock"
17VHOST_FUZZ_APP+=(-r "$FUZZ_RPC_SOCK" -g -s 256 --wait-for-rpc)
18
19vhost_rpc_py="$rootdir/scripts/rpc.py"
20fuzz_generic_rpc_py="$rootdir/scripts/rpc.py -s $FUZZ_RPC_SOCK"
21fuzz_specific_rpc_py="$rootdir/test/app/fuzz/common/fuzz_rpc.py -s $FUZZ_RPC_SOCK"
22
23"${VHOST_APP[@]}" > "$output_dir/vhost_fuzz_tgt_output.txt" 2>&1 &
24vhostpid=$!
25waitforlisten $vhostpid
26
27trap 'killprocess $vhostpid; exit 1' SIGINT SIGTERM exit
28
29"${VHOST_FUZZ_APP[@]}" -t 10 2> "$output_dir/vhost_fuzz_output1.txt" &
30fuzzpid=$!
31waitforlisten $fuzzpid $FUZZ_RPC_SOCK
32
33trap 'killprocess $vhostpid; killprocess $fuzzpid; exit 1' SIGINT SIGTERM exit
34
35$vhost_rpc_py bdev_malloc_create -b Malloc0 64 512
36$vhost_rpc_py vhost_create_blk_controller Vhost.1 Malloc0
37
38$vhost_rpc_py bdev_malloc_create -b Malloc1 64 512
39$vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.1
40$vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.1 0 Malloc1
41
42$vhost_rpc_py bdev_malloc_create -b Malloc2 64 512
43$vhost_rpc_py vhost_create_scsi_controller naa.VhostScsi0.2
44$vhost_rpc_py vhost_scsi_controller_add_target naa.VhostScsi0.2 0 Malloc2
45
46# test the vhost blk controller with valid data buffers.
47$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v
48# test the vhost scsi I/O queue with valid data buffers on a valid lun.
49$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v
50# test the vhost scsi management queue with valid data buffers.
51$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m
52# The test won't actually begin until this option is passed in.
53$fuzz_generic_rpc_py framework_start_init
54
55wait $fuzzpid
56
57"${VHOST_FUZZ_APP[@]}" -j "$rootdir/test/app/fuzz/vhost_fuzz/example.json" 2> "$output_dir/vhost_fuzz_output2.txt" &
58fuzzpid=$!
59waitforlisten $fuzzpid $FUZZ_RPC_SOCK
60
61# re-evaluate fuzzpid
62trap 'killprocess $vhostpid; killprocess $fuzzpid; exit 1' SIGINT SIGTERM exit
63
64$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/Vhost.1 -b -v
65$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.1 -l -v
66$fuzz_specific_rpc_py fuzz_vhost_create_dev -s $(pwd)/naa.VhostScsi0.2 -v -m
67$fuzz_generic_rpc_py framework_start_init
68
69wait $fuzzpid
70
71trap - SIGINT SIGTERM exit
72
73killprocess $vhostpid
74