Skip to content

tests: don't enforce NS management support for local testing#3226

Open
igaw wants to merge 2 commits intolinux-nvme:masterfrom
igaw:relax-tests
Open

tests: don't enforce NS management support for local testing#3226
igaw wants to merge 2 commits intolinux-nvme:masterfrom
igaw:relax-tests

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Apr 1, 2026

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.

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 1, 2026

@MaisenbacherD what do you think about this?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the NVMe Python test framework to avoid enforcing Namespace (NS) management during setup/teardown when running on devices that don’t support NS management, enabling a larger subset of tests to run in such environments.

Changes:

  • Add controller feature detection for NS management support via OACS parsing.
  • Conditionally skip default namespace create/attach logic in setUp() and tearDown() when unsupported.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +224 to +225
ns_mgmt_supported = bool(oacs & (1 << 3))
ns_attach_supported = bool(oacs & (1 << 4))
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_ns_mgmt_support() is interpreting OACS bit 4 as “namespace attach”, but in this repo OACS[4] is used for Device Self-test and OACS[3] is “NS Management and Attachment” (combined). This will incorrectly report ns_mgmt_supported as false on controllers that support NS mgmt/attach but don’t support self-test, causing namespace setup/teardown to be skipped. Please base the NS mgmt+attach detection on OACS bit 3 only (and adjust the returned fields accordingly).

Suggested change
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

Copilot uses AI. Check for mistakes.
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"]
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.ns_mgmt_supported is computed as ns_mgmt["ns_mgmt"] and ns_mgmt["ns_attach"], but the current OACS parsing treats bit 4 as “ns_attach”. In this codebase OACS bit 4 corresponds to Device Self-test and OACS bit 3 represents “NS Management and Attachment” together, so this AND will incorrectly disable namespace setup on some controllers. After fixing the OACS bit interpretation, consider deriving this flag directly from the combined capability to avoid mismatches.

Suggested change
self.ns_mgmt_supported = ns_mgmt["ns_mgmt"] and ns_mgmt["ns_attach"]
self.ns_mgmt_supported = bool(ns_mgmt.get("ns_mgmt_and_attach", ns_mgmt.get("ns_mgmt")))

Copilot uses AI. Check for mistakes.
"ERROR : nvme list-ctrl could not find ctrl")
return str(json_output['ctrl_list'][0]['ctrl_id'])

def get_ns_mgmt_support(self):
Copy link

Copilot AI Apr 1, 2026

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.

Suggested change
def get_ns_mgmt_support(self):
def get_ns_mgmt_support(self):
""" Parse controller OACS field to determine namespace management support.
- Args:
- None
- Returns:
- Dictionary with:
- "raw": integer OACS value.
- "ns_mgmt": True if OACS bit 3 (Namespace Management) is set.
- "ns_attach": True if OACS bit 4 (Namespace Attachment) is set.
"""

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@MaisenbacherD MaisenbacherD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a few comments. This is a good idea! :)

igaw added 2 commits April 2, 2026 09:34
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 <wagi@kernel.org>
These tests will fail if the controller does not support namespace
management, thus skip them.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 2, 2026

I am running this against a qemu emulated nvme disk:

$  meson test -C .build
[...]
52/76 nvme-cli - nvme_attach_detach_ns_test                              OK               1.49s
53/76 nvme-cli - nvme_create_max_ns_test                                 OK               1.62s
54/76 nvme-cli - nvme_format_test                                        OK               1.78s
55/76 nvme-cli - nvme_error_log_test                                     OK               2.01s
56/76 nvme-cli - nvme_fw_log_test                                        OK               1.94s
57/76 nvme-cli - nvme_flush_test                                         OK               2.18s
58/76 nvme-cli - nvme_id_ctrl_test                                       OK               2.05s
59/76 nvme-cli - nvme_id_ns_test                                         OK               2.08s
60/76 nvme-cli - nvme_compare_test                                       OK               2.62s
61/76 nvme-cli - nvme_read_write_test                                    OK               2.21s
62/76 nvme-cli - nvme_smart_log_test                                     OK               2.34s
63/76 nvme-cli - nvme_writeuncor_test                                    FAIL             2.80s   exit status 1
>>> MALLOC_PERTURB_=167 PATH=/home/wagi/work/nvme-cli/.build-debian:/usr/bin:/usr/sbin /usr/bin/nose2 --verbose --start-dir /home/wagi/work/nvme-cli/.build-debian/tests nvme_writeuncor_test

64/76 nvme-cli - nvme_verify_test                                        OK               2.43s
65/76 nvme-cli - nvme_dsm_test                                           OK               2.59s
66/76 nvme-cli - nvme_copy_test                                          FAIL             2.74s   exit status 1
>>> MALLOC_PERTURB_=243 PATH=/home/wagi/work/nvme-cli/.build-debian:/usr/bin:/usr/sbin /usr/bin/nose2 --verbose --start-dir /home/wagi/work/nvme-cli/.build-debian/tests nvme_copy_test

67/76 nvme-cli - nvme_get_lba_status_test                                OK               2.56s
68/76 nvme-cli - nvme_lba_status_log_test                                OK               2.69s
69/76 nvme-cli - nvme_writezeros_test                                    OK               3.16s
70/76 nvme-cli - nvme_get_features_test                                  FAIL             4.97s   exit status 1
>>> MALLOC_PERTURB_=87 PATH=/home/wagi/work/nvme-cli/.build-debian:/usr/bin:/usr/sbin /usr/bin/nose2 --verbose --start-dir /home/wagi/work/nvme-cli/.build-debian/tests nvme_get_features_test

71/76 nvme-cli - nvme_ctrl_reset_test                                    OK               2.91s
[...]

I think it starts to uncover bugs. nvme_get_features_test runs fine standalone, if it is run in the test suite it fails...

And we need to figure out how to forward the 'skipped' info to meson :)

@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Apr 2, 2026

okay, I've bitten the bullet: #3233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants