diff --git a/test/vhost/fiotest/common.sh b/test/vhost/fiotest/common.sh index 50cd20e22..cd0d53873 100644 --- a/test/vhost/fiotest/common.sh +++ b/test/vhost/fiotest/common.sh @@ -11,6 +11,7 @@ TEST_DIR="$(mkdir -p $TEST_DIR && cd $TEST_DIR && echo $PWD)" SPDK_SRC_DIR=$TEST_DIR/spdk SPDK_BUILD_DIR=$BASE_DIR/../../../ +VHOST_APP=$SPDK_BUILD_DIR/app/vhost/vhost SPDK_VHOST_SCSI_TEST_DIR=$TEST_DIR/vhost @@ -124,7 +125,6 @@ function spdk_build_and_install() function spdk_vhost_run() { - local vhost_app="$SPDK_BUILD_DIR/app/vhost/vhost" local vhost_log_file="$SPDK_VHOST_SCSI_TEST_DIR/vhost.log" local vhost_pid_file="$SPDK_VHOST_SCSI_TEST_DIR/vhost.pid" local vhost_socket="$SPDK_VHOST_SCSI_TEST_DIR/usvhost" @@ -135,8 +135,8 @@ function spdk_vhost_run() [[ -d $SPDK_VHOST_SCSI_TEST_DIR ]] && rm -f $SPDK_VHOST_SCSI_TEST_DIR/* mkdir -p $SPDK_VHOST_SCSI_TEST_DIR - if [[ ! -x $vhost_app ]]; then - error "application not found: $vhost_app" + if [[ ! -x $VHOST_APP ]]; then + error "application not found: $VHOST_APP" return 1 fi @@ -148,7 +148,7 @@ function spdk_vhost_run() cp $vhost_conf_template $vhost_conf_file $BASE_DIR/../../../scripts/gen_nvme.sh >> $vhost_conf_file - local cmd="$vhost_app -m $vhost_reactor_mask -p $vhost_master_core -c $vhost_conf_file" + local cmd="$VHOST_APP -m $vhost_reactor_mask -p $vhost_master_core -c $vhost_conf_file" echo "INFO: Loging to: $vhost_log_file" echo "INFO: Config file: $vhost_conf_file" diff --git a/test/vhost/fiotest/run_vhost.sh b/test/vhost/fiotest/run_vhost.sh index 2964b539f..36b489404 100755 --- a/test/vhost/fiotest/run_vhost.sh +++ b/test/vhost/fiotest/run_vhost.sh @@ -46,4 +46,26 @@ echo . $BASE_DIR/common.sh +echo "INFO: Testing vhost command line arguments" +# Printing help will force vhost to exit without error +$VHOST_APP -c /path/to/non_existing_file/conf -S $BASE_DIR -e 0x0 -s 1024 -d -q -h + +# Testing vhost create pid file option. Vhost will exit with error as invalid config path is given +if $VHOST_APP -c /path/to/non_existing_file/conf -f $SPDK_VHOST_SCSI_TEST_DIR/vhost.pid; then + echo "vhost started when specifying invalid config file" + exit 1 +fi + +# Expecting vhost to fail if an incorrect argument is given +if $VHOST_APP -x -h; then + echo "vhost started with invalid -x command line option" + exit 1 +fi + +# Passing trace flags if spdk is build without CONFIG_DEBUG=y option make vhost exit with error +if ! $VHOST_APP -t vhost_scsi -h; then + echo "vhost did not started with trace flags enabled but ignoring this as it might not be a debug build" +fi + +# Starting vhost with valid options spdk_vhost_run