1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2019 Intel Corporation 4# All rights reserved. 5# 6testdir=$(readlink -f $(dirname $0)) 7rootdir=$(readlink -f $testdir/../..) 8 9source "$rootdir/test/common/autotest_common.sh" 10 11TEST_TIMEOUT=1200 12 13function prepare_config() { 14 local allowed_transports 15 local test_module=$1 16 17 config_params=("--enable-asan" "--enable-ubsan" "--enable-debug") 18 19 case "$test_module" in 20 nvmf) 21 allowed_transports=("rdma" "tcp") 22 ;; 23 vhost) 24 allowed_transports=("scsi" "blk" "all") 25 config_params+=("--with-vhost") 26 config_params+=("--with-virtio") 27 ;; 28 iscsi) 29 allowed_transports=("tcp") 30 config_params+=("--with-iscsi-initiator") 31 ;; 32 *) 33 echo "Invalid module specified. Please specify either nvmf, vhost or iscsi." >&2 34 return 1 35 ;; 36 esac 37 38 if ! grep -q "$TEST_TRANSPORT" <(printf '%s\n' "${allowed_transports[@]}"); then 39 echo "Invalid transport. Please supply one of the following for module: $test_module." >&2 40 echo "${allowed_transports[@]}" >&2 41 return 1 42 fi 43 44 if [[ "$TEST_TRANSPORT" == "rdma" ]]; then 45 config_params+=("--with-rdma") 46 fi 47 48 printf '%s\n' "${config_params[@]}" 49} 50 51function run_fuzzer() { 52 local test_module=$1 53 # supply --iso to each test module so that it can run setup.sh. 54 "$testdir/autofuzz_$test_module.sh" --iso "--transport=$TEST_TRANSPORT" "--timeout=$TEST_TIMEOUT" 55} 56 57# These arguments are used in addition to the test arguments in autotest_common.sh 58for i in "$@"; do 59 case "$i" in 60 --module=*) 61 TEST_MODULE="${i#*=}" 62 ;; 63 --timeout=*) 64 TEST_TIMEOUT="${i#*=}" 65 ;; 66 esac 67done 68 69timing_enter autofuzz 70 71config_params=($(prepare_config "$TEST_MODULE")) 72 73timing_enter make 74cd "$rootdir" 75./configure "${config_params[@]}" 76$MAKE $MAKEFLAGS 77timing_exit make 78 79timing_enter fuzz_module 80run_fuzzer "$TEST_MODULE" 81timing_exit fuzz_module 82 83timing_exit autofuzz 84