diff mbox series

[ndctl,v3,7/9] test/libndctl: Enable libndctl tests on ndtest

Message ID 165030187808.3224737.13924358944848090966.stgit@lep8c.aus.stglabs.ibm.com (mailing list archive)
State New, archived
Headers show
Series test: Enable PAPR test family by default | expand

Commit Message

Shivaprasad G Bhat April 18, 2022, 5:15 p.m. UTC
The ndtest/papr dsm don't have the smart threshold payloads defined
and various smart fields like media/ctrl temperatures, spares etc.

Test only whats relevant and disable/skip the rest.

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/
* Split the patch into libndctl test specific changes.
* Rebased to use the global ndctl_test_family variable

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/libndctl.c   |   45 +++++++++++++++++++++++++++++++++++++++++++++
 test/skip_PAPR.js |    3 +--
 2 files changed, 46 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/test/libndctl.c b/test/libndctl.c
index a70c1ed7..15c47211 100644
--- a/test/libndctl.c
+++ b/test/libndctl.c
@@ -2075,6 +2075,46 @@  struct smart {
 		     life_used, shutdown_state, shutdown_count, vendor_size;
 };
 
+static int check_smart_ndtest(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
+			struct check_cmd *check)
+{
+	static const struct smart smart_data = {
+		.flags = ND_SMART_HEALTH_VALID | ND_SMART_SHUTDOWN_VALID
+			| ND_SMART_SHUTDOWN_COUNT_VALID | ND_SMART_USED_VALID,
+		.health = ND_SMART_NON_CRITICAL_HEALTH,
+		.life_used = 5,
+		.shutdown_state = 0,
+		.shutdown_count = 42,
+		.vendor_size = 0,
+	};
+	struct ndctl_cmd *cmd = ndctl_dimm_cmd_new_smart(dimm);
+	int rc;
+
+	if (!cmd) {
+		fprintf(stderr, "%s: dimm: %#x failed to create cmd\n",
+				__func__, ndctl_dimm_get_handle(dimm));
+		return -ENXIO;
+	}
+
+	rc = ndctl_cmd_submit(cmd);
+	if (rc < 0) {
+		fprintf(stderr, "%s: dimm: %#x failed to submit cmd: %d\n",
+			__func__, ndctl_dimm_get_handle(dimm), rc);
+		ndctl_cmd_unref(cmd);
+		return rc;
+	}
+
+	__check_smart(dimm, cmd, flags, -1);
+	__check_smart(dimm, cmd, health, -1);
+	__check_smart(dimm, cmd, life_used, -1);
+	__check_smart(dimm, cmd, shutdown_state, -1);
+	__check_smart(dimm, cmd, shutdown_count, -1);
+	__check_smart(dimm, cmd, vendor_size, -1);
+
+	check->cmd = cmd;
+	return 0;
+}
+
 static int check_smart(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 		struct check_cmd *check)
 {
@@ -2299,6 +2339,11 @@  static int check_commands(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
 
 	unsigned int i, rc = 0;
 
+	if (ndctl_test_family == NVDIMM_FAMILY_PAPR) {
+		dimm_commands &= ~(1 << ND_CMD_SMART_THRESHOLD);
+		__check_dimm_cmds[ND_CMD_SMART].check_fn = &check_smart_ndtest;
+	}
+
 	/*
 	 * The kernel did not start emulating v1.2 namespace spec smart data
 	 * until 4.9.
diff --git a/test/skip_PAPR.js b/test/skip_PAPR.js
index 367257c4..ec967c98 100644
--- a/test/skip_PAPR.js
+++ b/test/skip_PAPR.js
@@ -26,8 +26,7 @@ 
  "dm.sh",		//		""
  "mmap.sh",		//		""
  "monitor.sh",		// To be fixed
- "inject-smart.sh",	//    ""
- "libndctl"		//    ""
+ "inject-smart.sh"	//    ""
 ]
 
 // NOTE: The libjson-c doesn't like comments in json files, so keep the file