[blktests,2/2] nvme: add new test to check model attribute
diff mbox series

Message ID 20191030195258.31108-3-chaitanya.kulkarni@wdc.com
State New
Headers show
Series
  • nvme: add a new test to check model attr
Related show

Commit Message

Chaitanya Kulkarni Oct. 30, 2019, 7:52 p.m. UTC
This test allows us to dynamically set the subsys model attribute
and verify in the nvme list command output.
---
 tests/nvme/033     | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/033.out |  3 +++
 2 files changed, 64 insertions(+)
 create mode 100755 tests/nvme/033
 create mode 100644 tests/nvme/033.out

Patch
diff mbox series

diff --git a/tests/nvme/033 b/tests/nvme/033
new file mode 100755
index 0000000..8ddadcf
--- /dev/null
+++ b/tests/nvme/033
@@ -0,0 +1,61 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2017-2018 Western Digital Corporation or its affiliates.
+#
+# Test NVMeOF model attribute for subsys.
+
+. tests/nvme/rc
+
+DESCRIPTION="test added subsys model attribute"
+QUICK=1
+
+requires() {
+	_have_program nvme && _have_modules loop nvme-loop nvmet && \
+		_have_configfs
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+
+	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" "${subsys_name}"
+	port="$(_create_nvmet_port "loop")"
+	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+
+	nvme connect -t loop -n "${subsys_name}"
+
+	nvme list | grep -v grep | grep -q "${subsys_name}"
+	ret=$?
+	
+	nvmedev="$(_find_nvme_loop_dev)"
+
+	udevadm settle
+
+	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}"
+
+	if [ ${ret} == 1 ]; then
+		echo "Test Fail"
+	else
+		echo "Test complete"
+	fi
+}
diff --git a/tests/nvme/033.out b/tests/nvme/033.out
new file mode 100644
index 0000000..eb508be
--- /dev/null
+++ b/tests/nvme/033.out
@@ -0,0 +1,3 @@ 
+Running nvme/033
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete