Skip to contentSkip to conversation

kunit: Report test parameter results as (K)TAP subtests

PATCH In review David Gow 3 participants 3 messages Oct 6, 2021

Subsystems (2)
lore
Share & tools
lore

David Gow

author
#0 lore raw

PATCH 1/1 kunit: Report test parameter results as (K)TAP subtests

Currently, the results for individial parameters in a parameterised test are simply output as (K)TAP diagnostic lines. However, the plan was always[1] to make these (K)TAP subtests when kunit_tool supported them.

With [2], these are now supported. (v5 will print out an error about the missing plan line, but this can safely be ignored, and will hopefully be changed). As a result, individual test parameter results are parsed, displayed in the formatted results, and counted for test statistics.

[1]: https://lore.kernel.org/linux-kselftest/CABVgOSnJAgWvTTABaF082LuYjAoAWzrBsyu9sT7x4GGMVsOD6Q@mail.gmail.com/
[2]: https://lore.kernel.org/linux-kselftest/[email protected]/

---
 lib/kunit/test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
lib/kunit/test.c +4 -3
index f246b847024e..02a9fdadcae2 100644
@@ -508,6 +508,8 @@ int kunit_run_tests(struct kunit_suite *suite)
 			/* Get initial param. */
 			param_desc[0] = '\0';
 			test.param_value = test_case->generate_params(NULL, param_desc);
+			kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+				  "# Subtest: %s", test_case->name);
 		}
 
 		do {
@@ -520,9 +522,8 @@ int kunit_run_tests(struct kunit_suite *suite)
 				}
 
 				kunit_log(KERN_INFO, &test,
-					  KUNIT_SUBTEST_INDENT
-					  "# %s: %s %d - %s",
-					  test_case->name,
+					  KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+					  "%s %d - %s",
 					  kunit_status_to_ok_not_ok(test.status),
 					  test.param_index + 1, param_desc);
 
Signature · 1 line
2.33.0.800.g4c38ced690-goog
#1 lore raw
Quoted 8 lines · David Gow

Currently, the results for individial parameters in a parameterised test are simply output as (K)TAP diagnostic lines. However, the plan was always[1] to make these (K)TAP subtests when kunit_tool supported them.

With [2], these are now supported. (v5 will print out an error about the missing plan line, but this can safely be ignored, and will hopefully be changed). As a result, individual test parameter results are parsed,

Hmm, I'd rather not condition users to ignore warnings. It's possible we can get this all fixed up in time for 5.16, but we have quite a bit we're trying to get in already, so I'm not sure.

Quoted 38 lines

displayed in the formatted results, and counted for test statistics.

[1]: https://lore.kernel.org/linux-kselftest/CABVgOSnJAgWvTTABaF082LuYjAoAWzrBsyu9sT7x4GGMVsOD6Q@mail.gmail.com/
[2]: https://lore.kernel.org/linux-kselftest/[email protected]/

---
 lib/kunit/test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
lib/kunit/test.c +4 -4
index f246b847024e..02a9fdadcae2 100644
@@ -508,6 +508,8 @@ int kunit_run_tests(struct kunit_suite *suite)
                        /* Get initial param. */
                        param_desc[0] = '\0';
                        test.param_value = test_case->generate_params(NULL, param_desc);
+                       kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+                                 "# Subtest: %s", test_case->name);
                }
 
                do {
@@ -520,9 +522,8 @@ int kunit_run_tests(struct kunit_suite *suite)
                                }
 
                                kunit_log(KERN_INFO, &test,
-                                         KUNIT_SUBTEST_INDENT
-                                         "# %s: %s %d - %s",
-                                         test_case->name,
+                                         KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+                                         "%s %d - %s",
                                          kunit_status_to_ok_not_ok(test.status),
                                          test.param_index + 1, param_desc);
 
--

2.33.0.800.g4c38ced690-goog

#2 lore raw
Quoted 7 lines · Daniel Latypov
Quoted 5 lines · David Gow

Currently, the results for individial parameters in a parameterised test are simply output as (K)TAP diagnostic lines. However, the plan was always[1] to make these (K)TAP subtests when kunit_tool supported them.

Quoted 7 lines
Quoted 3 lines

With [2], these are now supported. (v5 will print out an error about the missing plan line, but this can safely be ignored, and will hopefully be changed). As a result, individual test parameter results are parsed,

Hmm, I'd rather not condition users to ignore warnings. It's possible we can get this all fixed up in time for 5.16, but we have quite a bit we're trying to get in already, so I'm not sure.

I agree with Daniel. I think we should just get that fixed first. I will poke Shuah to start applying patches for 5.16 to give us a place to work.

Quoted 38 lines
Quoted 38 lines

displayed in the formatted results, and counted for test statistics.

[1]: https://lore.kernel.org/linux-kselftest/CABVgOSnJAgWvTTABaF082LuYjAoAWzrBsyu9sT7x4GGMVsOD6Q@mail.gmail.com/
[2]: https://lore.kernel.org/linux-kselftest/[email protected]/

---
 lib/kunit/test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
lib/kunit/test.c +4 -4
index f246b847024e..02a9fdadcae2 100644
@@ -508,6 +508,8 @@ int kunit_run_tests(struct kunit_suite *suite)
                        /* Get initial param. */
                        param_desc[0] = '\0';
                        test.param_value = test_case->generate_params(NULL, param_desc);
+                       kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+                                 "# Subtest: %s", test_case->name);
                }
 
                do {
@@ -520,9 +522,8 @@ int kunit_run_tests(struct kunit_suite *suite)
                                }
 
                                kunit_log(KERN_INFO, &test,
-                                         KUNIT_SUBTEST_INDENT
-                                         "# %s: %s %d - %s",
-                                         test_case->name,
+                                         KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT
+                                         "%s %d - %s",
                                          kunit_status_to_ok_not_ok(test.status),
                                          test.param_index + 1, param_desc);
 
--

2.33.0.800.g4c38ced690-goog