From: Denis V. Lunev <[email protected]> Every NBD request the iotests send arrives in NBD_MODE_EXTENDED, so the server paths kept for older clients are never taken. Instrumenting nbd_co_receive_request() over the whole auto group and every test that touches NBD gives mode 4 for all of them, which leaves nbd_co_send_simple_reply() and the compact header handling dead under test. A regression there would only show against a third party client.
libnbd can negotiate down, so run the same command set three times, once per mode, and assert the mode that was actually reached. Block status is limited to the two modes that can negotiate a meta context. Signed-off-by: Denis V. Lunev <[email protected]> CC: Eric Blake <[email protected]> CC: Vladimir Sementsov-Ogievskiy <[email protected]> --- tests/qemu-iotests/tests/nbd-commands | 29 +++++++++++++++++++++++ tests/qemu-iotests/tests/nbd-commands.out | 4 ++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/tests/nbd-commands b/tests/qemu-iotests/tests/nbd-commands index cbfc47782f..3dfe913190 100755 --- a/tests/qemu-iotests/tests/nbd-commands +++ b/tests/qemu-iotests/tests/nbd-commands @@ -119,6 +119,35 @@ class TestNbdCommands(iotests.QMPTestCase): self.assertEqual(self.top_extents(), [(0, size, 0)]) qemu_io('-c', f'read -P {pattern} 0 {size}', top) + def check_commands(self, structured, extended): + self.connect(structured, extended) + + self.assertEqual(self.h.pread(4096, 4096), bytes([pattern]) * 4096) + + self.h.cache(size, 0) + + self.h.pwrite(b'x' * 4096, 4096) + self.h.flush() + self.assertEqual(self.h.pread(4096, 4096), b'x' * 4096) + + self.h.zero(4096, 8192) + self.assertEqual(self.h.pread(4096, 8192), bytes(4096)) + + self.h.trim(4096, 16384) + + if structured: + self.assertEqual(self.block_status()['qemu:allocation-depth'], + [(size, DEPTH_LOCAL)]) + + def test_commands_simple_replies(self): + self.check_commands(structured=False, extended=False) + + def test_commands_structured_replies(self): + self.check_commands(structured=True, extended=False) + + def test_commands_extended_headers(self): + self.check_commands(structured=True, extended=True) + def test_cache_past_end_of_export(self): self.assertRaises(nbd.Error, self.h.cache, size + 1, 0) diff --git a/tests/qemu-iotests/tests/nbd-commands.out b/tests/qemu-iotests/tests/nbd-commands.out index 8d7e996700..3f8a935a08 100644 --- a/tests/qemu-iotests/tests/nbd-commands.out +++ b/tests/qemu-iotests/tests/nbd-commands.out @@ -1,5 +1,5 @@ -... +...... ---------------------------------------------------------------------- -Ran 3 tests +Ran 6 tests OK -- 2.53.0
