test/nvme: only run setup.sh test on Linux

For now, our scripts don't support detecting mounted filesystems on NVMe
devices on FreeBSD, so only run those tests on Linux.

Change-Id: I558715bf4e95eaad2dd2d8a546626269c0837edb
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393420
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2018-01-02 14:52:43 -07:00 committed by Jim Harris
parent 71db3a0870
commit 581107c77a

View File

@ -31,60 +31,62 @@ function get_nvme_name_from_bdf {
timing_enter nvme timing_enter nvme
# check that our setup.sh script does not bind NVMe devices to uio/vfio if they if [ `uname` = Linux ]; then
# have an active mountpoint # check that our setup.sh script does not bind NVMe devices to uio/vfio if they
$rootdir/scripts/setup.sh reset # have an active mountpoint
# give kernel nvme driver some time to create the block devices before we start looking for them $rootdir/scripts/setup.sh reset
sleep 1 # give kernel nvme driver some time to create the block devices before we start looking for them
blkname=''
# first, find an NVMe device that does not have an active mountpoint already;
# this covers rare case where someone is running this test script on a system
# that has a mounted NVMe filesystem
#
# note: more work probably needs to be done to properly handle devices with multiple
# namespaces
for bdf in $(linux_iter_pci 0108); do
get_nvme_name_from_bdf "$bdf" blkname
if [ "$blkname" != "" ]; then
mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
if [ "$mountpoints" = "0" ]; then
break
else
blkname=''
fi
fi
done
# if we found an NVMe block device without an active mountpoint, create and mount
# a filesystem on it for purposes of testing the setup.sh script
if [ "$blkname" != "" ]; then
parted -s /dev/$blkname mklabel gpt
# just create a 100MB partition - this tests our ability to detect mountpoints
# on partitions of the device, not just the device itself; it also is faster
# since we don't trim and initialize the whole namespace
parted -s /dev/$blkname mkpart primary 1 100
sleep 1 sleep 1
mkfs.ext4 -F /dev/${blkname}p1 blkname=''
mkdir -p /tmp/nvmetest # first, find an NVMe device that does not have an active mountpoint already;
mount /dev/${blkname}p1 /tmp/nvmetest # this covers rare case where someone is running this test script on a system
$rootdir/scripts/setup.sh # that has a mounted NVMe filesystem
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver)) #
# check that the nvme driver is still loaded against the device # note: more work probably needs to be done to properly handle devices with multiple
if [ "$driver" != "nvme" ]; then # namespaces
exit 1 for bdf in $(linux_iter_pci 0108); do
get_nvme_name_from_bdf "$bdf" blkname
if [ "$blkname" != "" ]; then
mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
if [ "$mountpoints" = "0" ]; then
break
else
blkname=''
fi
fi
done
# if we found an NVMe block device without an active mountpoint, create and mount
# a filesystem on it for purposes of testing the setup.sh script
if [ "$blkname" != "" ]; then
parted -s /dev/$blkname mklabel gpt
# just create a 100MB partition - this tests our ability to detect mountpoints
# on partitions of the device, not just the device itself; it also is faster
# since we don't trim and initialize the whole namespace
parted -s /dev/$blkname mkpart primary 1 100
sleep 1
mkfs.ext4 -F /dev/${blkname}p1
mkdir -p /tmp/nvmetest
mount /dev/${blkname}p1 /tmp/nvmetest
$rootdir/scripts/setup.sh
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
# check that the nvme driver is still loaded against the device
if [ "$driver" != "nvme" ]; then
exit 1
fi
umount /tmp/nvmetest
rmdir /tmp/nvmetest
# write zeroes to the device to blow away the partition table and filesystem
dd if=/dev/zero of=/dev/$blkname oflag=direct bs=1M count=1
$rootdir/scripts/setup.sh
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
# check that the nvme driver is not loaded against the device
if [ "$driver" = "nvme" ]; then
exit 1
fi
else
$rootdir/scripts/setup.sh
fi fi
umount /tmp/nvmetest
rmdir /tmp/nvmetest
# write zeroes to the device to blow away the partition table and filesystem
dd if=/dev/zero of=/dev/$blkname oflag=direct bs=1M count=1
$rootdir/scripts/setup.sh
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
# check that the nvme driver is not loaded against the device
if [ "$driver" = "nvme" ]; then
exit 1
fi
else
$rootdir/scripts/setup.sh
fi fi
if [ `uname` = Linux ]; then if [ `uname` = Linux ]; then