numam-spdk/test/ocf/common.sh
Vitaliy Mysak 75c1681c86 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>
2020-04-14 11:35:17 +00:00

30 lines
704 B
Bash

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
}