]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
blktests: add NVMeOF flush test for bdev-ns
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Mon, 11 Jun 2018 09:15:51 +0000 (05:15 -0400)
committerOmar Sandoval <osandov@fb.com>
Thu, 26 Jul 2018 21:28:25 +0000 (14:28 -0700)
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
tests/nvme/014 [new file with mode: 0755]
tests/nvme/014.out [new file with mode: 0755]

diff --git a/tests/nvme/014 b/tests/nvme/014
new file mode 100755 (executable)
index 0000000..4be311a
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+# Test NVMeOF flush command from host with a block device backed ns.
+# Copyright (c) 2017-2018 Western Digital Corporation or its affiliates.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.
+#
+#   Author: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
+#
+
+. tests/nvme/rc
+
+DESCRIPTION="flush a NVMeOF block device-backed ns"
+QUICK=1
+
+requires() {
+       _have_program nvme && _have_module nvme-loop && _have_module loop && \
+               _have_module nvmet && _have_configfs
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       modprobe nvmet
+       modprobe nvme-loop
+
+       local port
+       local nvmedev
+       local loop_dev
+       local file_path="$TMPDIR/img"
+       local subsys_name="blktests-subsystem-1"
+
+       truncate -s 1G "${file_path}"
+
+       loop_dev="$(losetup -f --show "${file_path}")"
+
+       _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
+                "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
+       port="$(_create_nvmet_port "loop")"
+       _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+
+       nvme connect -t loop -n "${subsys_name}"
+
+       nvmedev="$(_find_nvme_loop_dev)"
+       cat "/sys/block/${nvmedev}n1/uuid"
+       cat "/sys/block/${nvmedev}n1/wwid"
+
+       dd if=/dev/urandom of="/dev/${nvmedev}n1" count=128000 bs=4k status=none
+
+       nvme flush "/dev/${nvmedev}" -n 1
+
+       nvme disconnect -n "${subsys_name}"
+
+       _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+       _remove_nvmet_subsystem "${subsys_name}"
+       _remove_nvmet_port "${port}"
+
+       losetup -d "${loop_dev}"
+
+       rm "${file_path}"
+
+       modprobe -r nvme-loop
+       modprobe -r nvmet
+
+       echo "Test complete"
+}
diff --git a/tests/nvme/014.out b/tests/nvme/014.out
new file mode 100755 (executable)
index 0000000..0285826
--- /dev/null
@@ -0,0 +1,6 @@
+Running nvme/014
+91fdba0d-f87b-4c25-b80f-db7be1418b9e
+uuid.91fdba0d-f87b-4c25-b80f-db7be1418b9e
+NVMe Flush: success
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete