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: [ndctl v3 PATCH 8/9] test/inject-smart: Enable inject-smart tests on ndtest
Date: Mon, 18 Apr 2022 12:17:31 -0500	[thread overview]
Message-ID: <165030210764.3224737.17752152448193088910.stgit@lep8c.aus.stglabs.ibm.com> (raw)
In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com>

The ndtest driver does not have the payloads defined for various
smart fields like the media|ctrl temperature, threshold parameters
for the current PAPR PDSM.

So, the patch makes the below changes to have a valid inject-smart
test run on the ndtest driver.
test/inject-smart.sh - Test only the shutdown_state and dimm_health
as only those are supported on ndtest. Skip rest of the tests. Reorder
the code for cleanliness
list-list-smart-dimms.c - Separate out filter_dimm implementation for
papr family with the relevant check.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>

---

Depends on the kernel patch -
https://patchwork.kernel.org/project/linux-nvdimm/patch/165027233876.3035289.4353747702027907365.stgit@lep8c.aus.stglabs.ibm.com/

Changelog:

Since v2:
Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/163102901146.260256.6712219128280188987.stgit@99912bbcb4c7/
* Addedd the init_env() call and use the bus name post environment
  initialization.
* Split the patch to have the libndctl test specific fixes separately
* Updating the skip file to not skip the test, as it works now with this
  patch

Since v1:
Link: https://patchwork.kernel.org/project/linux-nvdimm/patch/162737350565.3944327.6662473656483436466.stgit@lep8c.aus.stglabs.ibm.com/
* Updated the commit message description

 test/inject-smart.sh   |   14 +++++++++-----
 test/list-smart-dimm.c |   33 ++++++++++++++++++++++++++++++++-
 test/meson.build       |    2 +-
 test/skip_PAPR.js      |    3 +--
 4 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/test/inject-smart.sh b/test/inject-smart.sh
index 80af058a..07d04fb6 100755
--- a/test/inject-smart.sh
+++ b/test/inject-smart.sh
@@ -4,7 +4,6 @@
 
 rc=77
 . $(dirname $0)/common
-bus="$NFIT_TEST_BUS0"
 inj_val="42"
 
 trap 'err $LINENO' ERR
@@ -152,14 +151,18 @@ do_tests()
 	$NDCTL inject-smart -b $bus --uninject-all $dimm
 
 	# start tests
-	for field in "${fields_val[@]}"; do
-		test_field $field $inj_val
-	done
-
 	for field in "${fields_bool[@]}"; do
 		test_field $field
 	done
 
+	if [ $NDCTL_TEST_FAMILY == "PAPR" ]; then
+		return
+	fi
+
+	for field in "${fields_val[@]}"; do
+		test_field $field $inj_val
+	done
+
 	for field in "${fields_thresh[@]}"; do
 		test_field $field $inj_val "thresh"
 	done
@@ -168,6 +171,7 @@ do_tests()
 check_min_kver "4.19" || do_skip "kernel $KVER may not support smart (un)injection"
 check_prereq "jq"
 _init
+bus="$NFIT_TEST_BUS0"
 rc=1
 
 jlist=$($TEST_PATH/list-smart-dimm -b $bus)
diff --git a/test/list-smart-dimm.c b/test/list-smart-dimm.c
index f94277e8..7ad6c751 100644
--- a/test/list-smart-dimm.c
+++ b/test/list-smart-dimm.c
@@ -7,6 +7,7 @@
 #include <ndctl/libndctl.h>
 #include <util/parse-options.h>
 
+#include <test.h>
 #include <ndctl/filter.h>
 #include <ndctl/ndctl.h>
 #include <ndctl/json.h>
@@ -28,6 +29,32 @@ static bool filter_region(struct ndctl_region *region,
 	return true;
 }
 
+static void filter_ndtest_dimm(struct ndctl_dimm *dimm,
+			       struct ndctl_filter_ctx *ctx)
+{
+	struct list_filter_arg *lfa = ctx->list;
+	struct json_object *jdimm;
+
+	if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART))
+		return;
+
+	if (!lfa->jdimms) {
+		lfa->jdimms = json_object_new_array();
+		if (!lfa->jdimms) {
+			fail("\n");
+			return;
+		}
+	}
+
+	jdimm = util_dimm_to_json(dimm, lfa->flags);
+	if (!jdimm) {
+		fail("\n");
+		return;
+	}
+
+	json_object_array_add(lfa->jdimms, jdimm);
+}
+
 static void filter_dimm(struct ndctl_dimm *dimm, struct ndctl_filter_ctx *ctx)
 {
 	struct list_filter_arg *lfa = ctx->list;
@@ -92,6 +119,7 @@ int main(int argc, const char *argv[])
 	struct ndctl_filter_ctx fctx = { 0 };
 	struct list_filter_arg lfa = { 0 };
 
+	init_env();
 	rc = ndctl_new(&ctx);
 	if (rc < 0)
 		return EXIT_FAILURE;
@@ -102,7 +130,10 @@ int main(int argc, const char *argv[])
 		usage_with_options(u, options);
 
 	fctx.filter_bus = filter_bus;
-	fctx.filter_dimm = filter_dimm;
+	if (ndctl_test_family == NVDIMM_FAMILY_PAPR)
+		fctx.filter_dimm = filter_ndtest_dimm;
+	else
+		fctx.filter_dimm = filter_dimm;
 	fctx.filter_region = filter_region;
 	fctx.filter_namespace = NULL;
 	fctx.list = &lfa;
diff --git a/test/meson.build b/test/meson.build
index b33fe3b9..1f804afd 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -76,7 +76,7 @@ daxdev_errors = executable('daxdev-errors', [
   include_directories : root_inc,
 )
 
-list_smart_dimm = executable('list-smart-dimm', [
+list_smart_dimm = executable('list-smart-dimm', testcore + [
     'list-smart-dimm.c',
     '../ndctl/filter.c',
     '../util/json.c',
diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js
index ec967c98..97ceda82 100644
--- a/test/skip_PAPR.js
+++ b/test/skip_PAPR.js
@@ -25,8 +25,7 @@
  "align.sh",		//		""
  "dm.sh",		//		""
  "mmap.sh",		//		""
- "monitor.sh",		// To be fixed
- "inject-smart.sh"	//    ""
+ "monitor.sh"		// To be fixed
 ]
 
 // NOTE: The libjson-c doesn't like comments in json files, so keep the file



  parent reply	other threads:[~2022-04-18 17:17 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 ` [RFC ndctl PATCH 6/9] test: Enable PAPR test family tests after INTEL family tests Shivaprasad G Bhat
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 ` Shivaprasad G Bhat [this message]
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=165030210764.3224737.17752152448193088910.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.