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 <[email protected]>
---
 test/multi-pmem.c |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

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;

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to