diff mbox

[ndctl] test, multi-pmem: check namespace deletion

Message ID 148427309710.29210.6139502982382358673.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Williams Jan. 13, 2017, 2:04 a.m. UTC
The initial implementation of multi-pmem support neglected to enable
deletion of pmem namespaces. Add a test to check for this condition.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/multi-pmem.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox

Patch

diff --git a/test/multi-pmem.c b/test/multi-pmem.c
index 8f76e02d2fd1..dd1269ced667 100644
--- a/test/multi-pmem.c
+++ b/test/multi-pmem.c
@@ -54,6 +54,28 @@  static void destroy_namespace(struct ndctl_namespace *ndns)
 	cmd_destroy_namespace(argc, argv, ctx);
 }
 
+/* Check that the namespace device is gone (if it wasn't the seed) */
+static int check_deleted(struct ndctl_region *region, const char *devname,
+		struct ndctl_test *test)
+{
+	struct ndctl_namespace *ndns;
+
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 10, 0)))
+		return 0;
+
+	ndctl_namespace_foreach(region, ndns) {
+		if (strcmp(devname, ndctl_namespace_get_devname(ndns)))
+			continue;
+		if (ndns == ndctl_region_get_namespace_seed(region))
+			continue;
+		fprintf(stderr, "mult-pmem: expected %s to be deleted\n",
+				devname);
+		return -ENXIO;
+	}
+
+	return 0;
+}
+
 static int do_multi_pmem(struct ndctl_ctx *ctx, struct ndctl_test *test)
 {
 	int i;
@@ -190,6 +212,9 @@  static int do_multi_pmem(struct ndctl_ctx *ctx, struct ndctl_test *test)
 					devname, blk_avail, blk_avail_orig);
 			return -ENXIO;
 		}
+
+		if (check_deleted(target, devname, test) != 0)
+			return -ENXIO;
 	}
 
 	ndns = namespaces[NUM_NAMESPACES - 1];
@@ -204,6 +229,9 @@  static int do_multi_pmem(struct ndctl_ctx *ctx, struct ndctl_test *test)
 		return -ENXIO;
 	}
 
+	if (check_deleted(target, devname, test) != 0)
+		return -ENXIO;
+
 	ndctl_bus_foreach(ctx, bus) {
 		if (strncmp(ndctl_bus_get_provider(bus), "nfit_test", 9) != 0)
 			continue;