anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame 0019-test-Don-t-skip-tests-if-nfit-modules-are-missing.patch

Jeff Moyer 2c91dc
From 1649ad9c3e2c6e9c47870c8d3b54f10b24177bc7 Mon Sep 17 00:00:00 2001
Jeff Moyer 2c91dc
From: Santosh Sivaraj <santosh@fossix.org>
Jeff Moyer 2c91dc
Date: Thu, 13 May 2021 11:42:16 +0530
Jeff Moyer 2c91dc
Subject: [PATCH 019/217] test: Don't skip tests if nfit modules are missing
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
For NFIT to be available ACPI is a must, so don't fail when nfit modules
Jeff Moyer 2c91dc
are missing on a platform that doesn't support ACPI.
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
Link: https://lore.kernel.org/r/20210513061218.760322-2-santosh@fossix.org
Jeff Moyer 2c91dc
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Jeff Moyer 2c91dc
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Jeff Moyer 2c91dc
---
Jeff Moyer 2c91dc
 test.h                        |  2 +-
Jeff Moyer 2c91dc
 test/ack-shutdown-count-set.c |  2 +-
Jeff Moyer 2c91dc
 test/blk_namespaces.c         |  2 +-
Jeff Moyer 2c91dc
 test/core.c                   | 28 ++++++++++++++++++++++++++--
Jeff Moyer 2c91dc
 test/dpa-alloc.c              |  2 +-
Jeff Moyer 2c91dc
 test/dsm-fail.c               |  2 +-
Jeff Moyer 2c91dc
 test/libndctl.c               |  2 +-
Jeff Moyer 2c91dc
 test/multi-pmem.c             |  2 +-
Jeff Moyer 2c91dc
 test/parent-uuid.c            |  2 +-
Jeff Moyer 2c91dc
 test/pmem_namespaces.c        |  2 +-
Jeff Moyer 2c91dc
 10 files changed, 35 insertions(+), 11 deletions(-)
Jeff Moyer 2c91dc
Jeff Moyer 2c91dc
diff --git a/test.h b/test.h
Jeff Moyer 2c91dc
index cba8d41..7de13fe 100644
Jeff Moyer 2c91dc
--- a/test.h
Jeff Moyer 2c91dc
+++ b/test.h
Jeff Moyer 2c91dc
@@ -20,7 +20,7 @@ void builtin_xaction_namespace_reset(void);
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 struct kmod_ctx;
Jeff Moyer 2c91dc
 struct kmod_module;
Jeff Moyer 2c91dc
-int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Jeff Moyer 2c91dc
+int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Jeff Moyer 2c91dc
 		struct ndctl_ctx *nd_ctx, int log_level,
Jeff Moyer 2c91dc
 		struct ndctl_test *test);
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
diff --git a/test/ack-shutdown-count-set.c b/test/ack-shutdown-count-set.c
Jeff Moyer 2c91dc
index fb1d82b..c561ff3 100644
Jeff Moyer 2c91dc
--- a/test/ack-shutdown-count-set.c
Jeff Moyer 2c91dc
+++ b/test/ack-shutdown-count-set.c
Jeff Moyer 2c91dc
@@ -99,7 +99,7 @@ static int test_ack_shutdown_count_set(int loglevel, struct ndctl_test *test,
Jeff Moyer 2c91dc
 	int result = EXIT_FAILURE, err;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	ndctl_set_log_priority(ctx, loglevel);
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		result = 77;
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
diff --git a/test/blk_namespaces.c b/test/blk_namespaces.c
Jeff Moyer 2c91dc
index d7f00cb..f076e85 100644
Jeff Moyer 2c91dc
--- a/test/blk_namespaces.c
Jeff Moyer 2c91dc
+++ b/test/blk_namespaces.c
Jeff Moyer 2c91dc
@@ -228,7 +228,7 @@ int test_blk_namespaces(int log_level, struct ndctl_test *test,
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	if (!bus) {
Jeff Moyer 2c91dc
 		fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
Jeff Moyer 2c91dc
-		rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
Jeff Moyer 2c91dc
+		rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
Jeff Moyer 2c91dc
 		ndctl_invalidate(ctx);
Jeff Moyer 2c91dc
 		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
Jeff Moyer 2c91dc
 		if (rc < 0 || !bus) {
Jeff Moyer 2c91dc
diff --git a/test/core.c b/test/core.c
Jeff Moyer 2c91dc
index cc7d8d9..2b03aa9 100644
Jeff Moyer 2c91dc
--- a/test/core.c
Jeff Moyer 2c91dc
+++ b/test/core.c
Jeff Moyer 2c91dc
@@ -11,6 +11,7 @@
Jeff Moyer 2c91dc
 #include <util/log.h>
Jeff Moyer 2c91dc
 #include <util/sysfs.h>
Jeff Moyer 2c91dc
 #include <ndctl/libndctl.h>
Jeff Moyer 2c91dc
+#include <ndctl/ndctl.h>
Jeff Moyer 2c91dc
 #include <ccan/array_size/array_size.h>
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 #define KVER_STRLEN 20
Jeff Moyer 2c91dc
@@ -106,11 +107,11 @@ int ndctl_test_get_skipped(struct ndctl_test *test)
Jeff Moyer 2c91dc
 	return test->skip;
Jeff Moyer 2c91dc
 }
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
-int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Jeff Moyer 2c91dc
+int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Jeff Moyer 2c91dc
 		struct ndctl_ctx *nd_ctx, int log_level,
Jeff Moyer 2c91dc
 		struct ndctl_test *test)
Jeff Moyer 2c91dc
 {
Jeff Moyer 2c91dc
-	int rc;
Jeff Moyer 2c91dc
+	int rc, family = -1;
Jeff Moyer 2c91dc
 	unsigned int i;
Jeff Moyer 2c91dc
 	const char *name;
Jeff Moyer 2c91dc
 	struct ndctl_bus *bus;
Jeff Moyer 2c91dc
@@ -127,10 +128,28 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
Jeff Moyer 2c91dc
 		"nd_e820",
Jeff Moyer 2c91dc
 		"nd_pmem",
Jeff Moyer 2c91dc
 	};
Jeff Moyer 2c91dc
+	char *test_env;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	log_init(&log_ctx, "test/init", "NDCTL_TEST");
Jeff Moyer 2c91dc
 	log_ctx.log_priority = log_level;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
+	/*
Jeff Moyer 2c91dc
+	 * The following two checks determine the platform family. For
Jeff Moyer 2c91dc
+	 * Intel/platforms which support ACPI, check sysfs; for other platforms
Jeff Moyer 2c91dc
+	 * determine from the environment variable NVDIMM_TEST_FAMILY
Jeff Moyer 2c91dc
+	 */
Jeff Moyer 2c91dc
+	if (access("/sys/bus/acpi", F_OK) == 0)
Jeff Moyer 2c91dc
+		family = NVDIMM_FAMILY_INTEL;
Jeff Moyer 2c91dc
+
Jeff Moyer 2c91dc
+	test_env = getenv("NDCTL_TEST_FAMILY");
Jeff Moyer 2c91dc
+	if (test_env && strcmp(test_env, "PAPR") == 0)
Jeff Moyer 2c91dc
+		family = NVDIMM_FAMILY_PAPR;
Jeff Moyer 2c91dc
+
Jeff Moyer 2c91dc
+	if (family == -1) {
Jeff Moyer 2c91dc
+		log_err(&log_ctx, "Cannot determine NVDIMM family\n");
Jeff Moyer 2c91dc
+		return -ENOTSUP;
Jeff Moyer 2c91dc
+	}
Jeff Moyer 2c91dc
+
Jeff Moyer 2c91dc
 	*ctx = kmod_new(NULL, NULL);
Jeff Moyer 2c91dc
 	if (!*ctx)
Jeff Moyer 2c91dc
 		return -ENXIO;
Jeff Moyer 2c91dc
@@ -185,6 +204,11 @@ retry:
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 		path = kmod_module_get_path(*mod);
Jeff Moyer 2c91dc
 		if (!path) {
Jeff Moyer 2c91dc
+			if (family != NVDIMM_FAMILY_INTEL &&
Jeff Moyer 2c91dc
+			    (strcmp(name, "nfit") == 0 ||
Jeff Moyer 2c91dc
+			     strcmp(name, "nd_e820") == 0))
Jeff Moyer 2c91dc
+				continue;
Jeff Moyer 2c91dc
+
Jeff Moyer 2c91dc
 			log_err(&log_ctx, "%s.ko: failed to get path\n", name);
Jeff Moyer 2c91dc
 			break;
Jeff Moyer 2c91dc
 		}
Jeff Moyer 2c91dc
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
Jeff Moyer 2c91dc
index e922009..0b3bb7a 100644
Jeff Moyer 2c91dc
--- a/test/dpa-alloc.c
Jeff Moyer 2c91dc
+++ b/test/dpa-alloc.c
Jeff Moyer 2c91dc
@@ -289,7 +289,7 @@ int test_dpa_alloc(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
Jeff Moyer 2c91dc
 		return 77;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	ndctl_set_log_priority(ctx, loglevel);
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
 		fprintf(stderr, "nfit_test unavailable skipping tests\n");
Jeff Moyer 2c91dc
diff --git a/test/dsm-fail.c b/test/dsm-fail.c
Jeff Moyer 2c91dc
index 9dfd8b0..0a6383d 100644
Jeff Moyer 2c91dc
--- a/test/dsm-fail.c
Jeff Moyer 2c91dc
+++ b/test/dsm-fail.c
Jeff Moyer 2c91dc
@@ -346,7 +346,7 @@ int test_dsm_fail(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
Jeff Moyer 2c91dc
 	int result = EXIT_FAILURE, err;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	ndctl_set_log_priority(ctx, loglevel);
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		result = 77;
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
diff --git a/test/libndctl.c b/test/libndctl.c
Jeff Moyer 2c91dc
index c42f785..d9b50f4 100644
Jeff Moyer 2c91dc
--- a/test/libndctl.c
Jeff Moyer 2c91dc
+++ b/test/libndctl.c
Jeff Moyer 2c91dc
@@ -2708,7 +2708,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
Jeff Moyer 2c91dc
 	daxctl_set_log_priority(daxctl_ctx, loglevel);
Jeff Moyer 2c91dc
 	ndctl_set_private_data(ctx, test);
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
 		fprintf(stderr, "nfit_test unavailable skipping tests\n");
Jeff Moyer 2c91dc
diff --git a/test/multi-pmem.c b/test/multi-pmem.c
Jeff Moyer 2c91dc
index 3d10952..3ea08cc 100644
Jeff Moyer 2c91dc
--- a/test/multi-pmem.c
Jeff Moyer 2c91dc
+++ b/test/multi-pmem.c
Jeff Moyer 2c91dc
@@ -249,7 +249,7 @@ int test_multi_pmem(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	ndctl_set_log_priority(ctx, loglevel);
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		result = 77;
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
diff --git a/test/parent-uuid.c b/test/parent-uuid.c
Jeff Moyer 2c91dc
index 6424e9f..bded33a 100644
Jeff Moyer 2c91dc
--- a/test/parent-uuid.c
Jeff Moyer 2c91dc
+++ b/test/parent-uuid.c
Jeff Moyer 2c91dc
@@ -218,7 +218,7 @@ int test_parent_uuid(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ct
Jeff Moyer 2c91dc
 		return 77;
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	ndctl_set_log_priority(ctx, loglevel);
Jeff Moyer 2c91dc
-	err = nfit_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
+	err = ndctl_test_init(&kmod_ctx, &mod, NULL, loglevel, test);
Jeff Moyer 2c91dc
 	if (err < 0) {
Jeff Moyer 2c91dc
 		ndctl_test_skip(test);
Jeff Moyer 2c91dc
 		fprintf(stderr, "nfit_test unavailable skipping tests\n");
Jeff Moyer 2c91dc
diff --git a/test/pmem_namespaces.c b/test/pmem_namespaces.c
Jeff Moyer 2c91dc
index f0f2edd..a4db1ae 100644
Jeff Moyer 2c91dc
--- a/test/pmem_namespaces.c
Jeff Moyer 2c91dc
+++ b/test/pmem_namespaces.c
Jeff Moyer 2c91dc
@@ -191,7 +191,7 @@ int test_pmem_namespaces(int log_level, struct ndctl_test *test,
Jeff Moyer 2c91dc
 
Jeff Moyer 2c91dc
 	if (!bus) {
Jeff Moyer 2c91dc
 		fprintf(stderr, "ACPI.NFIT unavailable falling back to nfit_test\n");
Jeff Moyer 2c91dc
-		rc = nfit_test_init(&kmod_ctx, &mod, NULL, log_level, test);
Jeff Moyer 2c91dc
+		rc = ndctl_test_init(&kmod_ctx, &mod, NULL, log_level, test);
Jeff Moyer 2c91dc
 		ndctl_invalidate(ctx);
Jeff Moyer 2c91dc
 		bus = ndctl_bus_get_by_provider(ctx, "nfit_test.0");
Jeff Moyer 2c91dc
 		if (rc < 0 || !bus) {
Jeff Moyer 2c91dc
-- 
Jeff Moyer 2c91dc
2.27.0
Jeff Moyer 2c91dc