diff mbox series

[i-g-t,v3,5/5] lib/kunit: Minimize code duplication

Message ID 20240318103534.701693-12-janusz.krzysztofik@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series lib/kunit: Execute test cases synchronously | expand

Commit Message

Janusz Krzysztofik March 18, 2024, 10:13 a.m. UTC
A new helper has been introduced recently, used for fetching KTAP results
of a single test case.  Since that helper is called for that purpose
only after the test module is loaded with all other test cases filtered
out, its actual implementation is as simple as collecting all results from
a single KTAP report, no matter how many test suites and test cases it
covers.  Then, it's a good candidate for reuse in other scenarios when a
single KTAP report is handled, e.g., when we collect a list of test cases
from a single test suite or test module.  Go for it.

v3: Rebased on top of changes to struct igt_ktap_results pointer handling.
v2: Rebased on invalid test suite name workaround.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>
---
 lib/igt_kmod.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

Comments

Kamil Konieczny March 25, 2024, 5:12 p.m. UTC | #1
Hi Janusz,
On 2024-03-18 at 11:13:31 +0100, Janusz Krzysztofik wrote:
> A new helper has been introduced recently, used for fetching KTAP results
> of a single test case.  Since that helper is called for that purpose
> only after the test module is loaded with all other test cases filtered
> out, its actual implementation is as simple as collecting all results from
> a single KTAP report, no matter how many test suites and test cases it
> covers.  Then, it's a good candidate for reuse in other scenarios when a
> single KTAP report is handled, e.g., when we collect a list of test cases
> from a single test suite or test module.  Go for it.
> 
> v3: Rebased on top of changes to struct igt_ktap_results pointer handling.
> v2: Rebased on invalid test suite name workaround.
> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
> Cc: Jonathan Cavitt <jonathan.cavitt@intel.com>

Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>

> ---
>  lib/igt_kmod.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index c495d11b16..8979a5928b 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -1262,21 +1262,14 @@ static bool kunit_get_tests(struct igt_list_head *tests,
>  	igt_skip_on(modprobe(tst->kmod, opts));
>  	igt_skip_on(igt_kernel_tainted(&taints));
>  
> -	*ktap = igt_ktap_alloc(tests);
> -	igt_require(*ktap);
> -
>  	igt_skip_on(sigaction(SIGALRM, &sigalrm, saved));
>  	alarm(10);
>  
> -	do
> -		err = kunit_kmsg_result_get(tests, NULL, tst->kmsg, *ktap);
> -	while (err == -EINPROGRESS);
> +	err = kunit_get_results(tests, tst->kmsg, ktap);
>  
>  	alarm(0);
>  	igt_debug_on(sigaction(SIGALRM, saved, NULL));
>  
> -	igt_ktap_free(ktap);
> -
>  	igt_skip_on_f(err,
>  		      "KTAP parser failed while getting a list of test cases\n");
>  
> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index c495d11b16..8979a5928b 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -1262,21 +1262,14 @@  static bool kunit_get_tests(struct igt_list_head *tests,
 	igt_skip_on(modprobe(tst->kmod, opts));
 	igt_skip_on(igt_kernel_tainted(&taints));
 
-	*ktap = igt_ktap_alloc(tests);
-	igt_require(*ktap);
-
 	igt_skip_on(sigaction(SIGALRM, &sigalrm, saved));
 	alarm(10);
 
-	do
-		err = kunit_kmsg_result_get(tests, NULL, tst->kmsg, *ktap);
-	while (err == -EINPROGRESS);
+	err = kunit_get_results(tests, tst->kmsg, ktap);
 
 	alarm(0);
 	igt_debug_on(sigaction(SIGALRM, saved, NULL));
 
-	igt_ktap_free(ktap);
-
 	igt_skip_on_f(err,
 		      "KTAP parser failed while getting a list of test cases\n");