Skip to content

Commit b4af10b

Browse files
Copilotigaw
andauthored
tests: add mcl/mssrl/msrc limit checks to nvme_copy_test
Agent-Logs-Url: https://github.com/igaw/nvme-cli/sessions/b9873861-64f8-458e-9d40-1c230b961d91 Co-authored-by: igaw <1050803+igaw@users.noreply.github.com>
1 parent d47b05a commit b4af10b

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

tests/nvme_copy_test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import base64
2020

21-
from nvme_test import TestNVMe
21+
from nvme_test import TestNVMe, to_decimal
2222

2323

2424
class TestNVMeCopy(TestNVMe):
@@ -35,6 +35,9 @@ def setUp(self):
3535
""" Pre Section for TestNVMeCopy """
3636
super().setUp()
3737
self.ocfs = self.get_ocfs()
38+
self.mcl = to_decimal(self.get_id_ns_field_value("mcl"))
39+
self.mssrl = to_decimal(self.get_id_ns_field_value("mssrl"))
40+
self.msrc = to_decimal(self.get_id_ns_field_value("msrc"))
3841
self.host_behavior_data = None
3942
cross_namespace_copy = self.ocfs & 0xc
4043
if cross_namespace_copy:
@@ -78,6 +81,14 @@ def _check_format_supported(self, desc_format):
7881
if not self.ocfs & (1 << desc_format):
7982
self.skipTest(f"descriptor format {desc_format} is not supported")
8083

84+
def _check_ns_copy_limits(self):
85+
""" Skip test if namespace copy limits (mcl, mssrl, msrc) are not set """
86+
missing = [name for name, val in
87+
[("mcl", self.mcl), ("mssrl", self.mssrl), ("msrc", self.msrc)]
88+
if val == 0]
89+
if missing:
90+
self.skipTest(f"{', '.join(missing)} are 0, copy not supported on this namespace")
91+
8192
def copy(self, sdlba, blocks, slbs, **kwargs):
8293
""" Wrapper for nvme copy
8394
- Args:
@@ -105,29 +116,35 @@ def copy(self, sdlba, blocks, slbs, **kwargs):
105116
def test_copy_format_0(self):
106117
""" Test copy with descriptor format 0 """
107118
self._check_format_supported(0)
119+
self._check_ns_copy_limits()
108120
self.copy(0, 1, 2, descriptor_format=0)
109121

110122
def test_copy_format_1(self):
111123
""" Test copy with descriptor format 1 """
112124
self._check_format_supported(1)
125+
self._check_ns_copy_limits()
113126
self.copy(0, 1, 2, descriptor_format=1)
114127

115128
def test_copy_format_2(self):
116129
""" Test copy with descriptor format 2 """
117130
self._check_format_supported(2)
131+
self._check_ns_copy_limits()
118132
self.copy(0, 1, 2, descriptor_format=2, snsids=self.ns1_nsid)
119133

120134
def test_copy_format_2_sopts(self):
121135
""" Test copy with descriptor format 2 and source options """
122136
self._check_format_supported(2)
137+
self._check_ns_copy_limits()
123138
self.copy(0, 1, 2, descriptor_format=2, snsids=self.ns1_nsid, sopts=0)
124139

125140
def test_copy_format_3(self):
126141
""" Test copy with descriptor format 3 """
127142
self._check_format_supported(3)
143+
self._check_ns_copy_limits()
128144
self.copy(0, 1, 2, descriptor_format=3, snsids=self.ns1_nsid)
129145

130146
def test_copy_format_3_sopts(self):
131147
""" Test copy with descriptor format 3 and source options """
132148
self._check_format_supported(3)
149+
self._check_ns_copy_limits()
133150
self.copy(0, 1, 2, descriptor_format=3, snsids=self.ns1_nsid, sopts=0)

tests/nvme_test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,22 @@ def get_id_ctrl_field_value(self, field):
350350
f"ERROR : reading field '{field}' failed")
351351
return str(json_output[field])
352352

353+
def get_id_ns_field_value(self, field):
354+
""" Wrapper for extracting id-ns field values
355+
- Args:
356+
- field : field name to extract
357+
- Returns:
358+
- Field value of the given field as a string
359+
"""
360+
id_ns_cmd = f"{self.nvme_bin} id-ns {self.ns1} " + \
361+
"--output-format=json"
362+
result = self.run_cmd(id_ns_cmd)
363+
self.assertEqual(result.returncode, 0, "ERROR : reading id-ns failed")
364+
json_output = json.loads(result.stdout)
365+
self.assertTrue(field in json_output,
366+
f"ERROR : reading field '{field}' failed")
367+
return str(json_output[field])
368+
353369
def get_ocfs(self):
354370
""" Wrapper for extracting optional copy formats supported
355371
- Args:

0 commit comments

Comments
 (0)