Skip to contentSkip to conversation

kunit: tools: fix kunit_tool tests for parsing test plans

PATCH In review Brendan Higgins 2 participants 2 messages Oct 21, 2020 – Oct 22, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kunit: tools: fix kunit_tool tests for parsing test plans

Some tests logs for kunit_tool tests are missing their test plans causing their tests to fail; fix this by adding the test plans.

Fixes 45dcbb6f5ef7 ("kunit: test: add test plan to KUnit TAP format")
---
 tools/testing/kunit/kunit_tool_test.py        |  32 ++++++++++++++----
 .../test_data/test_config_printk_time.log     | Bin 1584 -> 1605 bytes
 .../test_data/test_interrupted_tap_output.log | Bin 1982 -> 2003 bytes
 .../test_data/test_kernel_panic_interrupt.log | Bin 1321 -> 1342 bytes
 .../test_data/test_multiple_prefixes.log      | Bin 1832 -> 1861 bytes
 .../kunit/test_data/test_pound_no_prefix.log  | Bin 1193 -> 1200 bytes
 .../kunit/test_data/test_pound_sign.log       | Bin 1656 -> 1676 bytes
 7 files changed, 25 insertions(+), 7 deletions(-)
tools/testing/kunit/kunit_tool_test.py +25 -7
index 99c3c5671ea48..0b60855fb8198 100755
@@ -179,7 +179,7 @@ class KUnitParserTest(unittest.TestCase):
 		print_mock = mock.patch('builtins.print').start()
 		result = kunit_parser.parse_run_tests(
 			kunit_parser.isolate_kunit_output(file.readlines()))
-		print_mock.assert_any_call(StrContains("no kunit output detected"))
+		print_mock.assert_any_call(StrContains('no tests run!'))
 		print_mock.stop()
 		file.close()
 
@@ -198,39 +198,57 @@ class KUnitParserTest(unittest.TestCase):
 			'test_data/test_config_printk_time.log')
 		with open(prefix_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.SUCCESS,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 	def test_ignores_multiple_prefixes(self):
 		prefix_log = get_absolute_path(
 			'test_data/test_multiple_prefixes.log')
 		with open(prefix_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.SUCCESS,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 	def test_prefix_mixed_kernel_output(self):
 		mixed_prefix_log = get_absolute_path(
 			'test_data/test_interrupted_tap_output.log')
 		with open(mixed_prefix_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.SUCCESS,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 	def test_prefix_poundsign(self):
 		pound_log = get_absolute_path('test_data/test_pound_sign.log')
 		with open(pound_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.SUCCESS,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 	def test_kernel_panic_end(self):
 		panic_log = get_absolute_path('test_data/test_kernel_panic_interrupt.log')
 		with open(panic_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.TEST_CRASHED,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 	def test_pound_no_prefix(self):
 		pound_log = get_absolute_path('test_data/test_pound_no_prefix.log')
 		with open(pound_log) as file:
 			result = kunit_parser.parse_run_tests(file.readlines())
-		self.assertEqual('kunit-resource-test', result.suites[0].name)
+			self.assertEqual(
+				kunit_parser.TestStatus.SUCCESS,
+				result.status)
+			self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 class KUnitJsonTest(unittest.TestCase):
 
tools/testing/kunit/test_data/test_config_printk_time.log binary +0 -0
index c02ca773946d641291e27d44d73174cc16a17d9d..6bdb57f76eacef0396e68942cb3fa983b6992bab 100644
GIT binary patch
tools/testing/kunit/test_data/test_interrupted_tap_output.log binary +0 -0
index 5c73fb3a1c6fd13a9b163a48d02eb33b0315a375..1fb677728abeb0fe6aa5edb3a0387c05906b9815 100644
GIT binary patch
tools/testing/kunit/test_data/test_kernel_panic_interrupt.log binary +0 -0
index c045eee75f27fefaabf3ba073d9e282721c19a67..a014ffe9725e3c4e81697f742cee2652a41b2108 100644
GIT binary patch
tools/testing/kunit/test_data/test_multiple_prefixes.log binary +0 -0
index bc48407dcc36c44665c7d2ac620e42e7caf98481..0ad78481a0b450bf463ca7aaab0ae739d4e43018 100644
GIT binary patch
tools/testing/kunit/test_data/test_pound_no_prefix.log binary +0 -0
index 2ceb360be7d52cbee4b0a5a426456605ded7466e..dc4cf09a96d077bbc0b5fbcb312251742e390379 100644
GIT binary patch
tools/testing/kunit/test_data/test_pound_sign.log binary +0 -0
index 28ffa5ba03bfa81ea02ea9d38e7de7acf3dd9e5d..3f358e3a7ba0d118c1dc15e5f637fb8ffb5aa388 100644
GIT binary patch

base-commit: 7cf726a59435301046250c42131554d9ccc566b8

Signature · 1 line
2.29.0.rc1.297.gfa9743e501-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Brendan Higgins

Some tests logs for kunit_tool tests are missing their test plans causing their tests to fail; fix this by adding the test plans.

Fixes 45dcbb6f5ef7 ("kunit: test: add test plan to KUnit TAP format")

Excellent: this fixes all of the failing tests in kunit_tool_test.py for me.

-- David

Quoted 146 lines
---
 tools/testing/kunit/kunit_tool_test.py        |  32 ++++++++++++++----
 .../test_data/test_config_printk_time.log     | Bin 1584 -> 1605 bytes
 .../test_data/test_interrupted_tap_output.log | Bin 1982 -> 2003 bytes
 .../test_data/test_kernel_panic_interrupt.log | Bin 1321 -> 1342 bytes
 .../test_data/test_multiple_prefixes.log      | Bin 1832 -> 1861 bytes
 .../kunit/test_data/test_pound_no_prefix.log  | Bin 1193 -> 1200 bytes
 .../kunit/test_data/test_pound_sign.log       | Bin 1656 -> 1676 bytes
 7 files changed, 25 insertions(+), 7 deletions(-)
tools/testing/kunit/kunit_tool_test.py +25 -7
index 99c3c5671ea48..0b60855fb8198 100755
@@ -179,7 +179,7 @@ class KUnitParserTest(unittest.TestCase):
                print_mock = mock.patch('builtins.print').start()
                result = kunit_parser.parse_run_tests(
                        kunit_parser.isolate_kunit_output(file.readlines()))
-               print_mock.assert_any_call(StrContains("no kunit output detected"))
+               print_mock.assert_any_call(StrContains('no tests run!'))
                print_mock.stop()
                file.close()
 
@@ -198,39 +198,57 @@ class KUnitParserTest(unittest.TestCase):
                        'test_data/test_config_printk_time.log')
                with open(prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_ignores_multiple_prefixes(self):
                prefix_log = get_absolute_path(
                        'test_data/test_multiple_prefixes.log')
                with open(prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_prefix_mixed_kernel_output(self):
                mixed_prefix_log = get_absolute_path(
                        'test_data/test_interrupted_tap_output.log')
                with open(mixed_prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_prefix_poundsign(self):
                pound_log = get_absolute_path('test_data/test_pound_sign.log')
                with open(pound_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_kernel_panic_end(self):
                panic_log = get_absolute_path('test_data/test_kernel_panic_interrupt.log')
                with open(panic_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.TEST_CRASHED,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_pound_no_prefix(self):
                pound_log = get_absolute_path('test_data/test_pound_no_prefix.log')
                with open(pound_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 class KUnitJsonTest(unittest.TestCase):
 
tools/testing/kunit/test_data/test_config_printk_time.log binary +0 -0
index c02ca773946d641291e27d44d73174cc16a17d9d..6bdb57f76eacef0396e68942cb3fa983b6992bab 100644
GIT binary patch
tools/testing/kunit/test_data/test_interrupted_tap_output.log binary +0 -0
index 5c73fb3a1c6fd13a9b163a48d02eb33b0315a375..1fb677728abeb0fe6aa5edb3a0387c05906b9815 100644
GIT binary patch
tools/testing/kunit/test_data/test_kernel_panic_interrupt.log binary +0 -0
index c045eee75f27fefaabf3ba073d9e282721c19a67..a014ffe9725e3c4e81697f742cee2652a41b2108 100644
GIT binary patch
tools/testing/kunit/test_data/test_multiple_prefixes.log binary +0 -0
index bc48407dcc36c44665c7d2ac620e42e7caf98481..0ad78481a0b450bf463ca7aaab0ae739d4e43018 100644
GIT binary patch
tools/testing/kunit/test_data/test_pound_no_prefix.log binary +0 -0
index 2ceb360be7d52cbee4b0a5a426456605ded7466e..dc4cf09a96d077bbc0b5fbcb312251742e390379 100644
GIT binary patch
tools/testing/kunit/test_data/test_pound_sign.log binary +0 -0
index 28ffa5ba03bfa81ea02ea9d38e7de7acf3dd9e5d..3f358e3a7ba0d118c1dc15e5f637fb8ffb5aa388 100644
GIT binary patch

base-commit: 7cf726a59435301046250c42131554d9ccc566b8 --
2.29.0.rc1.297.gfa9743e501-goog