test/ocf: factor out common functions

Move code like nvme_cfg and clean_nvme
to a new file - test/ocf/common.sh

Change-Id: Ife00cd979857ce69949ce9c9d9ad0b5581bb382b
Signed-off-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1629
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Michal Berger <michalx.berger@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Vitaliy Mysak 2020-04-01 17:06:17 +02:00 committed by Tomasz Zawadzki
parent 8d22cb3e4d
commit 75c1681c86
3 changed files with 37 additions and 50 deletions

29
test/ocf/common.sh Normal file
View File

@ -0,0 +1,29 @@
source $rootdir/scripts/common.sh
source $rootdir/test/common/autotest_common.sh
rpc_py=$rootdir/scripts/rpc.py
function nvme_cfg() {
if [ -z "$ocf_nvme_cfg" ]; then
ocf_nvme_cfg=$($rootdir/scripts/gen_nvme.sh)
fi
echo "$ocf_nvme_cfg"
}
function clear_nvme()
{
bdf=$($rootdir/scripts/gen_nvme.sh --json | jq '.config[0].params.traddr' | sed s/\"//g)
# Clear metadata on NVMe device
$rootdir/scripts/setup.sh reset
sleep 5
name=$(get_nvme_name_from_bdf $bdf)
mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w)
if [ "$mountpoints" != "0" ]; then
$rootdir/scripts/setup.sh
exit 1
fi
dd if=/dev/zero of=/dev/$name bs=1M count=1000 oflag=direct
$rootdir/scripts/setup.sh
}

View File

@ -2,9 +2,8 @@
curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
rootdir=$(readlink -f $curdir/../../..)
plugindir=$rootdir/examples/bdev/fio_plugin
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/ocf/common.sh
function fio_verify(){
fio_bdev $curdir/test.fio --aux-path=/tmp/ --ioengine=spdk_bdev "$@"
@ -14,33 +13,15 @@ function cleanup(){
rm -f $curdir/modes.conf
}
function clear_nvme()
{
# Clear metadata on NVMe device
$rootdir/scripts/setup.sh reset
sleep 5
name=$(get_nvme_name_from_bdf $1)
mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w)
if [ "$mountpoints" != "0" ]; then
$rootdir/scripts/setup.sh
exit 1
fi
dd if=/dev/zero of=/dev/$name bs=1M count=1000 oflag=direct
$rootdir/scripts/setup.sh
}
# Clear only nvme device which we will use in test
bdf=$($rootdir/scripts/gen_nvme.sh --json | jq '.config[0].params.traddr' | sed s/\"//g)
clear_nvme "$bdf"
# Clear nvme device which we will use in test
clear_nvme
trap "cleanup; exit 1" SIGINT SIGTERM EXIT
nvme_cfg=$($rootdir/scripts/gen_nvme.sh)
config="
$nvme_cfg
$(nvme_cfg)
[Split]
Split Nvme0n1 8 101

View File

@ -2,41 +2,18 @@
curdir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
rootdir=$(readlink -f $curdir/../../..)
source $rootdir/scripts/common.sh
source $rootdir/test/common/autotest_common.sh
function clear_nvme()
{
# Clear metadata on NVMe device
$rootdir/scripts/setup.sh reset
sleep 5
name=$(get_nvme_name_from_bdf $1)
mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w)
if [ "$mountpoints" != "0" ]; then
$rootdir/scripts/setup.sh
exit 1
fi
dd if=/dev/zero of=/dev/$name bs=1M count=1000 oflag=direct
$rootdir/scripts/setup.sh
}
rpc_py=$rootdir/scripts/rpc.py
$rootdir/scripts/setup.sh
nvme_cfg=$($rootdir/scripts/gen_nvme.sh)
source $rootdir/test/ocf/common.sh
config="
$nvme_cfg
$(nvme_cfg)
[Split]
Split Nvme0n1 7 128
"
echo "$config" > $curdir/config
# Clear only nvme device which we will use in test
bdf=$($rootdir/scripts/gen_nvme.sh --json | jq '.config[0].params.traddr' | sed s/\"//g)
clear_nvme $bdf
# Clear nvme device which we will use in test
clear_nvme
$rootdir/app/iscsi_tgt/iscsi_tgt -c $curdir/config &
spdk_pid=$!