From 8fc73469b8199b4d3c77502a883dd3fe0b058443 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 8 Dec 2025 15:09:59 +0100 Subject: [PATCH] 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 --- tests/nvme_test.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/nvme_test.py b/tests/nvme_test.py index 0c66be88a8..5a0eb9c5f9 100644 --- a/tests/nvme_test.py +++ b/tests/nvme_test.py @@ -77,14 +77,18 @@ def setUp(self): self.load_config() if self.do_validate_pci_device: self.validate_pci_device() - self.create_and_attach_default_ns() + ns_mgmt = self.get_ns_mgmt_support() + self.ns_mgmt_supported = ns_mgmt["ns_mgmt"] and ns_mgmt["ns_attach"] + if self.ns_mgmt_supported: + self.create_and_attach_default_ns() print(f"\nsetup: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n") def tearDown(self): """ Post Section for TestNVMe. """ if self.clear_log_dir is True: shutil.rmtree(self.log_dir, ignore_errors=True) - self.create_and_attach_default_ns() + if self.ns_mgmt_supported: + self.create_and_attach_default_ns() print(f"\nteardown: ctrl: {self.ctrl}, ns1: {self.ns1}, default_nsid: {self.default_nsid}, flbas: {self.flbas}\n") @classmethod @@ -209,6 +213,23 @@ def get_ctrl_id(self): "ERROR : nvme list-ctrl could not find ctrl") return str(json_output['ctrl_list'][0]['ctrl_id']) + def get_ns_mgmt_support(self): + oacs_str = self.get_id_ctrl_field_value("oacs") + + try: + oacs = int(oacs_str, 0) + except (TypeError, ValueError): + raise ValueError(f"Invalid OACS value: {oacs_str!r}") + + ns_mgmt_supported = bool(oacs & (1 << 3)) + ns_attach_supported = bool(oacs & (1 << 4)) + + return { + "raw": oacs, + "ns_mgmt": ns_mgmt_supported, + "ns_attach": ns_attach_supported, + } + def get_nsid_list(self): """ Wrapper for extracting the namespace list. - Args: