@@ -23,6 +23,8 @@ struct kmod_module;
int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx, int log_level,
struct ndctl_test *test);
+int ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod,
+ struct ndctl_ctx *nd_ctx);
struct ndctl_ctx;
int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
@@ -109,9 +109,9 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test,
}
result = do_test(ctx, test);
- kmod_module_remove_module(mod, 0);
- kmod_unref(kmod_ctx);
+ ndctl_test_module_remove(&kmod_ctx, &mod, ctx);
+
return result;
}
@@ -107,6 +107,34 @@ int ndctl_test_get_skipped(struct ndctl_test *test)
return test->skip;
}
+void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod,
+ struct ndctl_ctx *nd_ctx)
+{
+ struct ndctl_bus *bus;
+ int rc;
+
+ ndctl_bus_foreach(nd_ctx, bus) {
+ struct ndctl_region *region;
+
+ if ((strcmp(ndctl_bus_get_provider(bus),
+ "nfit_test.0") != 0) &&
+ strcmp(ndctl_bus_get_provider(bus),
+ "nfit_test.1") != 0)
+ continue;
+
+ ndctl_region_foreach(bus, region)
+ ndctl_region_disable_invalidate(region);
+ }
+
+ rc = kmod_module_remove_module(*mod, 0);
+ if (rc < 0 && rc != -ENOENT) {
+ fprintf(stderr, "couldn't remove module %s\n",
+ strerror(-rc));
+ }
+
+ kmod_unref(*ctx);
+}
+
int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
struct ndctl_ctx *nd_ctx, int log_level,
struct ndctl_test *test)
@@ -356,9 +356,9 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
}
result = do_test(ctx, test);
- kmod_module_remove_module(mod, 0);
- kmod_unref(kmod_ctx);
+ ndctl_test_module_remove(&kmod_ctx, &mod, ctx);
+
return result;
}
@@ -2612,8 +2612,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
if (i >= ARRAY_SIZE(do_test))
result = EXIT_SUCCESS;
- kmod_module_remove_module(mod, 0);
- kmod_unref(kmod_ctx);
+ ndctl_test_module_remove(&kmod_ctx, &mod, ctx);
return result;
}
@@ -198,7 +198,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
rc = 77;
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
- goto err_module;
+ goto exit;
}
}
@@ -214,7 +214,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
if (rc < 0) {
fprintf(stderr, "failed to zero %s\n",
ndctl_dimm_get_devname(dimm));
- goto err;
+ goto exit;
}
}
@@ -228,14 +228,14 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
if (!pmem_region || ndctl_region_enable(pmem_region) < 0) {
fprintf(stderr, "%s: failed to find PMEM region\n", comm);
rc = -ENODEV;
- goto err;
+ goto exit;
}
rc = -ENODEV;
ndns = create_pmem_namespace(pmem_region);
if (!ndns) {
fprintf(stderr, "%s: failed to create PMEM namespace\n", comm);
- goto err;
+ goto exit;
}
sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns));
@@ -243,20 +243,9 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
disable_pmem_namespace(ndns);
- err:
- /* unload nfit_test */
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
- if (bus)
- ndctl_region_foreach(bus, region)
- ndctl_region_disable_invalidate(region);
- bus = ndctl_bus_get_by_provider(ctx, "nfit_test.1");
- if (bus)
- ndctl_region_foreach(bus, region)
- ndctl_region_disable_invalidate(region);
- kmod_module_remove_module(mod, 0);
+ exit:
+ ndctl_test_module_remove(&kmod_ctx, &mod, ctx);
- err_module:
- kmod_unref(kmod_ctx);
return rc;
}
The kmod_module_remove_module() called by the tests without disabling the regions from the test provider. So, the module remove fails during many of the tests. The patch writes a wrapper which properly disables the test provider specific regions before calling the kmod_module_remove_module(). Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> --- test.h | 2 ++ test/ack-shutdown-count-set.c | 4 ++-- test/core.c | 28 ++++++++++++++++++++++++++++ test/dsm-fail.c | 4 ++-- test/libndctl.c | 3 +-- test/pmem_namespaces.c | 23 ++++++----------------- 6 files changed, 41 insertions(+), 23 deletions(-)