Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH i-g-t v3 4/6] lib/igt_kmod: Stop passing ktap around
Date: Wed,  6 Nov 2024 21:52:52 -0800	[thread overview]
Message-ID: <20241107055254.3129207-5-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20241107055254.3129207-1-lucas.demarchi@intel.com>

Just allocate and free in the only function it's needed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 lib/igt_kmod.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 36578aa68..fd79e8739 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -995,8 +995,9 @@ static void kunit_results_free(struct igt_list_head *results,
 }
 
 static int kunit_get_results(struct igt_list_head *results, const char *debugfs_path,
-			     const char *suite, struct igt_ktap_results **ktap)
+			     const char *suite)
 {
+	struct igt_ktap_results *ktap;
 	char results_path[PATH_MAX];
 	FILE *results_stream;
 	char *buf = NULL;
@@ -1012,21 +1013,21 @@ static int kunit_get_results(struct igt_list_head *results, const char *debugfs_
 	if (igt_debug_on(!results_stream))
 		return -errno;
 
-	*ktap = igt_ktap_alloc(results);
-	if (igt_debug_on(!*ktap)) {
+	ktap = igt_ktap_alloc(results);
+	if (igt_debug_on(!ktap)) {
 		err = -ENOMEM;
 		goto out_fclose;
 	}
 
 	while (len = getline(&buf, &size, results_stream), len > 0) {
-		err = igt_ktap_parse(buf, *ktap);
+		err = igt_ktap_parse(buf, ktap);
 		if (err != -EINPROGRESS)
 			break;
 	}
 
 	free(buf);
+	igt_ktap_free(&ktap);
 
-	igt_ktap_free(ktap);
 out_fclose:
 	fclose(results_stream);
 
@@ -1037,8 +1038,7 @@ static void kunit_get_tests(struct igt_list_head *tests,
 			    struct igt_ktest *tst,
 			    const char *suite,
 			    const char *opts,
-			    const char *debugfs_path,
-			    struct igt_ktap_results **ktap)
+			    const char *debugfs_path)
 {
 	struct igt_ktap_result *r, *rn;
 	struct dirent *subdir;
@@ -1083,7 +1083,7 @@ static void kunit_get_tests(struct igt_list_head *tests,
 		if (suite && strcmp(subdir->d_name, suite))
 			continue;
 
-		igt_warn_on_f(kunit_get_results(tests, debugfs_path, subdir->d_name, ktap),
+		igt_warn_on_f(kunit_get_results(tests, debugfs_path, subdir->d_name),
 			      "parsing KTAP report from test suite \"%s\" failed\n",
 			      subdir->d_name);
 
@@ -1102,8 +1102,7 @@ static void __igt_kunit(struct igt_ktest *tst,
 			const char *subtest,
 			const char *opts,
 			const char *debugfs_path,
-			struct igt_list_head *tests,
-			struct igt_ktap_results **ktap)
+			struct igt_list_head *tests)
 {
 	struct igt_ktap_result *t;
 
@@ -1133,7 +1132,7 @@ static void __igt_kunit(struct igt_ktest *tst,
 			igt_assert_eq(igt_kernel_tainted(&taints), 0);
 
 			igt_assert_eq(kunit_get_results(&results, debugfs_path,
-							t->suite_name, ktap), 0);
+							t->suite_name), 0);
 
 			for (i = 0; i < 2; i++) {
 				kunit_result_free(&r, &suite_name, &case_name);
@@ -1197,7 +1196,6 @@ void igt_kunit(const char *module_name, const char *suite, const char *opts)
 {
 	char debugfs_path[PATH_MAX] = { '\0', };
 	struct igt_ktest tst = { .kmsg = -1, };
-	struct igt_ktap_results *ktap = NULL;
 	char *subtest;
 	IGT_LIST_HEAD(tests);
 
@@ -1243,16 +1241,13 @@ void igt_kunit(const char *module_name, const char *suite, const char *opts)
 	 * and for documentation.
 	 */
 	igt_subtest_with_dynamic(subtest) {
-		kunit_get_tests(&tests, &tst, suite, opts,
-				debugfs_path, &ktap);
-		__igt_kunit(&tst, subtest, opts, debugfs_path, &tests, &ktap);
+		kunit_get_tests(&tests, &tst, suite, opts, debugfs_path);
+		__igt_kunit(&tst, subtest, opts, debugfs_path, &tests);
 	}
 
 	igt_fixture {
 		char *suite_name = NULL, *case_name = NULL;
 
-		igt_ktap_free(&ktap);
-
 		kunit_results_free(&tests, &suite_name, &case_name);
 
 		igt_ktest_end(&tst);
-- 
2.47.0


  parent reply	other threads:[~2024-11-07  5:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  5:52 [PATCH i-g-t v3 0/6] lib/igt_kmod: Drop legacy kunit integration Lucas De Marchi
2024-11-07  5:52 ` [PATCH i-g-t v3 1/6] lib/igt_kmod: Drop legacy kunit fallback Lucas De Marchi
2024-11-07  5:52 ` [PATCH i-g-t v3 2/6] lib/igt_kmod: Fix leaking subtest name Lucas De Marchi
2024-11-07  5:52 ` [PATCH i-g-t v3 3/6] lib/igt_kmod: Stop passing debugfs_dir around Lucas De Marchi
2024-11-14 14:24   ` Janusz Krzysztofik
2024-11-14 20:58     ` Lucas De Marchi
2024-11-14 21:45       ` Lucas De Marchi
2024-11-15 14:24         ` Janusz Krzysztofik
2024-11-07  5:52 ` Lucas De Marchi [this message]
2024-11-14 15:00   ` [PATCH i-g-t v3 4/6] lib/igt_kmod: Stop passing ktap around Janusz Krzysztofik
2024-11-07  5:52 ` [PATCH i-g-t v3 5/6] lib/igt_ktap: Just free ktap Lucas De Marchi
2024-11-14 15:02   ` Janusz Krzysztofik
2024-11-07  5:52 ` [PATCH i-g-t v3 6/6] lib/igt_kmod: Do not leak kmod ctx Lucas De Marchi
2024-11-14 17:06   ` Janusz Krzysztofik
2024-11-07  6:22 ` ✓ CI.xeBAT: success for lib/igt_kmod: Drop legacy kunit integration (rev3) Patchwork
2024-11-07  6:27 ` ✓ Fi.CI.BAT: " Patchwork
2024-11-07  7:29 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-11-08 11:25 ` ✗ CI.xeFULL: " Patchwork
2024-11-14 22:00 ` ✗ Fi.CI.BUILD: failure for lib/igt_kmod: Drop legacy kunit integration (rev4) 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=20241107055254.3129207-5-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=janusz.krzysztofik@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox