refresh 'ndctl bat' tests and other misc updates
Subsystems (3)
cover refresh 'ndctl bat' tests and other misc updates
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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 1/5 ndctl: update pkg-config description
Use the same description as rpmspec file which references "libnvdimm" instead of "nd".
--- lib/libndctl.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/libndctl.pc.in +1 -1
@@ -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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 2/5 ndctl: fix blk-ns test cleanup
In reply to Dan Williamsndctl_namespace_foreach_safe() needs to be used when a namespace is deleted while iterating. Otherwise, we can walk off into uninitialized memory and segfault.
--- test/blk_namespaces.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/blk_namespaces.c +2 -2
@@ -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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 3/5 Revert "ndctl: fix error handling in ND_BLK & PMEM tests"
In reply to Dan WilliamsThis 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.
--- test/blk_namespaces.c | 77 +++++++++++++++++++++++++----------------------- test/pmem_namespaces.c | 46 +++++++++++++++-------------- 2 files changed, 64 insertions(+), 59 deletions(-)
test/blk_namespaces.c +40 -37
@@ -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) {
test/pmem_namespaces.c +24 -22
132 lines not on this page · raw message
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 4/5 ndctl: convert 'ndctl bat' to use struct ndctl_test
In reply to Dan WilliamsThis gives the bat test the ability to skip tests based on kernel version and report test results in the same format as 'ndctl test'.
--- 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(-)
Makefile.am +6 -6
@@ -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
builtin-bat.c +21 -6
@@ -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); }
test.h +3 -3
@@ -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__ */
test/blk_namespaces.c +16 -2
@@ -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); }
test/pcommit.c +16 -3
@@ -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); }
test/pmem_namespaces.c +16 -2
@@ -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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
PATCH 5/5 ndctl: fall back to nfit_test for test/{blk|pmem}-ns
In reply to Dan WilliamsPrevent 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.
--- test/blk_namespaces.c | 56 ++++++++++++++++++++++++++++++++---------- test/pmem_namespaces.c | 64 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 92 insertions(+), 28 deletions(-)
test/blk_namespaces.c +42 -14
@@ -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; }
test/pmem_namespaces.c +50 -14
103 lines not on this page · raw message
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns
Quoted 5 lines · Dan Williams
Prevent these tests from bitrotting going forward by arranging for them to be run against
nfit_testresources in the case that an ACPI.NFIT provider is not found.Signed-off-by Dan Williams <[email protected]>
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?
Quoted 209 lines
--- test/blk_namespaces.c | 56 ++++++++++++++++++++++++++++++++---------- test/pmem_namespaces.c | 64 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 92 insertions(+), 28 deletions(-)test/blk_namespaces.c +42
-14@@ -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; }test/pmem_namespaces.c +45
-13@@ -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);
test/pmem_namespaces.c int test_pmem_namespaces(int log_level, struct ndctl_test *test) · line 281
Quoted 10 lines
test/pmem_namespaces.c +5
-1+kmod_module_remove_module (mod,0 ); + + err_module: +kmod_unref (kmod_ctx); + err_kmod:ndctl_unref (ctx); -return rc; }
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Re: [ndctl PATCH 5/5] ndctl: fall back to nfit_test for test/{blk|pmem}-ns
Quoted 10 lines · Ross Zwisler
Quoted 5 lines · Dan Williams
Prevent these tests from bitrotting going forward by arranging for them to be run against
nfit_testresources in the case that an ACPI.NFIT provider is not found.Signed-off-by Dan Williams <[email protected]>I'm testing on a system without
nfit_test, but with a working block namespace and PMEM namespace.
Quoted 6 lines
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_testresources, 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
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm