-
Notifications
You must be signed in to change notification settings - Fork 709
tests: don't enforce NS management support for local testing #3226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,7 +43,12 @@ def to_decimal(value): | |||||||||||
| - Returns: | ||||||||||||
| - Decimal integer | ||||||||||||
| """ | ||||||||||||
| return int(str(value), 0) | ||||||||||||
| val = 0 | ||||||||||||
| try: | ||||||||||||
| val = int(str(value), 0) | ||||||||||||
| except (TypeError, ValueError): | ||||||||||||
| raise ValueError(f"Invalid value: {value!r}") | ||||||||||||
| return val | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class TestNVMe(unittest.TestCase): | ||||||||||||
|
|
@@ -77,14 +82,17 @@ def setUp(self): | |||||||||||
| self.load_config() | ||||||||||||
| if self.do_validate_pci_device: | ||||||||||||
| self.validate_pci_device() | ||||||||||||
| self.create_and_attach_default_ns() | ||||||||||||
| self.ns_mgmt_supported = self.get_ns_mgmt_support() | ||||||||||||
| 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 +217,30 @@ 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): | ||||||||||||
| """ | ||||||||||||
| Determine whether Namespace Management and Namespace Attachment | ||||||||||||
| operations are supported by the controller. | ||||||||||||
|
|
||||||||||||
| This method reads the Optional Admin Command Support (OACS) field | ||||||||||||
| from the Identify Controller data structure and evaluates specific | ||||||||||||
| bits that indicate support for: | ||||||||||||
| - Namespace Management (bit 3) | ||||||||||||
| - Namespace Attachment (bit 4) | ||||||||||||
|
|
||||||||||||
| Both features must be supported for this function to return True. | ||||||||||||
|
|
||||||||||||
| Returns: | ||||||||||||
| bool: True if both Namespace Management and Namespace Attachment | ||||||||||||
| are supported, False otherwise. | ||||||||||||
| """ | ||||||||||||
| oacs = to_decimal(self.get_id_ctrl_field_value("oacs")) | ||||||||||||
|
|
||||||||||||
| ns_mgmt_supported = bool(oacs & (1 << 3)) | ||||||||||||
| ns_attach_supported = bool(oacs & (1 << 4)) | ||||||||||||
|
Comment on lines
+239
to
+240
|
||||||||||||
| ns_mgmt_supported = bool(oacs & (1 << 3)) | |
| ns_attach_supported = bool(oacs & (1 << 4)) | |
| # OACS bit 3 indicates combined Namespace Management and Attachment support. | |
| ns_mgmt_supported = bool(oacs & (1 << 3)) | |
| ns_attach_supported = ns_mgmt_supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
get_ns_mgmt_support()helper is missing a docstring, while surrounding helpers in this file consistently document purpose/args/returns. Please add a brief docstring (and ideally note which OACS bit(s) are being checked) to keep the file’s documentation style consistent.