diff options
author | Dan Williams <dan.j.williams@intel.com> | 2015-06-17 21:23:32 (GMT) |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2015-06-26 15:23:38 (GMT) |
commit | 6bc756193ff61bf5e7b3cfedfbb0873bf40f8055 (patch) | |
tree | 5b17fac71bf9989eb2f5ab4ff10e3c6fc01a3cbf /drivers/acpi/nfit.h | |
parent | 047fc8a1f9a6330eacc80374dff087e20dc2304b (diff) | |
download | linux-6bc756193ff61bf5e7b3cfedfbb0873bf40f8055.tar.xz |
tools/testing/nvdimm: libnvdimm unit test infrastructure
'libnvdimm' is the first driver sub-system in the kernel to implement
mocking for unit test coverage. The nfit_test module gets built as an
external module and arranges for external module replacements of nfit,
libnvdimm, nd_pmem, and nd_blk. These replacements use the linker
--wrap option to redirect calls to ioremap() + request_mem_region() to
custom defined unit test resources. The end result is a fully
functional nvdimm_bus, as far as userspace is concerned, but with the
capability to perform otherwise destructive tests on emulated resources.
Q: Why not use QEMU for this emulation?
QEMU is not suitable for unit testing. QEMU's role is to faithfully
emulate the platform. A unit test's role is to unfaithfully implement
the platform with the goal of triggering bugs in the corners of the
sub-system implementation. As bugs are discovered in platforms, or the
sub-system itself, the unit tests are extended to backstop a fix with a
reproducer unit test.
Another problem with QEMU is that it would require coordination of 3
software projects instead of 2 (kernel + libndctl [1]) to maintain and
execute the tests. The chances for bit rot and the difficulty of
getting the tests running goes up non-linearly the more components
involved.
Q: Why submit this to the kernel tree instead of external modules in
libndctl?
Simple, to alleviate the same risk that out-of-tree external modules
face. Updates to drivers/nvdimm/ can be immediately evaluated to see if
they have any impact on tools/testing/nvdimm/.
Q: What are the negative implications of merging this?
It is a unique maintenance burden because the purpose of mocking an
interface to enable a unit test is to purposefully short circuit the
semantics of a routine to enable testing. For example
__wrap_ioremap_cache() fakes the pmem driver into "ioremap()'ing" a test
resource buffer allocated by dma_alloc_coherent(). The future
maintenance burden hits when someone changes the semantics of
ioremap_cache() and wonders what the implications are for the unit test.
[1]: https://github.com/pmem/ndctl
Cc: <linux-acpi@vger.kernel.org>
Cc: Lv Zheng <lv.zheng@intel.com>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/acpi/nfit.h')
-rw-r--r-- | drivers/acpi/nfit.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h index 7bd38b7..c62fffe 100644 --- a/drivers/acpi/nfit.h +++ b/drivers/acpi/nfit.h @@ -93,6 +93,8 @@ struct acpi_nfit_desc { struct nvdimm_bus *nvdimm_bus; struct device *dev; unsigned long dimm_dsm_force_en; + int (*blk_do_io)(struct nd_blk_region *ndbr, resource_size_t dpa, + void *iobuf, u64 len, int rw); }; enum nd_blk_mmio_selector { @@ -146,4 +148,8 @@ static inline struct acpi_nfit_desc *to_acpi_desc( { return container_of(nd_desc, struct acpi_nfit_desc, nd_desc); } + +const u8 *to_nfit_uuid(enum nfit_uuids id); +int acpi_nfit_init(struct acpi_nfit_desc *nfit, acpi_size sz); +extern const struct attribute_group *acpi_nfit_attribute_groups[]; #endif /* __NFIT_H__ */ |