Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: tool: add test for parsing attributes

Add test for parsing attributes to kunit_tool_test.py. Test checks
attributes are parsed and saved in the test logs.

This test also checks that the attributes have not interfered with the
parsing of other test information, specifically the suite header as
the test plan was being incorrectely parsed.

Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Rae Moar and committed by
Shuah Khan
6eb0ea28 8ae27bc7

+25
+16
tools/testing/kunit/kunit_tool_test.py
··· 331 331 kunit_parser.parse_run_tests(file.readlines()) 332 332 self.print_mock.assert_any_call(StrContains('suite (1 subtest)')) 333 333 334 + def test_parse_attributes(self): 335 + ktap_log = test_data_path('test_parse_attributes.log') 336 + with open(ktap_log) as file: 337 + result = kunit_parser.parse_run_tests(file.readlines()) 338 + 339 + # Test should pass with no errors 340 + self.assertEqual(result.counts, kunit_parser.TestCounts(passed=1, errors=0)) 341 + self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 342 + 343 + # Ensure suite header is parsed correctly 344 + self.print_mock.assert_any_call(StrContains('suite (1 subtest)')) 345 + 346 + # Ensure attributes in correct test log 347 + self.assertContains('# module: example', result.subtests[0].log) 348 + self.assertContains('# test.speed: slow', result.subtests[0].subtests[0].log) 349 + 334 350 def test_show_test_output_on_failure(self): 335 351 output = """ 336 352 KTAP version 1
+9
tools/testing/kunit/test_data/test_parse_attributes.log
··· 1 + KTAP version 1 2 + 1..1 3 + KTAP version 1 4 + # Subtest: suite 5 + # module: example 6 + 1..1 7 + # test.speed: slow 8 + ok 1 test 9 + ok 1 suite