[PATCH blktests v5 2/4] nvme/rc: Add nvmet attribute feature detection function

Daniel Wagner dwagner at suse.de
Wed Apr 5 08:46:28 PDT 2023


In order to detect if the target supports a attribute, we have to setup
a target and check if the attribute file appears.

Signed-off-by: Daniel Wagner <dwagner at suse.de>
---
 tests/nvme/rc | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index ec7678dbe09e..e720a35113aa 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -627,6 +627,31 @@ _set_nvmet_attr_qid_max() {
 	fi
 }
 
+_detect_nvmet_subsys_attr() {
+	local attr="$1"
+	local file_path="${TMPDIR}/img"
+	local subsys_name="blktests-feature-detect"
+	local cfs_path="${NVMET_CFS}/subsystems/${subsys_name}"
+	local port
+
+	truncate -s 1M "${file_path}"
+
+	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
+		"b92842df-a394-44b1-84a4-92ae7d112332"
+	port="$(_create_nvmet_port "${nvme_trtype}")"
+
+	local val=1
+	[[ -f "${cfs_path}/${attr}" ]] && val=0
+
+	_remove_nvmet_subsystem "${subsys_name}"
+
+	_remove_nvmet_port "${port}"
+
+	rm "${file_path}"
+
+	return "${val}"
+}
+
 _find_nvme_dev() {
 	local subsys=$1
 	local subsysnqn
-- 
2.40.0




More information about the Linux-nvme mailing list