All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates
@ 2016-03-17  0:54 Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 1/5] ndctl: update pkg-config description Dan Williams
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

After discovering a segfault in test/blk-ns (fixed in patch 2) it became
clear that these tests could stand to have some more exposure.  These
updates make the tests fallback to nfit_test resources when run on a
platform that lacks an ACPI.NFIT.


---

Dan Williams (5):
      ndctl: update pkg-config description
      ndctl: fix blk-ns test cleanup
      Revert "ndctl: fix error handling in ND_BLK & PMEM tests"
      ndctl: convert 'ndctl bat' to use struct ndctl_test
      ndctl: fall back to nfit_test for test/{blk|pmem}-ns


 Makefile.am            |   12 ++--
 builtin-bat.c          |   27 +++++++--
 lib/libndctl.pc.in     |    2 -
 test.h                 |    6 +-
 test/blk_namespaces.c  |  149 +++++++++++++++++++++++++++++++-----------------
 test/pcommit.c         |   19 +++++-
 test/pmem_namespaces.c |  124 ++++++++++++++++++++++++++++------------
 7 files changed, 232 insertions(+), 107 deletions(-)
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [ndctl PATCH 1/5] ndctl: update pkg-config description
  2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
@ 2016-03-17  0:54 ` Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 2/5] ndctl: fix blk-ns test cleanup Dan Williams
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

Use the same description as rpmspec file which references "libnvdimm"
instead of "nd".

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 lib/libndctl.pc.in |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libndctl.pc.in b/lib/libndctl.pc.in
index a8ac4b799fdc..2af9ad18a6fc 100644
--- a/lib/libndctl.pc.in
+++ b/lib/libndctl.pc.in
@@ -4,7 +4,7 @@ libdir=@libdir@
 includedir=@includedir@
 
 Name: libndctl
-Description: Device discovery and manipulation for the "nd" subsystem
+Description: Manage "libnvdimm" subsystem devices (Non-volatile Memory)
 Version: @VERSION@
 Libs: -L${libdir} -lndctl
 Libs.private:

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [ndctl PATCH 2/5] ndctl: fix blk-ns test cleanup
  2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 1/5] ndctl: update pkg-config description Dan Williams
@ 2016-03-17  0:54 ` Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 3/5] Revert "ndctl: fix error handling in ND_BLK & PMEM tests" Dan Williams
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

ndctl_namespace_foreach_safe() needs to be used when a namespace is
deleted while iterating.  Otherwise, we can walk off into uninitialized
memory and segfault.

Reported-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/blk_namespaces.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index 968af2797feb..41c5ce0b1bd7 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -214,7 +214,7 @@ int test_blk_namespaces(int log_level)
 	char bdev[50];
 	struct ndctl_ctx *ctx;
 	struct ndctl_bus *bus;
-	struct ndctl_namespace *ndns[2];
+	struct ndctl_namespace *ndns[2], *_n;
 	struct ndctl_region *region, *blk_region = NULL;
 	struct ndctl_dimm *dimm;
 
@@ -307,7 +307,7 @@ int test_blk_namespaces(int log_level)
 
  err_cleanup:
 	if (blk_region) {
-		ndctl_namespace_foreach(blk_region, ndns[0])
+		ndctl_namespace_foreach_safe(blk_region, ndns[0], _n)
 			if (ndctl_namespace_get_size(ndns[0]) != 0)
 				disable_blk_namespace(ndns[0]);
 	}

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [ndctl PATCH 3/5] Revert "ndctl: fix error handling in ND_BLK & PMEM tests"
  2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 1/5] ndctl: update pkg-config description Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 2/5] ndctl: fix blk-ns test cleanup Dan Williams
@ 2016-03-17  0:54 ` Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 4/5] ndctl: convert 'ndctl bat' to use struct ndctl_test Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns Dan Williams
  4 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

This reverts commit 289f98097a25abd71fac7d8324e89abb4abfb19d.

For pass/fail we only care about these routines returning non-zero.  The
current opportunistic conversion of negative libndctl return values runs
the risk of a -EBADFD causing a false positive "skip test" indication.
It also makes these tests follow the same error reporting scheme as the
other tests.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/blk_namespaces.c  |   77 +++++++++++++++++++++++++-----------------------
 test/pmem_namespaces.c |   46 +++++++++++++++--------------
 2 files changed, 64 insertions(+), 59 deletions(-)

diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index 41c5ce0b1bd7..f3e7a5592e2a 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -82,21 +82,22 @@ static struct ndctl_namespace *create_blk_namespace(int region_fraction,
 static int disable_blk_namespace(struct ndctl_namespace *ndns)
 {
 	if (ndctl_namespace_disable_invalidate(ndns) < 0)
-		return ENODEV;
+		return -ENODEV;
 
 	if (ndctl_namespace_delete(ndns) < 0)
-		return ENODEV;
+		return -ENODEV;
 
 	return 0;
 }
 
 static int ns_do_io(const char *bdev)
 {
+	int fd, i;
+	int rc = 0;
 	const int page_size = 4096;
 	const int num_pages = 4;
 	unsigned long num_dev_pages, num_blocks;
 	off_t addr;
-	int fd, i, rc;
 
 	void *random_page[num_pages];
 	void *blk_page[num_pages];
@@ -120,13 +121,13 @@ static int ns_do_io(const char *bdev)
 
 	/* read random data into random_page */
 	if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
-		rc = errno;
 		err("open");
+		rc = -ENODEV;
 		goto err_free_all;
 	}
 
-	if (read(fd, random_page[0], page_size * num_pages) < 0) {
-		rc = errno;
+	rc = read(fd, random_page[0], page_size * num_pages);
+	if (rc < 0) {
 		err("read");
 		close(fd);
 		goto err_free_all;
@@ -134,10 +135,9 @@ static int ns_do_io(const char *bdev)
 
 	close(fd);
 
-	/* figure out our dev size */
 	if ((fd = open(bdev, O_RDWR|O_DIRECT)) < 0) {
-		rc = errno;
 		err("open");
+		rc = -ENODEV;
 		goto err_free_all;
 	}
 
@@ -145,48 +145,45 @@ static int ns_do_io(const char *bdev)
 	num_dev_pages = num_blocks / 8;
 
 	/* write the random data out to each of the segments */
-	if (pwrite(fd, random_page[0], page_size, 0) < 0) {
-		rc = errno;
+	rc = pwrite(fd, random_page[0], page_size, 0);
+	if (rc < 0) {
 		err("write");
 		goto err_close;
 	}
 
 	/* two pages that span the region discontinuity */
 	addr = page_size * (num_dev_pages/2 - 1);
-
-	if (pwrite(fd, random_page[1], page_size*2, addr) < 0) {
-		rc = errno;
+	rc = pwrite(fd, random_page[1], page_size*2, addr);
+	if (rc < 0) {
 		err("write");
 		goto err_close;
 	}
 
 	addr = page_size * (num_dev_pages - 1);
-
-	if (pwrite(fd, random_page[3], page_size, addr) < 0) {
-		rc = errno;
+	rc = pwrite(fd, random_page[3], page_size, addr);
+	if (rc < 0) {
 		err("write");
 		goto err_close;
 	}
 
 	/* read back the random data into blk_page */
-	if (pread(fd, blk_page[0], page_size, 0) < 0) {
-		rc = errno;
+	rc = pread(fd, blk_page[0], page_size, 0);
+	if (rc < 0) {
 		err("read");
 		goto err_close;
 	}
 
 	/* two pages that span the region discontinuity */
 	addr = page_size * (num_dev_pages/2 - 1);
-	if (pread(fd, blk_page[1], page_size*2, addr) < 0) {
-		rc = errno;
+	rc = pread(fd, blk_page[1], page_size*2, addr);
+	if (rc < 0) {
 		err("read");
 		goto err_close;
 	}
 
 	addr = page_size * (num_dev_pages - 1);
-
-	if (pread(fd, blk_page[3], page_size, addr) < 0) {
-		rc = errno;
+	rc = pread(fd, blk_page[3], page_size, addr);
+	if (rc < 0) {
 		err("read");
 		goto err_close;
 	}
@@ -194,9 +191,11 @@ static int ns_do_io(const char *bdev)
 	/* verify the data */
 	if (memcmp(random_page[0], blk_page[0], page_size * num_pages)) {
 		fprintf(stderr, "Block data miscompare\n");
-		rc = EIO;
+		rc = -EIO;
+		goto err_close;
 	}
 
+	rc = 0;
  err_close:
 	close(fd);
  err_free_all:
@@ -218,8 +217,8 @@ int test_blk_namespaces(int log_level)
 	struct ndctl_region *region, *blk_region = NULL;
 	struct ndctl_dimm *dimm;
 
-	rc = -ndctl_new(&ctx);
-	if (rc)
+	rc = ndctl_new(&ctx);
+	if (rc < 0)
 		return rc;
 
 	ndctl_set_log_priority(ctx, log_level);
@@ -229,17 +228,18 @@ int test_blk_namespaces(int log_level)
 		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
 		rc = 77;
 		goto err_nobus;
-	} else
+	} else {
 		fprintf(stderr, "%s: found provider: %s\n", comm,
 				ndctl_bus_get_provider(bus));
+	}
 
 	/* get the system to a clean state */
         ndctl_region_foreach(bus, region)
                 ndctl_region_disable_invalidate(region);
 
         ndctl_dimm_foreach(bus, dimm) {
-                rc = -ndctl_dimm_zero_labels(dimm);
-                if (rc) {
+                rc = ndctl_dimm_zero_labels(dimm);
+                if (rc < 0) {
                         fprintf(stderr, "failed to zero %s\n",
                                         ndctl_dimm_get_devname(dimm));
                         return rc;
@@ -253,12 +253,13 @@ int test_blk_namespaces(int log_level)
 			break;
 		}
 
-	rc = ENODEV;
 	if (!blk_region || ndctl_region_enable(blk_region) < 0) {
 		fprintf(stderr, "%s: failed to find block region\n", comm);
+		rc = -ENODEV;
 		goto err_cleanup;
 	}
 
+	rc = -ENODEV;
 	ndns[0] = create_blk_namespace(4, blk_region);
 	if (!ndns[0]) {
 		fprintf(stderr, "%s: failed to create block namespace\n", comm);
@@ -272,7 +273,7 @@ int test_blk_namespaces(int log_level)
 	}
 
 	rc = disable_blk_namespace(ndns[0]);
-	if (rc) {
+	if (rc < 0) {
 		fprintf(stderr, "%s: failed to disable block namespace\n", comm);
 		goto err_cleanup;
 	}
@@ -280,30 +281,32 @@ int test_blk_namespaces(int log_level)
 	ndns[0] = create_blk_namespace(2, blk_region);
 	if (!ndns[0]) {
 		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		rc = ENODEV;
+		rc = -ENODEV;
 		goto err_cleanup;
 	}
 
 	rc = disable_blk_namespace(ndns[1]);
-	if (rc) {
+	if (rc < 0) {
 		fprintf(stderr, "%s: failed to disable block namespace\n", comm);
 		goto err_cleanup;
 	}
 
+	rc = -ENODEV;
 	ndns[1] = create_blk_namespace(2, blk_region);
 	if (!ndns[1]) {
 		fprintf(stderr, "%s: failed to create block namespace\n", comm);
-		rc = ENODEV;
 		goto err_cleanup;
 	}
 
 	/* okay, all set up, do some I/O */
+	rc = -EIO;
 	sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[0]));
-	rc = ns_do_io(bdev);
-	if (rc)
+	if (ns_do_io(bdev))
 		goto err_cleanup;
 	sprintf(bdev, "/dev/%s", ndctl_namespace_get_block_device(ndns[1]));
-	rc = ns_do_io(bdev);
+	if (ns_do_io(bdev))
+		goto err_cleanup;
+	rc = 0;
 
  err_cleanup:
 	if (blk_region) {
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
index 17c301947fa4..24f307df0c81 100644
--- a/test/pmem_namespaces.c
+++ b/test/pmem_namespaces.c
@@ -60,10 +60,10 @@ static struct ndctl_namespace *create_pmem_namespace(struct ndctl_region *region
 static int disable_pmem_namespace(struct ndctl_namespace *ndns)
 {
 	if (ndctl_namespace_disable_invalidate(ndns) < 0)
-		return ENODEV;
+		return -ENODEV;
 
 	if (ndctl_namespace_delete(ndns) < 0)
-		return ENODEV;
+		return -ENODEV;
 
 	return 0;
 }
@@ -73,8 +73,9 @@ static int ns_do_io(const char *bdev)
 	unsigned long num_dev_pages, num_blocks;
 	const int page_size = 4096;
 	const int num_pages = 2;
-	int fd, i, rc;
 	off_t addr;
+	int rc = 0;
+	int fd, i;
 
 	void *random_page[num_pages];
 	void *pmem_page[num_pages];
@@ -98,13 +99,13 @@ static int ns_do_io(const char *bdev)
 
 	/* read random data into random_page */
 	if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
-		rc = errno;
 		err("open");
+		rc = -ENODEV;
 		goto err_free_all;
 	}
 
-	if (read(fd, random_page[0], page_size * num_pages) < 0) {
-		rc = errno;
+	rc = read(fd, random_page[0], page_size * num_pages);
+	if (rc < 0) {
 		err("read");
 		close(fd);
 		goto err_free_all;
@@ -114,8 +115,8 @@ static int ns_do_io(const char *bdev)
 
 	/* figure out our dev size */
 	if ((fd = open(bdev, O_RDWR|O_DIRECT)) < 0) {
-		rc = errno;
 		err("open");
+		rc = -ENODEV;
 		goto err_free_all;
 	}
 
@@ -123,29 +124,29 @@ static int ns_do_io(const char *bdev)
 	num_dev_pages = num_blocks / 8;
 
 	/* write the random data out to each of the segments */
-	if (pwrite(fd, random_page[0], page_size, 0) < 0) {
-		rc = errno;
+	rc = pwrite(fd, random_page[0], page_size, 0);
+	if (rc < 0) {
 		err("write");
 		goto err_close;
 	}
 
 	addr = page_size * (num_dev_pages - 1);
-	if (pwrite(fd, random_page[1], page_size, addr) < 0) {
-		rc = errno;
+	rc = pwrite(fd, random_page[1], page_size, addr);
+	if (rc < 0) {
 		err("write");
 		goto err_close;
 	}
 
 	/* read back the random data into pmem_page */
-	if (pread(fd, pmem_page[0], page_size, 0) < 0) {
-		rc = errno;
+	rc = pread(fd, pmem_page[0], page_size, 0);
+	if (rc < 0) {
 		err("read");
 		goto err_close;
 	}
 
 	addr = page_size * (num_dev_pages - 1);
-	if (pread(fd, pmem_page[1], page_size, addr) < 0) {
-		rc = errno;
+	rc = pread(fd, pmem_page[1], page_size, addr);
+	if (rc < 0) {
 		err("read");
 		goto err_close;
 	}
@@ -153,10 +154,11 @@ static int ns_do_io(const char *bdev)
 	/* verify the data */
 	if (memcmp(random_page[0], pmem_page[0], page_size * num_pages)) {
 		fprintf(stderr, "PMEM data miscompare\n");
-		rc = EIO;
+		rc = -EIO;
 		goto err_close;
 	}
 
+	rc = 0;
  err_close:
 	close(fd);
  err_free_all:
@@ -178,8 +180,8 @@ int test_pmem_namespaces(int log_level)
 	char bdev[50];
 	int rc;
 
-	rc = -ndctl_new(&ctx);
-	if (rc)
+	rc = ndctl_new(&ctx);
+	if (rc < 0)
 		return rc;
 
 	ndctl_set_log_priority(ctx, log_level);
@@ -198,8 +200,8 @@ int test_pmem_namespaces(int log_level)
                 ndctl_region_disable_invalidate(region);
 
         ndctl_dimm_foreach(bus, dimm) {
-                rc = -ndctl_dimm_zero_labels(dimm);
-                if (rc) {
+                rc = ndctl_dimm_zero_labels(dimm);
+                if (rc < 0) {
                         fprintf(stderr, "failed to zero %s\n",
                                         ndctl_dimm_get_devname(dimm));
                         return rc;
@@ -215,14 +217,14 @@ int test_pmem_namespaces(int log_level)
 
 	if (!pmem_region || ndctl_region_enable(pmem_region) < 0) {
 		fprintf(stderr, "%s: failed to find PMEM region\n", comm);
-		rc = ENODEV;
+		rc = -ENODEV;
 		goto err;
 	}
 
+	rc = -ENODEV;
 	ndns = create_pmem_namespace(pmem_region);
 	if (!ndns) {
 		fprintf(stderr, "%s: failed to create PMEM namespace\n", comm);
-		rc = ENODEV;
 		goto err;
 	}
 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [ndctl PATCH 4/5] ndctl: convert 'ndctl bat' to use struct ndctl_test
  2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
                   ` (2 preceding siblings ...)
  2016-03-17  0:54 ` [ndctl PATCH 3/5] Revert "ndctl: fix error handling in ND_BLK & PMEM tests" Dan Williams
@ 2016-03-17  0:54 ` Dan Williams
  2016-03-17  0:54 ` [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns Dan Williams
  4 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

This gives the bat test the ability to skip tests based on kernel
version and report test results in the same format as 'ndctl test'.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 Makefile.am            |   12 ++++++------
 builtin-bat.c          |   27 +++++++++++++++++++++------
 test.h                 |    6 +++---
 test/blk_namespaces.c  |   18 ++++++++++++++++--
 test/pcommit.c         |   19 ++++++++++++++++---
 test/pmem_namespaces.c |   18 ++++++++++++++++--
 6 files changed, 78 insertions(+), 22 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 84582771e97d..eaf544a96284 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,13 +97,13 @@ ndctl_SOURCES = ndctl.c \
 		util/size.c \
 		util/strbuf.c \
 		util/wrapper.c \
-		util/filter.c
+		util/filter.c \
+		test/core.c
 
 if ENABLE_TEST
 ndctl_SOURCES += test/libndctl.c \
 		 test/dpa-alloc.c \
-		 test/parent-uuid.c \
-		 test/core.c
+		 test/parent-uuid.c
 endif
 
 if ENABLE_DESTRUCTIVE
@@ -158,13 +158,13 @@ endif
 test_libndctl_SOURCES = test/libndctl.c test/core.c
 test_libndctl_LDADD = lib/libndctl.la $(UUID_LIBS) $(KMOD_LIBS)
 
-test_pcommit_SOURCES = test/pcommit.c
+test_pcommit_SOURCES = test/pcommit.c test/core.c
 test_pcommit_LDADD = lib/libndctl.la $(KMOD_LIBS)
 
-test_blk_ns_SOURCES = test/blk_namespaces.c
+test_blk_ns_SOURCES = test/blk_namespaces.c test/core.c
 test_blk_ns_LDADD = lib/libndctl.la $(KMOD_LIBS)
 
-test_pmem_ns_SOURCES = test/pmem_namespaces.c
+test_pmem_ns_SOURCES = test/pmem_namespaces.c test/core.c
 test_pmem_ns_LDADD = lib/libndctl.la $(KMOD_LIBS)
 
 test_dpa_alloc_SOURCES = test/dpa-alloc.c test/core.c
diff --git a/builtin-bat.c b/builtin-bat.c
index 14ef08b756b1..ca6fd121f3a7 100644
--- a/builtin-bat.c
+++ b/builtin-bat.c
@@ -1,11 +1,14 @@
 #include <stdio.h>
 #include <syslog.h>
 #include <test.h>
+#include <limits.h>
 #include <util/parse-options.h>
 
 int cmd_bat(int argc, const char **argv)
 {
 	int loglevel = LOG_DEBUG, i, rc;
+	struct ndctl_test *test;
+	bool force = false;
 	const char * const u[] = {
 		"ndctl bat [<options>]",
 		NULL
@@ -13,6 +16,8 @@ int cmd_bat(int argc, const char **argv)
 	const struct option options[] = {
 	OPT_INTEGER('l', "loglevel", &loglevel,
 		"set the log level (default LOG_DEBUG)"),
+	OPT_BOOLEAN('f', "force", &force,
+		"force run all tests regardless of required kernel"),
 	OPT_END(),
 	};
 
@@ -24,17 +29,27 @@ int cmd_bat(int argc, const char **argv)
 	if (argc)
 		usage_with_options(u, options);
 
-	rc = test_pcommit();
+	if (force)
+		test = ndctl_test_new(UINT_MAX);
+	else
+		test = ndctl_test_new(0);
+
+	if (!test) {
+		fprintf(stderr, "failed to initialize test\n");
+		return EXIT_FAILURE;
+	}
+
+	rc = test_pcommit(test);
 	fprintf(stderr, "test_pcommit: %s\n", rc ? "FAIL" : "PASS");
-	if (rc)
+	if (rc && rc != 77)
 		return rc;
 
-	rc = test_blk_namespaces(loglevel);
+	rc = test_blk_namespaces(loglevel, test);
 	fprintf(stderr, "test_blk_namespaces: %s\n", rc ? "FAIL" : "PASS");
-	if (rc)
+	if (rc && rc != 77)
 		return rc;
 
-	rc = test_pmem_namespaces(loglevel);
+	rc = test_pmem_namespaces(loglevel, test);
 	fprintf(stderr, "test_pmem_namespaces: %s\n", rc ? "FAIL" : "PASS");
-	return rc;
+	return ndctl_test_result(test, rc);
 }
diff --git a/test.h b/test.h
index d58dc8874dda..61ca05f489fa 100644
--- a/test.h
+++ b/test.h
@@ -16,7 +16,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test);
 int test_direct_io(int loglevel, struct ndctl_test *test);
 int test_dpa_alloc(int loglevel, struct ndctl_test *test);
 int test_libndctl(int loglevel, struct ndctl_test *test);
-int test_blk_namespaces(int loglevel);
-int test_pmem_namespaces(int loglevel);
-int test_pcommit(void);
+int test_blk_namespaces(int loglevel, struct ndctl_test *test);
+int test_pmem_namespaces(int loglevel, struct ndctl_test *test);
+int test_pcommit(struct ndctl_test *test);
 #endif /* __TEST_H__ */
diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index f3e7a5592e2a..db30a1fe567c 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
+#include <linux/version.h>
 #include <test.h>
 
 /* The purpose of this test is to verify that we can successfully do I/O to
@@ -207,7 +208,7 @@ static int ns_do_io(const char *bdev)
 
 static const char *comm = "test-blk-namespaces";
 
-int test_blk_namespaces(int log_level)
+int test_blk_namespaces(int log_level, struct ndctl_test *test)
 {
 	int rc;
 	char bdev[50];
@@ -217,6 +218,9 @@ int test_blk_namespaces(int log_level)
 	struct ndctl_region *region, *blk_region = NULL;
 	struct ndctl_dimm *dimm;
 
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
+		return 77;
+
 	rc = ndctl_new(&ctx);
 	if (rc < 0)
 		return rc;
@@ -226,6 +230,7 @@ int test_blk_namespaces(int log_level)
 	bus = ndctl_bus_get_by_provider(ctx, provider);
 	if (!bus) {
 		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
+		ndctl_test_skip(test);
 		rc = 77;
 		goto err_nobus;
 	} else {
@@ -323,6 +328,15 @@ int test_blk_namespaces(int log_level)
 
 int __attribute__((weak)) main(int argc, char *argv[])
 {
+	struct ndctl_test *test = ndctl_test_new(0);
+	int rc;
+
 	comm = argv[0];
-	return test_blk_namespaces(LOG_DEBUG);
+	if (!test) {
+		fprintf(stderr, "failed to initialize test\n");
+		return EXIT_FAILURE;
+	}
+
+	rc = test_blk_namespaces(LOG_DEBUG, test);
+	return ndctl_test_result(test, rc);
 }
diff --git a/test/pcommit.c b/test/pcommit.c
index 3ef09a5074a4..ea5e82f3773d 100644
--- a/test/pcommit.c
+++ b/test/pcommit.c
@@ -16,11 +16,13 @@
 #include <stdio.h>
 #include <string.h>
 #include <test.h>
+#include <stdlib.h>
+#include <linux/version.h>
 
 #define err(msg)\
 	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
 
-int test_pcommit(void)
+int test_pcommit(struct ndctl_test *test)
 {
 	const char *pcommit = "pcommit";
 	const char *flags = "flags";
@@ -30,10 +32,13 @@ int test_pcommit(void)
 	FILE *cpuinfo;
 	char *token;
 
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 0, 0)))
+		return 77;
+
 	cpuinfo = fopen("/proc/cpuinfo", "r");
 	if (!cpuinfo) {
 		err("open");
-		return EBADF;
+		return -ENXIO;
 	}
 
         while (fgets(buffer, buffer_size, cpuinfo)) {
@@ -54,10 +59,18 @@ int test_pcommit(void)
         }
 
 	fclose(cpuinfo);
+	ndctl_test_skip(test);
 	return 77;
 }
 
 int __attribute__((weak)) main(int argc, char *argv[])
 {
-	return test_pcommit();
+	struct ndctl_test *test = ndctl_test_new(0);
+
+	if (!test) {
+		fprintf(stderr, "failed to initialize test\n");
+		return EXIT_FAILURE;
+	}
+
+	return test_pcommit(test);
 }
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
index 24f307df0c81..f7dfce618c1a 100644
--- a/test/pmem_namespaces.c
+++ b/test/pmem_namespaces.c
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
+#include <linux/version.h>
 #include <test.h>
 
 #define err(msg)\
@@ -170,7 +171,7 @@ static int ns_do_io(const char *bdev)
 
 static const char *comm = "test-pmem-namespaces";
 
-int test_pmem_namespaces(int log_level)
+int test_pmem_namespaces(int log_level, struct ndctl_test *test)
 {
 	struct ndctl_region *region, *pmem_region = NULL;
 	struct ndctl_namespace *ndns;
@@ -180,6 +181,9 @@ int test_pmem_namespaces(int log_level)
 	char bdev[50];
 	int rc;
 
+	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
+		return 77;
+
 	rc = ndctl_new(&ctx);
 	if (rc < 0)
 		return rc;
@@ -189,6 +193,7 @@ int test_pmem_namespaces(int log_level)
 	bus = ndctl_bus_get_by_provider(ctx, provider);
 	if (!bus) {
 		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
+		ndctl_test_skip(test);
 		rc = 77;
 		goto err;
 	} else
@@ -240,6 +245,15 @@ int test_pmem_namespaces(int log_level)
 
 int __attribute__((weak)) main(int argc, char *argv[])
 {
+	struct ndctl_test *test = ndctl_test_new(0);
+	int rc;
+
 	comm = argv[0];
-	return test_pmem_namespaces(LOG_DEBUG);
+	if (!test) {
+		fprintf(stderr, "failed to initialize test\n");
+		return EXIT_FAILURE;
+	}
+
+	rc = test_pmem_namespaces(LOG_DEBUG, test);
+	return ndctl_test_result(test, rc);
 }

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns
  2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
                   ` (3 preceding siblings ...)
  2016-03-17  0:54 ` [ndctl PATCH 4/5] ndctl: convert 'ndctl bat' to use struct ndctl_test Dan Williams
@ 2016-03-17  0:54 ` Dan Williams
  2016-03-18 16:24   ` Ross Zwisler
  4 siblings, 1 reply; 8+ messages in thread
From: Dan Williams @ 2016-03-17  0:54 UTC (permalink / raw
  To: linux-nvdimm

Prevent these tests from bitrotting going forward by arranging for them
to be run against nfit_test resources in the case that an ACPI.NFIT
provider is not found.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/blk_namespaces.c  |   56 ++++++++++++++++++++++++++++++++----------
 test/pmem_namespaces.c |   64 ++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 92 insertions(+), 28 deletions(-)

diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
index db30a1fe567c..b4d677b4d0d6 100644
--- a/test/blk_namespaces.c
+++ b/test/blk_namespaces.c
@@ -27,6 +27,7 @@
 #include <uuid/uuid.h>
 #include <linux/version.h>
 #include <test.h>
+#include <libkmod.h>
 
 /* The purpose of this test is to verify that we can successfully do I/O to
  * multiple nd_blk namespaces that have discontiguous segments.  It first
@@ -44,8 +45,6 @@
 #define err(msg)\
 	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
 
-static const char *provider = "ACPI.NFIT";
-
 static struct ndctl_namespace *create_blk_namespace(int region_fraction,
 		struct ndctl_region *region)
 {
@@ -214,9 +213,11 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
 	char bdev[50];
 	struct ndctl_ctx *ctx;
 	struct ndctl_bus *bus;
-	struct ndctl_namespace *ndns[2], *_n;
-	struct ndctl_region *region, *blk_region = NULL;
+	struct kmod_module *mod;
 	struct ndctl_dimm *dimm;
+	struct kmod_ctx *kmod_ctx;
+	struct ndctl_namespace *ndns[2];
+	struct ndctl_region *region, *blk_region = NULL;
 
 	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
 		return 77;
@@ -227,12 +228,33 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
 
 	ndctl_set_log_priority(ctx, log_level);
 
-	bus = ndctl_bus_get_by_provider(ctx, provider);
+	kmod_ctx = kmod_new(NULL, NULL);
+	if (!kmod_ctx)
+		goto err_kmod;
+	kmod_set_log_priority(kmod_ctx, log_level);
+
+	rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod);
+	if (rc < 0)
+		goto err_module;
+
+	rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST,
+			NULL, NULL, NULL, NULL);
+	if (rc < 0) {
+		rc = 77;
+		ndctl_test_skip(test);
+		fprintf(stderr, "nfit_test unavailable skipping tests\n");
+		goto err_module;
+	}
+
+	bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
+	if (!bus)
+		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
+
 	if (!bus) {
 		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
 		ndctl_test_skip(test);
 		rc = 77;
-		goto err_nobus;
+		goto err_cleanup;
 	} else {
 		fprintf(stderr, "%s: found provider: %s\n", comm,
 				ndctl_bus_get_provider(bus));
@@ -314,15 +336,21 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
 	rc = 0;
 
  err_cleanup:
-	if (blk_region) {
-		ndctl_namespace_foreach_safe(blk_region, ndns[0], _n)
-			if (ndctl_namespace_get_size(ndns[0]) != 0)
-				disable_blk_namespace(ndns[0]);
-	}
-
- err_nobus:
+	/* 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);
+
+ err_module:
+	kmod_unref(kmod_ctx);
+ err_kmod:
 	ndctl_unref(ctx);
-
 	return rc;
 }
 
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
index f7dfce618c1a..198f8ef0cb37 100644
--- a/test/pmem_namespaces.c
+++ b/test/pmem_namespaces.c
@@ -25,14 +25,13 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <uuid/uuid.h>
+#include <libkmod.h>
 #include <linux/version.h>
 #include <test.h>
 
 #define err(msg)\
 	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
 
-static const char *provider = "ACPI.NFIT";
-
 static struct ndctl_namespace *create_pmem_namespace(struct ndctl_region *region)
 {
 	struct ndctl_namespace *seed_ns = NULL;
@@ -175,7 +174,9 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
 {
 	struct ndctl_region *region, *pmem_region = NULL;
 	struct ndctl_namespace *ndns;
+	struct kmod_ctx *kmod_ctx;
 	struct ndctl_dimm *dimm;
+	struct kmod_module *mod;
 	struct ndctl_ctx *ctx;
 	struct ndctl_bus *bus;
 	char bdev[50];
@@ -190,7 +191,28 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
 
 	ndctl_set_log_priority(ctx, log_level);
 
-	bus = ndctl_bus_get_by_provider(ctx, provider);
+	kmod_ctx = kmod_new(NULL, NULL);
+	if (!kmod_ctx)
+		goto err_kmod;
+	kmod_set_log_priority(kmod_ctx, log_level);
+
+	rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod);
+	if (rc < 0)
+		goto err_module;
+
+	rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST,
+			NULL, NULL, NULL, NULL);
+	if (rc < 0) {
+		rc = 77;
+		ndctl_test_skip(test);
+		fprintf(stderr, "nfit_test unavailable skipping tests\n");
+		goto err_module;
+	}
+
+	bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
+	if (!bus)
+		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
+
 	if (!bus) {
 		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
 		ndctl_test_skip(test);
@@ -202,16 +224,16 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
 
 	/* get the system to a clean state */
         ndctl_region_foreach(bus, region)
-                ndctl_region_disable_invalidate(region);
-
-        ndctl_dimm_foreach(bus, dimm) {
-                rc = ndctl_dimm_zero_labels(dimm);
-                if (rc < 0) {
-                        fprintf(stderr, "failed to zero %s\n",
-                                        ndctl_dimm_get_devname(dimm));
-                        return rc;
-                }
-        }
+		ndctl_region_disable_invalidate(region);
+
+	ndctl_dimm_foreach(bus, dimm) {
+		rc = ndctl_dimm_zero_labels(dimm);
+		if (rc < 0) {
+			fprintf(stderr, "failed to zero %s\n",
+					ndctl_dimm_get_devname(dimm));
+			goto err;
+		}
+	}
 
 	/* create our config */
 	ndctl_region_foreach(bus, region)
@@ -237,9 +259,23 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
 	rc = ns_do_io(bdev);
 
 	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);
+
+ err_module:
+	kmod_unref(kmod_ctx);
+ err_kmod:
 	ndctl_unref(ctx);
-
 	return rc;
 }
 

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns
  2016-03-17  0:54 ` [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns Dan Williams
@ 2016-03-18 16:24   ` Ross Zwisler
  2016-03-18 16:48     ` Dan Williams
  0 siblings, 1 reply; 8+ messages in thread
From: Ross Zwisler @ 2016-03-18 16:24 UTC (permalink / raw
  To: Dan Williams; +Cc: linux-nvdimm

On Wed, Mar 16, 2016 at 05:54:55PM -0700, Dan Williams wrote:
> Prevent these tests from bitrotting going forward by arranging for them
> to be run against nfit_test resources in the case that an ACPI.NFIT
> provider is not found.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>

I'm testing on a system without nfit_test, but with a working block namespace
and PMEM namespace.

Prior to this change both the blk-ns and pmem-ns tests pass, but with this
patch they are both skipped.

I'm guessing that it's looking for nfit_test resources, not finding them, and
then just skipping the test instead of running against my real PMEM & BLK
namespaces?

> ---
>  test/blk_namespaces.c  |   56 ++++++++++++++++++++++++++++++++----------
>  test/pmem_namespaces.c |   64 ++++++++++++++++++++++++++++++++++++++----------
>  2 files changed, 92 insertions(+), 28 deletions(-)
> 
> diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
> index db30a1fe567c..b4d677b4d0d6 100644
> --- a/test/blk_namespaces.c
> +++ b/test/blk_namespaces.c
> @@ -27,6 +27,7 @@
>  #include <uuid/uuid.h>
>  #include <linux/version.h>
>  #include <test.h>
> +#include <libkmod.h>
>  
>  /* The purpose of this test is to verify that we can successfully do I/O to
>   * multiple nd_blk namespaces that have discontiguous segments.  It first
> @@ -44,8 +45,6 @@
>  #define err(msg)\
>  	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
>  
> -static const char *provider = "ACPI.NFIT";
> -
>  static struct ndctl_namespace *create_blk_namespace(int region_fraction,
>  		struct ndctl_region *region)
>  {
> @@ -214,9 +213,11 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
>  	char bdev[50];
>  	struct ndctl_ctx *ctx;
>  	struct ndctl_bus *bus;
> -	struct ndctl_namespace *ndns[2], *_n;
> -	struct ndctl_region *region, *blk_region = NULL;
> +	struct kmod_module *mod;
>  	struct ndctl_dimm *dimm;
> +	struct kmod_ctx *kmod_ctx;
> +	struct ndctl_namespace *ndns[2];
> +	struct ndctl_region *region, *blk_region = NULL;
>  
>  	if (!ndctl_test_attempt(test, KERNEL_VERSION(4, 2, 0)))
>  		return 77;
> @@ -227,12 +228,33 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
>  
>  	ndctl_set_log_priority(ctx, log_level);
>  
> -	bus = ndctl_bus_get_by_provider(ctx, provider);
> +	kmod_ctx = kmod_new(NULL, NULL);
> +	if (!kmod_ctx)
> +		goto err_kmod;
> +	kmod_set_log_priority(kmod_ctx, log_level);
> +
> +	rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod);
> +	if (rc < 0)
> +		goto err_module;
> +
> +	rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST,
> +			NULL, NULL, NULL, NULL);
> +	if (rc < 0) {
> +		rc = 77;
> +		ndctl_test_skip(test);
> +		fprintf(stderr, "nfit_test unavailable skipping tests\n");
> +		goto err_module;
> +	}
> +
> +	bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
> +	if (!bus)
> +		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
> +
>  	if (!bus) {
>  		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
>  		ndctl_test_skip(test);
>  		rc = 77;
> -		goto err_nobus;
> +		goto err_cleanup;
>  	} else {
>  		fprintf(stderr, "%s: found provider: %s\n", comm,
>  				ndctl_bus_get_provider(bus));
> @@ -314,15 +336,21 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test)
>  	rc = 0;
>  
>   err_cleanup:
> -	if (blk_region) {
> -		ndctl_namespace_foreach_safe(blk_region, ndns[0], _n)
> -			if (ndctl_namespace_get_size(ndns[0]) != 0)
> -				disable_blk_namespace(ndns[0]);
> -	}
> -
> - err_nobus:
> +	/* 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);
> +
> + err_module:
> +	kmod_unref(kmod_ctx);
> + err_kmod:
>  	ndctl_unref(ctx);
> -
>  	return rc;
>  }
>  
> diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
> index f7dfce618c1a..198f8ef0cb37 100644
> --- a/test/pmem_namespaces.c
> +++ b/test/pmem_namespaces.c
> @@ -25,14 +25,13 @@
>  #include <sys/types.h>
>  #include <unistd.h>
>  #include <uuid/uuid.h>
> +#include <libkmod.h>
>  #include <linux/version.h>
>  #include <test.h>
>  
>  #define err(msg)\
>  	fprintf(stderr, "%s:%d: %s (%s)\n", __func__, __LINE__, msg, strerror(errno))
>  
> -static const char *provider = "ACPI.NFIT";
> -
>  static struct ndctl_namespace *create_pmem_namespace(struct ndctl_region *region)
>  {
>  	struct ndctl_namespace *seed_ns = NULL;
> @@ -175,7 +174,9 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
>  {
>  	struct ndctl_region *region, *pmem_region = NULL;
>  	struct ndctl_namespace *ndns;
> +	struct kmod_ctx *kmod_ctx;
>  	struct ndctl_dimm *dimm;
> +	struct kmod_module *mod;
>  	struct ndctl_ctx *ctx;
>  	struct ndctl_bus *bus;
>  	char bdev[50];
> @@ -190,7 +191,28 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
>  
>  	ndctl_set_log_priority(ctx, log_level);
>  
> -	bus = ndctl_bus_get_by_provider(ctx, provider);
> +	kmod_ctx = kmod_new(NULL, NULL);
> +	if (!kmod_ctx)
> +		goto err_kmod;
> +	kmod_set_log_priority(kmod_ctx, log_level);
> +
> +	rc = kmod_module_new_from_name(kmod_ctx, "nfit_test", &mod);
> +	if (rc < 0)
> +		goto err_module;
> +
> +	rc = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST,
> +			NULL, NULL, NULL, NULL);
> +	if (rc < 0) {
> +		rc = 77;
> +		ndctl_test_skip(test);
> +		fprintf(stderr, "nfit_test unavailable skipping tests\n");
> +		goto err_module;
> +	}
> +
> +	bus = ndctl_bus_get_by_provider(ctx, "ACPI.NFIT");
> +	if (!bus)
> +		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
> +
>  	if (!bus) {
>  		fprintf(stderr, "%s: failed to find NFIT-provider\n", comm);
>  		ndctl_test_skip(test);
> @@ -202,16 +224,16 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
>  
>  	/* get the system to a clean state */
>          ndctl_region_foreach(bus, region)
> -                ndctl_region_disable_invalidate(region);
> -
> -        ndctl_dimm_foreach(bus, dimm) {
> -                rc = ndctl_dimm_zero_labels(dimm);
> -                if (rc < 0) {
> -                        fprintf(stderr, "failed to zero %s\n",
> -                                        ndctl_dimm_get_devname(dimm));
> -                        return rc;
> -                }
> -        }
> +		ndctl_region_disable_invalidate(region);
> +
> +	ndctl_dimm_foreach(bus, dimm) {
> +		rc = ndctl_dimm_zero_labels(dimm);
> +		if (rc < 0) {
> +			fprintf(stderr, "failed to zero %s\n",
> +					ndctl_dimm_get_devname(dimm));
> +			goto err;
> +		}
> +	}
>  
>  	/* create our config */
>  	ndctl_region_foreach(bus, region)
> @@ -237,9 +259,23 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test)
>  	rc = ns_do_io(bdev);
>  
>  	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);
> +
> + err_module:
> +	kmod_unref(kmod_ctx);
> + err_kmod:
>  	ndctl_unref(ctx);
> -
>  	return rc;
>  }
>  
> 
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns
  2016-03-18 16:24   ` Ross Zwisler
@ 2016-03-18 16:48     ` Dan Williams
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Williams @ 2016-03-18 16:48 UTC (permalink / raw
  To: Ross Zwisler; +Cc: linux-nvdimm@lists.01.org

On Fri, Mar 18, 2016 at 9:24 AM, Ross Zwisler
<ross.zwisler@linux.intel.com> wrote:
> On Wed, Mar 16, 2016 at 05:54:55PM -0700, Dan Williams wrote:
>> Prevent these tests from bitrotting going forward by arranging for them
>> to be run against nfit_test resources in the case that an ACPI.NFIT
>> provider is not found.
>>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>
> I'm testing on a system without nfit_test, but with a working block namespace
> and PMEM namespace.
>
> Prior to this change both the blk-ns and pmem-ns tests pass, but with this
> patch they are both skipped.
>
> I'm guessing that it's looking for nfit_test resources, not finding them, and
> then just skipping the test instead of running against my real PMEM & BLK
> namespaces?

Ah, yes, it bails if it can't load nfit_test.ko.  Let me re-order that
a bit.  Thanks Ross!
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-18 16:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-17  0:54 [ndctl PATCH 0/5] refresh 'ndctl bat' tests and other misc updates Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 1/5] ndctl: update pkg-config description Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 2/5] ndctl: fix blk-ns test cleanup Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 3/5] Revert "ndctl: fix error handling in ND_BLK & PMEM tests" Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 4/5] ndctl: convert 'ndctl bat' to use struct ndctl_test Dan Williams
2016-03-17  0:54 ` [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns Dan Williams
2016-03-18 16:24   ` Ross Zwisler
2016-03-18 16:48     ` Dan Williams

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.