summaryrefslogtreecommitdiffstats
path: root/tools/testing/kunit/kunit_tool_test.py
diff options
context:
space:
mode:
authorDavid Gow <davidgow@google.com>2021-11-02 08:30:12 +0100
committerShuah Khan <skhan@linuxfoundation.org>2021-12-13 21:36:15 +0100
commite56e482855b782b0e38b91cc383324bb80461073 (patch)
treec0ba53548cb4406cac30b2437ff03e9da9dc2988 /tools/testing/kunit/kunit_tool_test.py
parentkunit: tool: Do not error on tests without test plans (diff)
downloadlinux-e56e482855b782b0e38b91cc383324bb80461073.tar.xz
linux-e56e482855b782b0e38b91cc383324bb80461073.zip
kunit: tool: Report an error if any test has no subtests
It's possible for a test to have a subtest header, but zero valid subtests. We used to error on this if the test plan had no subtests listed, but it's possible to have subtests without a test plan (indeed, this is how parameterised tests work). Tests with 0 subtests now have the result NO_TESTS, and will report an error (which does not halt test execution, but is printed in a scary red colour and is noted in the results summary). Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/kunit/kunit_tool_test.py')
-rwxr-xr-xtools/testing/kunit/kunit_tool_test.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py
index 0fcdddf0124c..1b93f1151fcf 100755
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@ -209,6 +209,18 @@ class KUnitParserTest(unittest.TestCase):
kunit_parser.TestStatus.NO_TESTS,
result.status)
+ def test_no_tests_no_plan(self):
+ no_plan_log = test_data_path('test_is_test_passed-no_tests_no_plan.log')
+ with open(no_plan_log) as file:
+ result = kunit_parser.parse_run_tests(
+ kunit_parser.extract_tap_lines(file.readlines()))
+ self.assertEqual(0, len(result.test.subtests[0].subtests[0].subtests))
+ self.assertEqual(
+ kunit_parser.TestStatus.NO_TESTS,
+ result.test.subtests[0].subtests[0].status)
+ self.assertEqual(1, result.test.counts.errors)
+
+
def test_no_kunit_output(self):
crash_log = test_data_path('test_insufficient_memory.log')
print_mock = mock.patch('builtins.print').start()