The pmem_ns unit test is designed to fallback to using the nfit_test bus resource when an ACPI resource is not available. That fallback is not as solid as it could be, causing intermittent failures of the unit test.
That nfit_test fallback fails with errors such as: path: /sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid libndctl: write_attr: failed to open /sys/devices/platform/nfit_test.0/ndbus2/region7/namespace7.0/uuid: No such file or directory /root/ndctl/build/test/pmem-ns: failed to create PMEM namespace This occurs because calling ndctl_test_init() with a NULL context only unloads and reloads the nfit_test module, but does not invalidate and reinitialize the libndctl context or its sysfs view from previous runs. The resulting stale state prevents the test from creating a new namespace cleanly. Replace the NULL context parameter when calling ndctl_test_init() with the available ndctl_ctx to ensure pmem_ns can find usable PMEM regions. Add more debug messaging to describe why the nfit_test fallback path is taken, ie NULL bus or NULL region. Reported-by: Marc Herbert <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Tested-by: Marc Herbert <[email protected]> Signed-off-by: Alison Schofield <[email protected]> --- Changes in v2: - Clarify which ACPI resource was not found, bus or region (MarcH) - Update commit message and log - Remove Closes tag (MarcH) test/pmem_namespaces.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c index 4bafff5164c8..6411e58ed5fd 100644 --- a/test/pmem_namespaces.c +++ b/test/pmem_namespaces.c @@ -178,20 +178,24 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test, ndctl_set_log_priority(ctx, log_level); + /* Try to use ACPI resource first, then nfit_test */ bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT"); - if (bus) { - /* skip this bus if no label-enabled PMEM regions */ + if (bus) ndctl_region_foreach(bus, region) if (ndctl_region_get_nstype(region) == ND_DEVICE_NAMESPACE_PMEM) break; - if (!region) - bus = NULL; + + if (!bus) + fprintf(stderr, "ACPI.NFIT: bus not found\n"); + else if (!region) { + fprintf(stderr, "ACPI.NFIT: no PMEM region found\n"); + bus = NULL; } if (!bus) { fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n"); - rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test); + rc = ndctl_test_init(&kmod_ctx, &mod, ctx, log_level, test); ndctl_invalidate(ctx); bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0"); if (rc < 0 || !bus) { -- 2.37.3
