Skip to content

fixes and improvements for nvme_copy_test #3327

Merged
igaw merged 10 commits intolinux-nvme:masterfrom
igaw:fix-test-copy
Apr 28, 2026
Merged

fixes and improvements for nvme_copy_test #3327
igaw merged 10 commits intolinux-nvme:masterfrom
igaw:fix-test-copy

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Apr 27, 2026

Address the long standing decoding issue reported in #3232 by implementing nvme feat host-behavior-suported and update the test case to use it.

Second split the nvme_copy_test into several sub tests so they reported independently.

Third, test if the device actually has valid values for mcl, mssrl, and msrc. Qemu's default settings are 0.

>>> PATH=/home/wagi/work/nvme-cli/.build-debian:/usr/bin:/usr/sbin MALLOC_PERTURB_=199 /usr/bin/python3 /home/wagi/work/nvme-cli/tests/tap_runner.py --start-dir /home/wagi/work/nvme-cli/tests nvme_copy_test
▶ 1/1 - test_copy_format_0 (TestNVMeCopy) OK
▶ 1/1 - test_copy_format_1 (TestNVMeCopy) FAIL
▶ 1/1 - test_copy_format_2 (TestNVMeCopy) OK
▶ 1/1 - test_copy_format_2_sopts (TestNVMeCopy) OK
▶ 1/1 - test_copy_format_3 (TestNVMeCopy) FAIL
▶ 1/1 - test_copy_format_3_sopts (TestNVMeCopy) FAIL
1/1 nvme-cli - nvme_copy_test        FAIL             3.38s   3/6 subtests passed
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
  ---
  traceback: |
    Traceback (most recent call last):
      File "/usr/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
        yield
      File "/usr/lib/python3.11/unittest/case.py", line 623, in run
        self._callTestMethod(testMethod)
      File "/usr/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
        if method() is not None:
           ^^^^^^^^
      File "/home/wagi/work/nvme-cli/tests/nvme_copy_test.py", line 133, in test_copy_format_1
        self.copy(0, 1, 2, descriptor_format=1)
      File "/home/wagi/work/nvme-cli/tests/nvme_copy_test.py", line 121, in copy
        self.assertEqual(self.exec_cmd(copy_cmd), 0)
    AssertionError: 1 != 0
  ...

Fixes: #3232 #3322

@igaw igaw force-pushed the fix-test-copy branch 2 times, most recently from 25c3270 to 788303d Compare April 27, 2026 21:37
@igaw igaw marked this pull request as ready for review April 27, 2026 21:38
igaw added 10 commits April 28, 2026 13:41
The file might already exist, thus in the case make sure it's truncated
to zero before writing to it.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Implement Host Behavior Support in the feat plugin to enable its use in
the nvme_copy_test test case, which currently relies on parsing raw log
pages.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Replace the the raw output decoding of the Host Behavior Support feature
with the new 'nvme feat host-behavior-support' command.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
get_lba_format_size incorrectly treats the 'ms' field as a power-of-2
exponent.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Report the result of each individual test instead of combining them.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The copy test can only run with valid mcl, mssrl, and msrc values.
Therefore, check that they are non-zero. QEMU’s default namespace
settings set these values to 0. The user must set them explicitly, e.g

	-device nvme-ns,drive=ns0,nsid=1,mcl=1024,mssrl=1024,msrc=63

Signed-off-by: Daniel Wagner <wagi@kernel.org>
The setUp method was enabling all cross-namespace cdfe bits
(CDF2E | CDF3E = 12) for every test, including format 0 and 1.
Only enable support necessary descriptor version used in the test.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Copy Descriptor Formats 1h and 3h require the source namespace to be
formatted with 64-bit guard protection information (pif=2 in the
extended LBA format entry per nvm-id-ns). When the namespace uses a
standard 16-bit guard LBA format the controller returns "Invalid
Format" (0x410a).

Signed-off-by: Daniel Wagner <wagi@kernel.org>
… PI mode

When ns_mgmt_supported=False, TestNVMe.setUp/tearDown never touch the
namespace.  If the device is configured with 64-bit guard PI (e.g. QEMU
started with pif=2, or namespace left reformatted by a previous run),
copy descriptor format 0 and format 2 commands would fail with NVMe
status "Invalid Format" instead of being skipped cleanly.

Signed-off-by: Daniel Wagner <wagi@kernel.org>
Teach the test framework about PI and MS.

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

igaw commented Apr 28, 2026

Tested with various Qemu configurations:

  • -device nvme-ns,drive=ns0,nsid=1,mcl=1024,mssrl=1024,msrc=63
  • -device nvme-ns,drive=ns0,nsid=1,mcl=1024,mssrl=1024,msrc=63,ms=16
  • -device nvme-ns,drive=ns0,nsid=1,mcl=1024,mssrl=1024,msrc=63,ms=16,pi=1

All but one test passes (see #3321)

@igaw igaw merged commit 901d3a3 into linux-nvme:master Apr 28, 2026
28 of 29 checks passed
@igaw igaw deleted the fix-test-copy branch April 28, 2026 12:25
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.

nvme_copy_test fails on decoding output

1 participant