Linux-NVDIMM Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Santosh Sivaraj <santosh@fossix.org>
To: linux-nvdimm@lists.01.org
Cc: harish@linux.ibm.com, "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [ndctl PATCH] Enable ndctl tests for emulated pmem devices
Date: Fri,  7 Jun 2019 10:55:58 +0530	[thread overview]
Message-ID: <20190607052558.15037-1-santosh@fossix.org> (raw)

For QEMU emulated devices, nfit drivers need not be loaded, also the
nfit_test, libnvdimm_test modules are not required. This patch adds a
configure option to enable testing on qemu without nfit dependencies.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 configure.ac         | 30 ++++++++++++++++++++++++++++++
 test/common          | 14 +++++++++++---
 test/core.c          |  7 ++++++-
 test/create.sh       |  6 +++++-
 test/daxdev-errors.c |  1 -
 test/dpa-alloc.c     |  2 --
 test/libndctl.c      |  2 --
 7 files changed, 52 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6dca96e..115f59e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -148,6 +148,36 @@ fi
 AC_SUBST([BASH_COMPLETION_DIR])
 AM_CONDITIONAL([ENABLE_BASH_COMPLETION], [test "x$with_bash" = "xyes"])
 
+AC_CANONICAL_HOST
+AS_CASE([$host_cpu],
+  [x86_64|arm*],
+  [
+	AC_DEFINE([ACPI], [1], ["Build for ACPI NFIT"])
+  ]
+)
+
+# Build on a qemu
+AC_ARG_ENABLE(qemu-test,
+  [ --enable-qemu-test   Enable compilation for testing on qemu],
+  [case "${enableval}" in
+     yes | no ) QEMU_PMEM_TEST="${enableval}" ;;
+     *) AC_MSG_ERROR(bad value ${enableval} for --enable-qemu-test) ;;
+   esac],
+  [QEMU_PMEM_TEST="yes"]
+)
+
+AM_CONDITIONAL([QEMU_PMEM_TEST], [test "x$QEMU_PMEM_TEST" = "xyes"])
+
+if test "x$QEMU_PMEM_TEST" = "xyes"; then
+    AC_DEFINE([QEMU_PMEM_TEST], [1], ["build for qemu pmem testing"])
+    AC_DEFINE_UNQUOTED([NFIT_PROVIDER0], [["$BUS_PROVIDER0"]], ["pmem device"])
+    AC_DEFINE_UNQUOTED([NFIT_PROVIDER1], [["$BUS_PROVIDER1"]], ["pmem device"])
+    AC_MSG_NOTICE([building for pmem testing on qemu])
+else
+    AC_DEFINE_UNQUOTED([NFIT_PROVIDER0], [["nfit_test.0"]], ["nfit device"])
+    AC_DEFINE_UNQUOTED([NFIT_PROVIDER1], [["nfit_test.1"]], ["nfit device"])
+fi
+
 AC_ARG_ENABLE([local],
         AS_HELP_STRING([--disable-local], [build against kernel ndctl.h @<:@default=system@:>@]),
         [], [enable_local=yes])
diff --git a/test/common b/test/common
index 1b9d3da..5a75e22 100644
--- a/test/common
+++ b/test/common
@@ -17,8 +17,14 @@ fi
 
 # NFIT_TEST_BUS[01]
 #
-NFIT_TEST_BUS0=nfit_test.0
-NFIT_TEST_BUS1=nfit_test.1
+if [ -z $BUS_PROVIDER0]; then
+    NFIT_TEST_BUS0=nfit_test.0
+    NFIT_TEST_BUS1=nfit_test.1
+else
+    NFIT_TEST_BUS0=$BUS_PROVIDER0
+    NFIT_TEST_BUS1=$BUS_PROVIDER1
+    QEMU_PMEM_TEST=yes
+fi
 
 
 # Functions
@@ -71,7 +77,9 @@ _cleanup()
 {
 	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
 	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-	modprobe -r nfit_test
+	if [ "x$QEMU_PMEM_TEST" = "x" ]; then
+		modprobe -r nfit_test
+	fi
 }
 
 # json2var
diff --git a/test/core.c b/test/core.c
index b9e3bbf..4f5123f 100644
--- a/test/core.c
+++ b/test/core.c
@@ -126,7 +126,9 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 	struct ndctl_bus *bus;
 	struct log_ctx log_ctx;
 	const char *list[] = {
+#ifdef ACPI
 		"nfit",
+#endif
 		"device_dax",
 		"dax_pmem",
 		"dax_pmem_core",
@@ -134,7 +136,9 @@ int nfit_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 		"libnvdimm",
 		"nd_blk",
 		"nd_btt",
+#ifdef ACPI
 		"nd_e820",
+#endif
 		"nd_pmem",
 	};
 
@@ -228,10 +232,11 @@ retry:
 		/* caller wants a full nfit_test reset */
 		ndctl_bus_foreach(nd_ctx, bus) {
 			struct ndctl_region *region;
-
+#ifdef ACPI
 			if (strncmp(ndctl_bus_get_provider(bus),
 						"nfit_test", 9) != 0)
 				continue;
+#endif
 			ndctl_region_foreach(bus, region)
 				ndctl_region_disable_invalidate(region);
 		}
diff --git a/test/create.sh b/test/create.sh
index 8d78797..7fdf696 100755
--- a/test/create.sh
+++ b/test/create.sh
@@ -23,7 +23,11 @@ check_min_kver "4.5" || do_skip "may lack namespace mode attribute"
 trap 'err $LINENO' ERR
 
 # setup (reset nfit_test dimms)
-modprobe nfit_test
+if [ -z $QEMU_PMEM_TEST ]; then
+    # setup (reset nfit_test dimms)
+    modprobe nfit_test
+fi
+
 $NDCTL disable-region -b $NFIT_TEST_BUS0 all
 $NDCTL zero-labels -b $NFIT_TEST_BUS0 all
 $NDCTL enable-region -b $NFIT_TEST_BUS0 all
diff --git a/test/daxdev-errors.c b/test/daxdev-errors.c
index 29de16b..c17e42a 100644
--- a/test/daxdev-errors.c
+++ b/test/daxdev-errors.c
@@ -45,7 +45,6 @@ struct check_cmd {
 static sigjmp_buf sj_env;
 static int sig_count;
 
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
 static struct check_cmd *check_cmds;
 
 static void sigbus_hdl(int sig, siginfo_t *siginfo, void *ptr)
diff --git a/test/dpa-alloc.c b/test/dpa-alloc.c
index 9a9c6b6..2f100b1 100644
--- a/test/dpa-alloc.c
+++ b/test/dpa-alloc.c
@@ -30,8 +30,6 @@
 #include <ndctl/libndctl.h>
 #include <ccan/array_size/array_size.h>
 
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
 #define NUM_NAMESPACES 4
 
 struct test_dpa_namespace {
diff --git a/test/libndctl.c b/test/libndctl.c
index 02bb9cc..6c123f8 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -94,8 +94,6 @@
  *    dimm.
  */
 
-static const char *NFIT_PROVIDER0 = "nfit_test.0";
-static const char *NFIT_PROVIDER1 = "nfit_test.1";
 #define SZ_4K   0x00001000
 #define SZ_128K 0x00020000
 #define SZ_7M   0x00700000
-- 
2.20.1

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

             reply	other threads:[~2019-06-07  5:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07  5:25 Santosh Sivaraj [this message]
2019-06-21  0:59 ` [ndctl PATCH] Enable ndctl tests for emulated pmem devices Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190607052558.15037-1-santosh@fossix.org \
    --to=santosh@fossix.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=harish@linux.ibm.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox