Skip to content

Commit 8fc7346

Browse files
committed
tests: don't enforce NS management support for local testing
The tests framework added supported and dependency on NS management for clean setups. Though this prevents to run part of the tests suites on devices which do no support NS management. Add feature detection and skip the setup/tear down code for the NS setup if the device doesn't support this. Signed-off-by: Daniel Wagner <[email protected]>
1 parent c634947 commit 8fc7346

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/nvme_test.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ def setUp(self):
7777
self.load_config()
7878
if self.do_validate_pci_device:
7979
self.validate_pci_device()
80-
self.create_and_attach_default_ns()
80+
ns_mgmt = self.get_ns_mgmt_support()
81+
self.ns_mgmt_supported = ns_mgmt["ns_mgmt"] and ns_mgmt["ns_attach"]
82+
if self.ns_mgmt_supported:
83+
self.create_and_attach_default_ns()
8184
print(f"\nsetup: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n")
8285

8386
def tearDown(self):
8487
""" Post Section for TestNVMe. """
8588
if self.clear_log_dir is True:
8689
shutil.rmtree(self.log_dir, ignore_errors=True)
87-
self.create_and_attach_default_ns()
90+
if self.ns_mgmt_supported:
91+
self.create_and_attach_default_ns()
8892
print(f"\nteardown: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n")
8993

9094
@classmethod
@@ -209,6 +213,23 @@ def get_ctrl_id(self):
209213
"ERROR : nvme list-ctrl could not find ctrl")
210214
return str(json_output['ctrl_list'][0]['ctrl_id'])
211215

216+
def get_ns_mgmt_support(self):
217+
oacs_str = self.get_id_ctrl_field_value("oacs")
218+
219+
try:
220+
oacs = int(oacs_str, 0)
221+
except (TypeError, ValueError):
222+
raise ValueError(f"Invalid OACS value: {oacs_str!r}")
223+
224+
ns_mgmt_supported = bool(oacs & (1 << 3))
225+
ns_attach_supported = bool(oacs & (1 << 4))
226+
227+
return {
228+
"raw": oacs,
229+
"ns_mgmt": ns_mgmt_supported,
230+
"ns_attach": ns_attach_supported,
231+
}
232+
212233
def get_nsid_list(self):
213234
""" Wrapper for extracting the namespace list.
214235
- Args:

0 commit comments

Comments
 (0)