@@ -29,7 +29,8 @@ void builtin_xaction_namespace_reset(void);
struct kmod_ctx;
struct kmod_module;
int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
- int log_level, struct ndctl_test *test);
+ struct ndctl_ctx *nd_ctx, int log_level,
+ struct ndctl_test *test);
struct ndctl_ctx;
int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx);
@@ -239,7 +239,7 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test,
if (!bus) {
fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
- rc = nfit_test_init(&kmod_ctx, &mod, log_level, test);
+ rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
ndctl_invalidate(ctx);
bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
if (rc < 0 || !bus) {
@@ -20,6 +20,7 @@
#include <util/log.h>
#include <util/sysfs.h>
+#include <ndctl/libndctl.h>
#include <ccan/array_size/array_size.h>
#define KVER_STRLEN 20
@@ -116,11 +117,13 @@ int ndctl_test_get_skipped(struct ndctl_test *test)
}
int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
- int log_level, struct ndctl_test *test)
+ struct ndctl_ctx *nd_ctx, int log_level,
+ struct ndctl_test *test)
{
int rc;
unsigned int i;
const char *name;
+ struct ndctl_bus *bus;
struct log_ctx log_ctx;
const char *list[] = {
"nfit",
@@ -219,6 +222,26 @@ retry:
return rc;
}
+ if (nd_ctx) {
+ /* caller wants a full nfit_test reset */
+ ndctl_bus_foreach(nd_ctx, bus) {
+ struct ndctl_region *region;
+
+ if (strncmp(ndctl_bus_get_provider(bus),
+ "nfit_test", 9) != 0)
+ continue;
+ ndctl_region_foreach(bus, region)
+ ndctl_region_disable_invalidate(region);
+ }
+
+ rc = kmod_module_remove_module(*mod, 0);
+ if (rc < 0 && rc != -ENOENT) {
+ kmod_unref(*ctx);
+ return rc;
+ }
+ ndctl_invalidate(nd_ctx);
+ }
+
rc = kmod_module_probe_insert_module(*mod, KMOD_PROBE_APPLY_BLACKLIST,
NULL, NULL, NULL, NULL);
if (rc)
@@ -287,7 +287,7 @@ int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
return 77;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, loglevel, test);
+ err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
@@ -167,7 +167,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
int result = EXIT_FAILURE, err;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, loglevel, test);
+ err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
result = 77;
ndctl_test_skip(test);
@@ -2567,7 +2567,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
daxctl_set_log_priority(daxctl_ctx, loglevel);
ndctl_set_private_data(ctx, test);
- err = nfit_test_init(&kmod_ctx, &mod, loglevel, test);
+ err = nfit_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
@@ -260,7 +260,7 @@ int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, loglevel, test);
+ err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
result = 77;
ndctl_test_skip(test);
@@ -229,7 +229,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ct
return 77;
ndctl_set_log_priority(ctx, loglevel);
- err = nfit_test_init(&kmod_ctx, &mod, loglevel, test);
+ err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
if (err < 0) {
ndctl_test_skip(test);
fprintf(stderr, "nfit_test unavailable skipping tests\n");
@@ -203,7 +203,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
if (!bus) {
fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
- rc = nfit_test_init(&kmod_ctx, &mod, log_level, test);
+ rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
ndctl_invalidate(ctx);
bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
if (rc < 0 || !bus) {
In preparation for tests that write smart threshold and injected-smart values arrange for nfit_test to be completely reloaded for each test run. I.e. it is no longer sufficient to just clear label data and reset regions. Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- test.h | 3 ++- test/blk_namespaces.c | 2 +- test/core.c | 25 ++++++++++++++++++++++++- test/dpa-alloc.c | 2 +- test/dsm-fail.c | 2 +- test/libndctl.c | 2 +- test/multi-pmem.c | 2 +- test/parent-uuid.c | 2 +- test/pmem_namespaces.c | 2 +- 9 files changed, 33 insertions(+), 9 deletions(-)