All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shivaprasad G Bhat <sbhat@linux.ibm.com>
To: nvdimm@lists.linux.dev, dan.j.williams@intel.com,
	vishal.l.verma@intel.com
Cc: aneesh.kumar@linux.ibm.com, sbhat@linux.ibm.com, vaibhav@linux.ibm.com
Subject: [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests
Date: Mon, 18 Apr 2022 12:11:11 -0500	[thread overview]
Message-ID: <165030186233.3224737.11514053958670858450.stgit@lep8c.aus.stglabs.ibm.com> (raw)
In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com>

The patch here attempts to run tests per-family loading
their respective kernel test modules based on the environment
variable set by the meson scripts. The skip_PAPR.js file is
added to ensure there are no false negatives from PAPR family.

The behaviour can be overridden by configure option
-Dtest-families=INTEL Or PAPR to run the tests for the specific
family.

When not running the "meson test" but running tests individually
the patch takes precaution to set the default settings to INTEL
to keep the current behaviour unaffected on individual tests.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
 meson.build       |   10 +++++++++
 meson_options.txt |    2 ++
 test/common       |   42 ++++++++++++++++++++++++++++++++--------
 test/core.c       |   17 +++++++++++++++-
 test/libndctl.c   |    2 +-
 test/meson.build  |   56 ++++++++++++++++++++++++++++++-----------------------
 6 files changed, 95 insertions(+), 34 deletions(-)

diff --git a/meson.build b/meson.build
index 42e11aa2..bf44ba4f 100644
--- a/meson.build
+++ b/meson.build
@@ -14,6 +14,16 @@ project('ndctl', 'c',
   ],
 )
 
+families = [ 'INTEL', 'PAPR' ]
+if get_option('test-families') != ''
+  families_str=get_option('test-families').split(',')
+  foreach f : families_str
+    if not families.contains(f.to_upper().strip())
+      error('Invalid test_family "@0@" specified.'.format(f))
+    endif
+  endforeach
+endif
+
 # rootprefixdir and rootlibdir setup copied from systemd:
 rootprefixdir = get_option('rootprefix')
 rootprefix_default = '/usr'
diff --git a/meson_options.txt b/meson_options.txt
index aa4a6dc8..95dfb395 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,6 +7,8 @@ option('keyutils', type : 'feature', value : 'enabled',
   description : 'enable nvdimm device passphrase management')
 option('test', type : 'feature', value : 'disabled',
   description : 'enable shipping tests in ndctl')
+option('test-families', type : 'string', value : 'INTEL,PAPR',
+  description : 'specify command separated test families in ndctl. Default is INTEL,PAPR')
 option('destructive', type : 'feature', value : 'disabled',
   description : 'enable tests that may clobber live system resources')
 option('poison', type : 'feature', value : 'enabled',
diff --git a/test/common b/test/common
index 31395ece..743f63bf 100644
--- a/test/common
+++ b/test/common
@@ -124,7 +124,7 @@ _cleanup()
 {
 	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
 	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
-	modprobe -r nfit_test
+	modprobe -r $TEST_MODULE
 	if [ $NDCTL_TEST_FAMILY == "INTEL" ]; then
 		modprobe -r nfit
 	fi
@@ -132,14 +132,40 @@ _cleanup()
 
 _init()
 {
-	set +e
-	modprobe nfit_test
-	if [ $? -ne 0 ]; then
-		echo "Could not load the nfit_test module."
-		exit 77
+	modules=$(awk -F" " 'BEGIN {ORS=" "} {print $1}' /proc/modules)
+	if [ "$NDCTL_TEST_FAMILY" == "PAPR" ]; then
+		TEST_MODULE="ndtest"
+		if [[ " ${modules[*]} "  =~ " nfit " ]] ||
+			[[ " ${modules[*]} " =~ " nfit_test " ]]; then
+			echo "The test module ${TEST_MODULE}.ko conflicts "
+			echo "with nfit and nfit_test. Unload them and retry.."
+			exit 77
+		fi
+		NFIT_TEST_BUS0=ndtest.0
+		NFIT_TEST_BUS1=ndtest.1
+	else
+		TEST_MODULE="nfit_test"
+		if [[ " ${modules[*]} " =~ "ndtest" ]]; then
+			echo "The test module ${TEST_MODULE}.ko conflicts "
+			echo "with ndtest. Unload it and retry.."
+			exit 77
+		fi
+	fi
+	if [ -d "/lib/modules/`uname -r`/extra/test" ]; then
+		if [ -f "/lib/modules/`uname -r`/extra/test/${TEST_MODULE}.ko" ]; then
+			set +e
+			modprobe ${TEST_MODULE}
+			if [ $? -ne 0 ]; then
+				echo "Could not load the ${TEST_MODULE} module."
+				exit 77
+			fi
+			set -e
+			trap _cleanup EXIT INT TERM HUP PIPE
+		else
+			echo "The test module ${TEST_MODULE}.ko not found. Skipping.."
+			exit 77
+		fi
 	fi
-	set -e
-	trap _cleanup EXIT INT TERM HUP PIPE
 }
 
 # json2var
diff --git a/test/core.c b/test/core.c
index f5cf6c82..ee7f5182 100644
--- a/test/core.c
+++ b/test/core.c
@@ -260,6 +260,18 @@ int ndctl_test_init(struct kmod_ctx **ctx, struct kmod_module **mod,
 	if (test_env && strcmp(test_env, "PAPR") == 0)
 		family = NVDIMM_FAMILY_PAPR;
 
+	if ((family == NVDIMM_FAMILY_INTEL) &&
+		(access("/sys/module/ndtest/initstate", F_OK) == 0)) {
+		fprintf(stderr,
+			"PAPR specific ndtest module loaded while attempting to test nfit_test\n");
+		return -ENOTSUP;
+	} else if ((family == NVDIMM_FAMILY_PAPR) &&
+		   ((access("/sys/module/nfit_test/initstate", F_OK) == 0) ||
+		    (access("/sys/module/nfit/initstate", F_OK) == 0))) {
+		fprintf(stderr, "nfit/nfit_test module loaded while attempting to test ndtest\n");
+		return -ENOTSUP;
+	}
+
 	if (family == -1) {
 		log_err(&log_ctx, "Cannot determine NVDIMM family\n");
 		return -ENOTSUP;
@@ -363,7 +375,10 @@ retry:
 		return -ENXIO;
 	}
 
-	rc = kmod_module_new_from_name(*ctx, "nfit_test", mod);
+	if (family == NVDIMM_FAMILY_INTEL)
+		rc = kmod_module_new_from_name(*ctx, "nfit_test", mod);
+	else
+		rc = kmod_module_new_from_name(*ctx, "ndtest", mod);
 	if (rc < 0) {
 		kmod_unref(*ctx);
 		return rc;
diff --git a/test/libndctl.c b/test/libndctl.c
index ab9f73c9..a70c1ed7 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2596,7 +2596,7 @@ int test_libndctl(int loglevel, struct ndctl_test *test, struct ndctl_ctx *ctx)
 	err = ndctl_test_init(&kmod_ctx, &mod, ctx, loglevel, test);
 	if (err < 0) {
 		ndctl_test_skip(test);
-		fprintf(stderr, "nfit_test unavailable skipping tests\n");
+		fprintf(stderr, "test module couldnt not be loaded, skipping tests\n");
 		return 77;
 	}
 
diff --git a/test/meson.build b/test/meson.build
index 395b5333..b33fe3b9 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -177,6 +177,11 @@ tests = [
   [ 'track-uuid.sh',          track_uuid,	  'ndctl' ],
 ]
 
+families_string = get_option('test-families')
+if families_string != ''
+  families=families_string.split(',')
+endif
+
 if get_option('destructive').enabled()
   sub_section = find_program('sub-section.sh')
   dax_ext4 = find_program('dax-ext4.sh')
@@ -212,28 +217,31 @@ if get_option('keyutils').enabled()
   ]
 endif
 
-foreach t : tests
-  test(t[0], t[1],
-    is_parallel : false,
-    depends : [
-      ndctl_tool,
-      daxctl_tool,
-      cxl_tool,
-      smart_notify,
-      list_smart_dimm,
-      dax_pmd,
-      dax_errors,
-      daxdev_errors,
-      dax_dev,
-      mmap,
-    ],
-    suite: t[2],
-    timeout : 0,
-    env : [
-      'NDCTL=@0@'.format(ndctl_tool.full_path()),
-      'DAXCTL=@0@'.format(daxctl_tool.full_path()),
-      'TEST_PATH=@0@'.format(meson.current_build_dir()),
-      'DATA_PATH=@0@'.format(meson.current_source_dir()),
-    ],
-  )
+foreach f : families
+  foreach t : tests
+    test(t[0], t[1],
+      is_parallel : false,
+      depends : [
+        ndctl_tool,
+        daxctl_tool,
+        cxl_tool,
+        smart_notify,
+        list_smart_dimm,
+        dax_pmd,
+        dax_errors,
+        daxdev_errors,
+        dax_dev,
+        mmap,
+      ],
+      suite: [ t[2], f ],
+      timeout : 0,
+      env : [
+        'NDCTL=@0@'.format(ndctl_tool.full_path()),
+        'DAXCTL=@0@'.format(daxctl_tool.full_path()),
+        'TEST_PATH=@0@'.format(meson.current_build_dir()),
+        'DATA_PATH=@0@'.format(meson.current_source_dir()),
+        'NDCTL_TEST_FAMILY=@0@'.format(f.to_upper().strip()),
+      ],
+    )
+  endforeach
 endforeach



  parent reply	other threads:[~2022-04-18 17:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 17:09 [RFC ndctl PATCH 0/9] test: Enable PAPR test family by default Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 1/9] test/common: Ensure to unload test modules Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 2/9] test: core: Fix module unload failures Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 3/9] test: Unload the nfit module during cleanup Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 4/9] test: Introduce skip file to skip irrelevant tests Shivaprasad G Bhat
2022-04-18 17:10 ` [RFC ndctl PATCH 5/9] test: Assign provider name based on the test family Shivaprasad G Bhat
2022-04-18 17:11 ` Shivaprasad G Bhat [this message]
2022-04-18 17:15 ` [ndctl v3 PATCH 7/9] test/libndctl: Enable libndctl tests on ndtest Shivaprasad G Bhat
2022-04-18 17:17 ` [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart " Shivaprasad G Bhat
2022-04-18 17:19 ` [ndctl v3 PATCH 9/9] test/monitor.sh: Partially skip monitor test " Shivaprasad G Bhat

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=165030186233.3224737.11514053958670858450.stgit@lep8c.aus.stglabs.ibm.com \
    --to=sbhat@linux.ibm.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=vaibhav@linux.ibm.com \
    --cc=vishal.l.verma@intel.com \
    /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 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.