]> www.infradead.org Git - users/sagi/libnvme.git/commit
test: add infra for mocking passthru ioctls
authorCaleb Sander <csander@purestorage.com>
Sun, 30 Jul 2023 23:08:59 +0000 (17:08 -0600)
committerDaniel Wagner <wagi@monom.org>
Fri, 11 Aug 2023 10:04:21 +0000 (12:04 +0200)
commitf6bfc622d6e8f716fb9ab6a8ca84370badb0bbae
tree26c7787d7717aaaf0f8993d85d36b85bb809e22f
parent3564474d451ee21d1e92eec69609cf81d6177d2c
test: add infra for mocking passthru ioctls

Functions issuing admin/IO passthru ioctls sorely lack unit tests.
It would be great for unit tests not to need a real NVMe controller.
It's also useful to be able to test responses to commands
that might be impossible to trigger with real controllers.

To that end, implement infrastructure for mocking ioctl(),
allowing tests to set expectations for the NVMe passthru ioctls
that will be issued and control the corresponding responses.

The mock library can be used with LD_PRELOAD so that libnvme's ioctl()
calls are redirected from libc. No changes in libnvme itself are needed.

Signed-off-by: Caleb Sander <csander@purestorage.com>
test/ioctl/meson.build [new file with mode: 0644]
test/ioctl/mock.c [new file with mode: 0644]
test/ioctl/mock.h [new file with mode: 0644]
test/ioctl/util.c [new file with mode: 0644]
test/ioctl/util.h [new file with mode: 0644]
test/meson.build