Commit 1dfac8ba authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

test/ocf: Don't depend on gen_nvme.sh while detecting nvme ctrls



gen_nvme.sh requires that all the nvme devices are not bound to the
nvme driver which doesn't have to be the case when clear_nvme() is
called. To not depend on which driver is in use, simply iterate over
pci bus to find a proper device. This avoids additional setup.sh
ping-pong which is required to make use of gen_nvme.sh.

Additionally, upon exiting, in case mounts for given nvme device were
detected, keep the test environment reset to leave nvmes bound to the
nvme driver.

Change-Id: I428c5e2b0517553d267411a30316bde5d1ce8eef
Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1843


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent d3f04b64
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -13,15 +13,15 @@ function nvme_cfg() {

function clear_nvme()
{
	bdf=$($rootdir/scripts/gen_nvme.sh --json | jq '.config[0].params.traddr' | sed s/\"//g)
	mapfile -t bdf < <(iter_all_pci_class_code 01 08 02)

	# Clear metadata on NVMe device
	$rootdir/scripts/setup.sh reset
	sleep 5
	name=$(get_nvme_name_from_bdf $bdf)

	name=$(get_nvme_name_from_bdf "${bdf[0]}")
	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