Skip to step 3 if the kernel version is >= v4.8. Otherwise, for kernel versions < v4.8, configure the kernel to make some memory available to CMA (contiguous memory allocator). This will be used to emulate DAX.

CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=200

orcma=200M on the kernel command line.

Compile the libnvdimm sub-system as a module, make sure “zone device” memory is enabled, and enable the btt, pfn, and dax features of the sub-system:

Build and install the unit test enabled libnvdimm modules in the following order. The unit test modules need to be in place prior to the depmod that runs during the final modules_install

make M=tools/testing/nvdimm
sudo make M=tools/testing/nvdimm modules_install
sudo make modules_install

Now run make check in the ndctl source directory, or ndctl test, if ndctl was built with --enable-test.

Troubleshooting

The unit tests will validate that the environment is set up correctly before they try to run. If the platform is misconfigured, i.e. the unit test modules are not available, or the test versions of the modules are superseded by the “in-tree/production” version of the modules make check will skip tests and report a message like the following in test/test-suite.log:

The nfit_test module emulates pmem with memory allocated via vmalloc(). One of the side effects is that this breaks ‘physically contiguous’ assumptions in the driver. Use the '--align=4K option to ‘ndctl create-namespace’ to avoid these corner case scenarios.