Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Subject: [PATCH i-g-t v3 3/6] lib/kunit: Unload base KUnit module only before reloading it
Date: Thu,  1 Feb 2024 19:59:19 +0100	[thread overview]
Message-ID: <20240201190237.150754-11-janusz.krzysztofik@linux.intel.com> (raw)
In-Reply-To: <20240201190237.150754-8-janusz.krzysztofik@linux.intel.com>

In preparation for replacement of the current method of reloading base
KUnit module with updating the module parameters via sysfs when a new set
of those parameters is needed, unload the module right before it is now
reloaded with new parameters, and stop unloading it in other places.
A follow-up patch will remove all those unloads still left, but even then
it will be shorter and more clean when based on top of this one.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 lib/igt_kmod.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index d1091bdc79..d2c28d0a64 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -1130,6 +1130,7 @@ static void kunit_get_tests(struct igt_list_head *tests,
 	 * iterating over KTAP results collected from blind execution of all
 	 * Kunit test cases provided by a Kunit test module.
 	 */
+	igt_ignore_warn(igt_kmod_unload("kunit", KMOD_REMOVE_FORCE));
 	if (igt_debug_on(igt_kmod_load("kunit",
 				       "filter=module=none filter_action=skip")))
 		return;
@@ -1167,7 +1168,6 @@ static void kunit_get_tests(struct igt_list_head *tests,
 	}
 
 	igt_skip_on(kmod_module_remove_module(tst->kmod, KMOD_REMOVE_FORCE));
-	igt_skip_on(igt_kmod_unload("kunit", KMOD_REMOVE_FORCE));
 
 	igt_skip_on_f(err,
 		      "KTAP parser failed while getting a list of test cases\n");
@@ -1200,6 +1200,17 @@ static void __igt_kunit(struct igt_ktest *tst,
 			      t->case_name) {
 
 			if (!modprobe.thread) {
+				/*
+				 * Since we have successfully loaded the kunit
+				 * base module with non-default parameters in
+				 * order to get a list of test cases, now we
+				 * have to unload it so it is then automatically
+				 * reloaded with default parameter values when
+				 * we load the test module again for execution.
+				 */
+				igt_skip_on(igt_kmod_unload("kunit",
+							    KMOD_REMOVE_FORCE));
+
 				igt_assert_eq(pthread_mutexattr_init(&attr), 0);
 				igt_assert_eq(pthread_mutexattr_setrobust(&attr,
 							  PTHREAD_MUTEX_ROBUST),
@@ -1364,15 +1375,6 @@ void igt_kunit(const char *module_name, const char *name, const char *opts)
 		igt_skip_on(igt_ktest_init(&tst, module_name));
 		igt_skip_on(igt_ktest_begin(&tst));
 
-		/*
-		 * Since we need to load kunit base module with specific
-		 * options in order to get a list of test cases, make
-		 * sure that the module is not loaded.  However, since
-		 * unload may fail if kunit base module is not loaded,
-		 * ignore any failures, we'll fail later if still loaded.
-		 */
-		igt_ignore_warn(igt_kmod_unload("kunit", KMOD_REMOVE_FORCE));
-
 		igt_assert(igt_list_empty(&tests));
 	}
 
@@ -1404,7 +1406,6 @@ void igt_kunit(const char *module_name, const char *name, const char *opts)
 		kunit_results_free(&tests, &suite_name, &case_name);
 
 		igt_ktest_end(&tst);
-		igt_debug_on(igt_kmod_unload("kunit", KMOD_REMOVE_FORCE));
 	}
 
 	igt_ktest_fini(&tst);
-- 
2.43.0


  parent reply	other threads:[~2024-02-01 19:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 18:59 [PATCH i-g-t v3 0/6] lib/kunit: Support writable filter* parameters of kunit module Janusz Krzysztofik
2024-02-01 18:59 ` [PATCH i-g-t v3 1/6] lib/kunit: Skip on empty list of test cases Janusz Krzysztofik
2024-02-01 18:59 ` [PATCH i-g-t v3 2/6] lib/kmode: Prepare open_parameters() helper for reuse by kunit Janusz Krzysztofik
2024-02-01 18:59 ` Janusz Krzysztofik [this message]
2024-02-02 10:37   ` [PATCH i-g-t v3 3/6] lib/kunit: Unload base KUnit module only before reloading it Kamil Konieczny
2024-02-01 18:59 ` [PATCH i-g-t v3 4/6] lib/kunit: Support writable filter* parameters of kunit module Janusz Krzysztofik
2024-02-01 20:26   ` Lucas De Marchi
2024-02-02 10:14     ` Janusz Krzysztofik
2024-02-02 15:57       ` Lucas De Marchi
2024-02-05 12:38         ` Janusz Krzysztofik
2024-02-01 18:59 ` [PATCH i-g-t v3 5/6] lib/kunit: Report early kernel taints explicitly Janusz Krzysztofik
2024-02-01 18:59 ` [PATCH i-g-t v3 6/6] lib/kunit: Process module remove error after list errors Janusz Krzysztofik
2024-02-01 20:55 ` ✗ CI.Patch_applied: failure for lib/kunit: Support writable filter* parameters of kunit module (rev3) Patchwork

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=20240201190237.150754-11-janusz.krzysztofik@linux.intel.com \
    --to=janusz.krzysztofik@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=mchehab@kernel.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