diff --git a/test/vhost/common/common.sh b/test/vhost/common/common.sh index 4b50cd64c..fc3e42d74 100644 --- a/test/vhost/common/common.sh +++ b/test/vhost/common/common.sh @@ -3,7 +3,7 @@ set -e : ${SPDK_VHOST_VERBOSE=false} : ${QEMU_PREFIX="/usr/local/qemu/spdk-2.12-pre"} -BASE_DIR=$(readlink -f $(dirname $0)) +BASE_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]})) # Default running dir -> spdk/.. [[ -z "$TEST_DIR" ]] && TEST_DIR=$BASE_DIR/../../../../ diff --git a/test/vhost/fiotest/autotest.sh b/test/vhost/fiotest/autotest.sh index 7bff0103b..22f7ea664 100755 --- a/test/vhost/fiotest/autotest.sh +++ b/test/vhost/fiotest/autotest.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -e -BASE_DIR=$(readlink -f $(dirname $0)) -[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)" -[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../../../ && pwd)" +AUTOTEST_BASE_DIR=$(readlink -f $(dirname $0)) +[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $AUTOTEST_BASE_DIR/../common && pwd)" +[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $AUTOTEST_BASE_DIR/../../../../ && pwd)" dry_run=false no_shutdown=false @@ -82,7 +82,7 @@ if [[ $test_type =~ "spdk_vhost" ]]; then notice "" notice "running SPDK" notice "" - spdk_vhost_run --conf-path=$BASE_DIR + spdk_vhost_run --conf-path=$AUTOTEST_BASE_DIR notice "" fi diff --git a/test/vhost/initiator/blockdev.sh b/test/vhost/initiator/blockdev.sh index c3108ec97..500764b21 100755 --- a/test/vhost/initiator/blockdev.sh +++ b/test/vhost/initiator/blockdev.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -e -BASE_DIR=$(readlink -f $(dirname $0)) -[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)" -ROOT_DIR=$(readlink -f $BASE_DIR/../../..) +INITIATOR_DIR=$(readlink -f $(dirname $0)) +[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $INITIATOR_DIR/../common && pwd)" +ROOT_DIR=$(readlink -f $INITIATOR_DIR/../../..) function usage() { @@ -31,7 +31,7 @@ while getopts 'h-:' optchar; do done source $COMMON_DIR/common.sh -source $BASE_DIR/autotest.config +source $INITIATOR_DIR/autotest.config PLUGIN_DIR=$ROOT_DIR/examples/bdev/fio_plugin RPC_PY="$ROOT_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" FIO_BIN="/usr/src/fio/fio" @@ -79,14 +79,14 @@ function create_bdev_config() $RPC_PY construct_vhost_scsi_controller naa.Malloc1.0 $RPC_PY add_vhost_scsi_lun naa.Malloc1.0 0 Malloc1 - vbdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf) + vbdevs=$(discover_bdevs $ROOT_DIR $INITIATOR_DIR/bdev.conf) virtio_bdevs=$(jq -r '[.[].name] | join(":")' <<< $vbdevs) virtio_with_unmap=$(jq -r '[.[] | select(.supported_io_types.unmap==true).name] | join(":")' <<< $vbdevs) } timing_enter spdk_vhost_run -spdk_vhost_run --conf-path=$BASE_DIR +spdk_vhost_run --conf-path=$INITIATOR_DIR timing_exit spdk_vhost_run timing_enter create_bdev_config @@ -94,14 +94,14 @@ create_bdev_config timing_exit create_bdev_config timing_enter run_spdk_fio -run_spdk_fio $BASE_DIR/bdev.fio --filename=$virtio_bdevs --section=job_randwrite --section=job_randrw \ - --section=job_write --section=job_rw --spdk_conf=$BASE_DIR/bdev.conf +run_spdk_fio $INITIATOR_DIR/bdev.fio --filename=$virtio_bdevs --section=job_randwrite --section=job_randrw \ + --section=job_write --section=job_rw --spdk_conf=$INITIATOR_DIR/bdev.conf report_test_completion "vhost_run_spdk_fio" timing_exit run_spdk_fio timing_enter run_spdk_fio_unmap -run_spdk_fio $BASE_DIR/bdev.fio --filename=$virtio_with_unmap --spdk_conf=$BASE_DIR/bdev.conf \ - --spdk_conf=$BASE_DIR/bdev.conf +run_spdk_fio $INITIATOR_DIR/bdev.fio --filename=$virtio_with_unmap --spdk_conf=$INITIATOR_DIR/bdev.conf \ + --spdk_conf=$INITIATOR_DIR/bdev.conf timing_exit run_spdk_fio_unmap timing_enter setup_vm diff --git a/test/vhost/integrity/integrity_start.sh b/test/vhost/integrity/integrity_start.sh index e6b843493..1908f74b4 100755 --- a/test/vhost/integrity/integrity_start.sh +++ b/test/vhost/integrity/integrity_start.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -e +INTEGRITY_BASE_DIR=$(readlink -f $(dirname $0)) ctrl_type="spdk_vhost_scsi" vm_fs="ext4" @@ -55,7 +56,7 @@ trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR vm_kill_all notice "Starting SPDK vhost" -spdk_vhost_run --conf-path=$BASE_DIR +spdk_vhost_run --conf-path=$INTEGRITY_BASE_DIR notice "..." # Set up lvols and vhost controllers @@ -82,7 +83,7 @@ vm_run 0 vm_wait_for_boot 600 0 # Run tests on VM -vm_scp 0 $BASE_DIR/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh +vm_scp 0 $INTEGRITY_BASE_DIR/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh vm_ssh 0 "~/integrity_vm.sh $ctrl_type \"$vm_fs\"" notice "Shutting down virtual machine..." diff --git a/test/vhost/lvol/lvol_test.sh b/test/vhost/lvol/lvol_test.sh index 9b10a922d..4b67f10ac 100755 --- a/test/vhost/lvol/lvol_test.sh +++ b/test/vhost/lvol/lvol_test.sh @@ -4,9 +4,9 @@ set -e rootdir=$(readlink -f $(dirname $0))/../../.. source "$rootdir/scripts/common.sh" -BASE_DIR=$(readlink -f $(dirname $0)) -[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../../../ && pwd)" -[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)" +LVOL_TEST_DIR=$(readlink -f $(dirname $0)) +[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $LVOL_TEST_DIR/../../../../ && pwd)" +[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $LVOL_TEST_DIR/../common && pwd)" . $COMMON_DIR/common.sh rpc_py="python $SPDK_BUILD_DIR/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" @@ -113,7 +113,7 @@ fi if $distribute_cores; then # FIXME: this need to be handled entirely in common.sh - source $BASE_DIR/autotest.config + source $LVOL_TEST_DIR/autotest.config fi trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR @@ -121,7 +121,7 @@ trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR vm_kill_all notice "running SPDK vhost" -spdk_vhost_run --conf-path=$BASE_DIR +spdk_vhost_run --conf-path=$LVOL_TEST_DIR notice "..." trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR diff --git a/test/vhost/migration/migration-tc1.sh b/test/vhost/migration/migration-tc1.sh index a86301522..4947f2de0 100644 --- a/test/vhost/migration/migration-tc1.sh +++ b/test/vhost/migration/migration-tc1.sh @@ -54,10 +54,10 @@ function migration_tc1() # Use 2 VMs: # incoming VM - the one we want to migrate # targe VM - the one which will accept migration - local job_file="$BASE_DIR/migration-tc1.job" + local job_file="$MIGRATION_DIR/migration-tc1.job" # Run vhost - spdk_vhost_run --conf-path=$BASE_DIR + spdk_vhost_run --conf-path=$MIGRATION_DIR migration_tc1_configure_vhost notice "Setting up VMs" diff --git a/test/vhost/migration/migration-tc2.sh b/test/vhost/migration/migration-tc2.sh index 4840b05dc..04b5dcad0 100644 --- a/test/vhost/migration/migration-tc2.sh +++ b/test/vhost/migration/migration-tc2.sh @@ -101,11 +101,11 @@ function migration_tc2_configure_vhost() waitforlisten "$nvmf_tgt_pid" "$nvmf_dir/rpc.sock" timing_exit start_nvmf_tgt - spdk_vhost_run --conf-path=$BASE_DIR --memory=512 --vhost-num=0 + spdk_vhost_run --conf-path=$MIGRATION_DIR --memory=512 --vhost-num=0 # Those are global intentionaly vhost_1_reactor_mask=0x2 vhost_1_master_core=1 - spdk_vhost_run --conf-path=$BASE_DIR --memory=512 --vhost-num=1 + spdk_vhost_run --conf-path=$MIGRATION_DIR --memory=512 --vhost-num=1 local rdma_ip_list=$(get_available_rdma_ips) local nvmf_target_ip=$(echo "$rdma_ip_list" | head -n 1) @@ -160,7 +160,7 @@ function migration_tc2() # Use 2 VMs: # incoming VM - the one we want to migrate # targe VM - the one which will accept migration - local job_file="$BASE_DIR/migration-tc2.job" + local job_file="$MIGRATION_DIR/migration-tc2.job" migration_tc2_configure_vhost diff --git a/test/vhost/migration/migration-tc3a.sh b/test/vhost/migration/migration-tc3a.sh index 77dc56222..9d5672b2c 100644 --- a/test/vhost/migration/migration-tc3a.sh +++ b/test/vhost/migration/migration-tc3a.sh @@ -1,5 +1,5 @@ source $SPDK_BUILD_DIR/test/nvmf/common.sh -source $BASE_DIR/autotest.config +source $MIGRATION_DIR/autotest.config MGMT_TARGET_IP="10.102.17.181" MGMT_INITIATOR_IP="10.102.17.180" @@ -10,7 +10,7 @@ target_vm=2 incoming_vm_ctrlr=naa.VhostScsi0.$incoming_vm target_vm_ctrlr=naa.VhostScsi0.$target_vm share_dir=$TEST_DIR/share -job_file=$BASE_DIR/migration-tc3.job +job_file=$MIGRATION_DIR/migration-tc3.job function ssh_remote() { @@ -106,7 +106,7 @@ function host1_start_vhost() notice "Starting vhost0 instance on local server" trap 'host1_cleanup_vhost; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT - spdk_vhost_run --conf-path=$BASE_DIR --vhost-num=0 + spdk_vhost_run --conf-path=$MIGRATION_DIR --vhost-num=0 $rpc_0 construct_nvme_bdev -b Nvme0 -t rdma -f ipv4 -a $RDMA_TARGET_IP -s 4420 -n "nqn.2018-02.io.spdk:cnode1" $rpc_0 construct_vhost_scsi_controller $incoming_vm_ctrlr $rpc_0 add_vhost_scsi_lun $incoming_vm_ctrlr 0 Nvme0n1 diff --git a/test/vhost/migration/migration-tc3b.sh b/test/vhost/migration/migration-tc3b.sh index 79e21c541..0cd32ec61 100755 --- a/test/vhost/migration/migration-tc3b.sh +++ b/test/vhost/migration/migration-tc3b.sh @@ -2,7 +2,7 @@ # as we are usin non-interactive session to connect to remote. # Without -m it would be not possible to suspend the process. set -m -source $BASE_DIR/autotest.config +source $MIGRATION_DIR/autotest.config RDMA_TARGET_IP="10.0.0.1" incoming_vm=1 @@ -34,7 +34,7 @@ function host_2_start_vhost() notice "Starting vhost 1 instance on remote server" trap 'host_2_cleanup_vhost; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT - spdk_vhost_run --conf-path=$BASE_DIR --vhost-num=1 + spdk_vhost_run --conf-path=$MIGRATION_DIR --vhost-num=1 $rpc construct_nvme_bdev -b Nvme0 -t rdma -f ipv4 -a $RDMA_TARGET_IP -s 4420 -n "nqn.2018-02.io.spdk:cnode1" $rpc construct_vhost_scsi_controller $target_vm_ctrl diff --git a/test/vhost/migration/migration.sh b/test/vhost/migration/migration.sh index 5fb8cdd00..c3d13e3f3 100755 --- a/test/vhost/migration/migration.sh +++ b/test/vhost/migration/migration.sh @@ -45,6 +45,7 @@ for param in "$@"; do done . $(readlink -e "$(dirname $0)/../common/common.sh") || exit 1 +MIGRATION_DIR=$(readlink -f $(dirname $0)) [[ ! -z "$test_cases" ]] || fail "Need '--test-cases=' parameter" @@ -131,7 +132,7 @@ for test_case in ${test_cases//,/ }; do notice "===============================" timing_enter migration-tc${test_case} - source $BASE_DIR/migration-tc${test_case}.sh + source $MIGRATION_DIR/migration-tc${test_case}.sh timing_exit migration-tc${test_case} done diff --git a/test/vhost/other/negative.sh b/test/vhost/other/negative.sh index 45ace64b4..4d10321ec 100755 --- a/test/vhost/other/negative.sh +++ b/test/vhost/other/negative.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -BASE_DIR=$(readlink -f $(dirname $0)) -[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)" -[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../../../ && pwd)" +NEGATIVE_BASE_DIR=$(readlink -f $(dirname $0)) +[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $NEGATIVE_BASE_DIR/../common && pwd)" +[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $NEGATIVE_BASE_DIR/../../../../ && pwd)" function usage() { @@ -42,7 +42,7 @@ VHOST_APP="$SPDK_BUILD_DIR/app/vhost/vhost" notice "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 +$VHOST_APP -c /path/to/non_existing_file/conf -S $NEGATIVE_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 diff --git a/test/vhost/readonly/readonly.sh b/test/vhost/readonly/readonly.sh index bd273e85d..93e25cf43 100755 --- a/test/vhost/readonly/readonly.sh +++ b/test/vhost/readonly/readonly.sh @@ -1,12 +1,12 @@ #!/usr/bin/env bash set -e -BASE_DIR=$(readlink -f $(dirname $0)) -[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../../../ && pwd)" -[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $BASE_DIR/../common && pwd)" +READONLY_BASE_DIR=$(readlink -f $(dirname $0)) +[[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $READONLY_BASE_DIR/../../../../ && pwd)" +[[ -z "$COMMON_DIR" ]] && COMMON_DIR="$(cd $READONLY_BASE_DIR/../common && pwd)" source $COMMON_DIR/common.sh -rpc_py="$BASE_DIR/../../../scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" +rpc_py="$READONLY_BASE_DIR/../../../scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" vm_img="" disk="Nvme0n1" @@ -90,7 +90,7 @@ function blk_ro_tc1() vm_run $vm_no vm_wait_for_boot 600 $vm_no notice "Preparing partition and file on guest VM" - vm_ssh $vm_no "bash -s" < $BASE_DIR/disabled_readonly_vm.sh + vm_ssh $vm_no "bash -s" < $READONLY_BASE_DIR/disabled_readonly_vm.sh sleep 1 vm_shutdown_all @@ -102,7 +102,7 @@ function blk_ro_tc1() vm_run $vm_no vm_wait_for_boot 600 $vm_no notice "Testing readonly feature on guest VM" - vm_ssh $vm_no "bash -s" < $BASE_DIR/enabled_readonly_vm.sh + vm_ssh $vm_no "bash -s" < $READONLY_BASE_DIR/enabled_readonly_vm.sh sleep 3 vm_shutdown_all @@ -114,13 +114,13 @@ function blk_ro_tc1() vm_run $vm_no vm_wait_for_boot 600 $vm_no notice "Removing partition and file from test disk on guest VM" - vm_ssh $vm_no "bash -s" < $BASE_DIR/delete_partition_vm.sh + vm_ssh $vm_no "bash -s" < $READONLY_BASE_DIR/delete_partition_vm.sh sleep 1 vm_shutdown_all } -spdk_vhost_run --conf-path=$BASE_DIR +spdk_vhost_run --conf-path=$READONLY_BASE_DIR if [[ -z $x ]]; then set +x fi