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 3/9] test: Unload the nfit module during cleanup
Date: Mon, 18 Apr 2022 12:10:31 -0500	[thread overview]
Message-ID: <165030182353.3224737.2306830041576864838.stgit@lep8c.aus.stglabs.ibm.com> (raw)
In-Reply-To: <165030175745.3224737.6985015146263991065.stgit@lep8c.aus.stglabs.ibm.com>

The nfit module which is needed for nfit_test is probed and is never
unloaded. The future patches attempt to load the ndtest modules and
continue the tests for PAPR family. Let there be clean state, so
unload it.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
---
 test/common |    7 +++++++
 test/core.c |   14 ++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/test/common b/test/common
index d3216a0c..d2cb3f73 100644
--- a/test/common
+++ b/test/common
@@ -31,6 +31,10 @@ if [ -z $TEST_PATH ]; then
 	export TEST_PATH=.
 fi
 
+if [ ! -v NDCTL_TEST_FAMILY ]; then
+	export NDCTL_TEST_FAMILY=INTEL
+fi
+
 # NFIT_TEST_BUS[01]
 #
 NFIT_TEST_BUS0="nfit_test.0"
@@ -111,6 +115,9 @@ _cleanup()
 	$NDCTL disable-region -b $NFIT_TEST_BUS0 all
 	$NDCTL disable-region -b $NFIT_TEST_BUS1 all
 	modprobe -r nfit_test
+	if [ $NDCTL_TEST_FAMILY == "INTEL" ]; then
+		modprobe -r nfit
+	fi
 }
 
 _init()
diff --git a/test/core.c b/test/core.c
index 7b23e258..bc7542aa 100644
--- a/test/core.c
+++ b/test/core.c
@@ -130,8 +130,22 @@ void ndctl_test_module_remove(struct kmod_ctx **ctx, struct kmod_module **mod,
 	if (rc < 0 && rc != -ENOENT) {
 		fprintf(stderr, "couldn't remove module %s\n",
 				    strerror(-rc));
+		kmod_unref(*ctx);
+		return;
 	}
 
+	rc = kmod_module_new_from_name(*ctx, "nfit", mod);
+	if (rc == 0) {
+		int state = kmod_module_get_initstate(*mod);
+
+		if (state > 0) {
+			rc = kmod_module_remove_module(*mod, 0);
+			if (rc < 0) {
+				fprintf(stderr, "couldn't remove module %s\n",
+				    strerror(-rc));
+			}
+		}
+	}
 	kmod_unref(*ctx);
 }
 



  parent reply	other threads:[~2022-04-18 17:10 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 ` Shivaprasad G Bhat [this message]
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 ` [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=165030182353.3224737.2306830041576864838.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.