summaryrefslogtreecommitdiff
path: root/lib/kunit/executor.c
diff options
context:
space:
mode:
authorBrendan Higgins <brendanhiggins@google.com>2020-08-04 13:47:44 -0700
committerShuah Khan <skhan@linuxfoundation.org>2020-10-09 14:37:49 -0600
commit45dcbb6f5ef78b0a9c1b91bea2f6f227642a65aa (patch)
tree3b1166347c5ae73bf8f4b7101651a1bb633474db /lib/kunit/executor.c
parent8c0d884986ba22f1020be9c02e41c030890ee8f2 (diff)
kunit: test: add test plan to KUnit TAP format
TAP 14 allows an optional test plan to be emitted before the start of the start of testing[1]; this is valuable because it makes it possible for a test harness to detect whether the number of tests run matches the number of tests expected to be run, ensuring that no tests silently failed. Link[1]: https://github.com/isaacs/testanything.github.io/blob/tap14/tap-version-14-specification.md#the-plan Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/executor.c')
-rw-r--r--lib/kunit/executor.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c
index 4aab7f70a88c..a95742a4ece7 100644
--- a/lib/kunit/executor.c
+++ b/lib/kunit/executor.c
@@ -11,10 +11,27 @@ extern struct kunit_suite * const * const __kunit_suites_end[];
#if IS_BUILTIN(CONFIG_KUNIT)
+static void kunit_print_tap_header(void)
+{
+ struct kunit_suite * const * const *suites, * const *subsuite;
+ int num_of_suites = 0;
+
+ for (suites = __kunit_suites_start;
+ suites < __kunit_suites_end;
+ suites++)
+ for (subsuite = *suites; *subsuite != NULL; subsuite++)
+ num_of_suites++;
+
+ pr_info("TAP version 14\n");
+ pr_info("1..%d\n", num_of_suites);
+}
+
int kunit_run_all_tests(void)
{
struct kunit_suite * const * const *suites;
+ kunit_print_tap_header();
+
for (suites = __kunit_suites_start;
suites < __kunit_suites_end;
suites++)