Kunit fixes update for Linux 5.10-rc3
Subsystems (4)
Shuah Khan
maintainerHi Linus,
Please pull the following Kunit fixes update for Linux 5.10-rc3
This Kunit update for Linux 5.10-rc3 consists of several kunit_tool and documentation fixes.
diff is attached.
thanks,
-- Shuah
----------------------------------------------------------------
The following changes since commit 3650b228f83adda7e5ee532e2b90429c03f7b9ec:
Linux 5.10-rc1 (2020-10-25 15:14:11 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
tags/linux-kselftest-kunit-fixes-5.10-rc3
for you to fetch changes up to 0d0d245104a42e593adcf11396017a6420c08ba8:
kunit: tools: fix kunit_tool tests for parsing test plans (2020-10-26
13:25:40 -0600)
----------------------------------------------------------------
linux-kselftest-kunit-fixes-5.10-rc3
This Kunit update for Linux 5.10-rc3 consists of several kunit_tool and documentation fixes.
----------------------------------------------------------------
Andy Shevchenko (1):
kunit: Don't fail test suites if one of them is empty
Brendan Higgins (1):
kunit: tools: fix kunit_tool tests for parsing test plans
David Gow (1):
kunit: Fix kunit.py --raw_output option
Mauro Carvalho Chehab (1):
kunit: test: fix remaining kernel-doc warnings
SeongJae Park (1):
Documentation: kunit: Update Kconfig parts for KUNIT's module support
Documentation/dev-tools/kunit/start.rst | 2 +- Documentation/dev-tools/kunit/usage.rst | 5 ++++ include/kunit/test.h | 16 +++++------ tools/testing/kunit/kunit_parser.py | 3 +- tools/testing/kunit/kunit_tool_test.py | 32 ++++++++++++++++----- .../kunit/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 .../kunit/test_data/test_multiple_prefixes.log | Bin 1832 -> 1861 bytes .../kunit/test_data/test_pound_no_prefix.log | Bin 1193 -> 1200 bytes tools/testing/kunit/test_data/test_pound_sign.log | Bin 1656 -> 1676 bytes 11 files changed, 40 insertions(+), 18 deletions(-)
----------------------------------------------------------------
Documentation/dev-tools/kunit/start.rst +1 -1
@@ -197,7 +197,7 @@ Now add the following to ``drivers/misc/Kconfig``: config MISC_EXAMPLE_TEST bool "Test for my example" - depends on MISC_EXAMPLE && KUNIT + depends on MISC_EXAMPLE && KUNIT=y and the following to ``drivers/misc/Makefile``:
Documentation/dev-tools/kunit/usage.rst +5 -0
@@ -561,6 +561,11 @@ Once the kernel is built and installed, a simple ...will run the tests. +.. note:: + Note that you should make sure your test depends on ``KUNIT=y`` in Kconfig + if the test does not support module build. Otherwise, it will trigger + compile errors if ``CONFIG_KUNIT`` is ``m``. + Writing new tests for other architectures -----------------------------------------
include/kunit/test.h +8 -8
@@ -252,13 +252,14 @@ static inline int kunit_run_all_tests(void) }#endif /* IS_BUILTIN(CONFIG_KUNIT) */ +#ifdef MODULE /** -* kunit_test_suites() - used to register one or more &struct kunit_suite -* with KUnit. +* kunit_test_suites_for_module() - used to register one or more +* &struct kunit_suite with KUnit. * -* @suites_list...: a statically allocated list of &struct kunit_suite. +* @__suites: a statically allocated list of &struct kunit_suite. * -* Registers @suites_list with the test framework. See &struct kunit_suite for +* Registers @__suites with the test framework. See &struct kunit_suite for * more information. * * If a test suite is built-in, module_init() gets translated into
@@ -267,7 +268,6 @@ static inline int kunit_run_all_tests(void)* module_{init|exit} functions for the builtin case when registering * suites via kunit_test_suites() below. */ -#ifdef MODULE #define kunit_test_suites_for_module (__suites) \ static int __init kunit_test_suites_init(void) \ { \
@@ -294,7 +294,7 @@ static inline int kunit_run_all_tests(void)* kunit_test_suites() - used to register one or more &struct kunit_suite * with KUnit. * -* @suites: a statically allocated list of &struct kunit_suite. +* @__suites: a statically allocated list of &struct kunit_suite. * * Registers @suites with the test framework. See &struct kunit_suite for * more information.
@@ -308,10 +308,10 @@ static inline int kunit_run_all_tests(void)* module. * */ -#define kunit_test_suites (...) \ +#define kunit_test_suites(__suites...) \ __kunit_test_suites(__UNIQUE_ID(array), \ __UNIQUE_ID(suites), \ - __VA_ARGS__) + ##__suites)#define kunit_test_suite (suite) kunit_test_suites(&suite)
tools/testing/kunit/kunit_parser.py +1 -2
@@ -66,7 +66,6 @@ def isolate_kunit_output(kernel_output): def raw_output(kernel_output): for line in kernel_output: print(line) - yield line DIVIDER = '=' * 60
@@ -242,7 +241,7 @@ def parse_test_suite(lines: List[str], expected_suite_index: int) -> TestSuite: return None test_suite.name = name expected_test_case_num = parse_subtest_plan(lines) - if not expected_test_case_num: + if expected_test_case_num is None: return None while expected_test_case_num > 0: test_case = parse_test_case(lines)
tools/testing/kunit/kunit_tool_test.py +25 -7
@@ -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
tools/testing/kunit/test_data/test_interrupted_tap_output.log binary +0 -0
tools/testing/kunit/test_data/test_kernel_panic_interrupt.log binary +0 -0
tools/testing/kunit/test_data/test_multiple_prefixes.log binary +0 -0
tools/testing/kunit/test_data/test_pound_no_prefix.log binary +0 -0
tools/testing/kunit/test_data/test_pound_sign.log binary +0 -0
Quoted 5 lines · Shuah Khan
.../kunit/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 .../kunit/test_data/test_multiple_prefixes.log | Bin 1832 -> 1861
This diffstat is a bit annoying.
And the reason is that we have
[torvalds@ryzen linux]$ cat tools/testing/kunit/.gitattributes test_data/* binary
iow, you're telling git that everything in that test_data directory is binary blobs. Which isn't actually true.
This isn't new, but it was just more noticeable this time around.
That binary marker comes from commit afc63da64f1e ("kunit:kunit_parser: make parser more robust") and I'm not really seeing the reason for it.
Linus
Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Shuah Khan
.../kunit/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 .../kunit/test_data/test_multiple_prefixes.log | Bin 1832 -> 1861This diffstat is a bit annoying.
Oh, and another note: because you don't have the "[GIT PULL}" marker on the subject line, the pr-tracker-bot doesn't react to the pull requests, and you didn't get notified that it's been pulled.
Just FYI - I personally don't care, as your pull requests do show up in _my_ queue, because you have "git" and "pull" in the body of the message. But the automation doesn't see them.
Linus
Shuah Khan
maintainerQuoted 12 lines · Linus Torvalds
Quoted 9 lines · Linus Torvalds
Quoted 5 lines · Shuah Khan
.../kunit/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 .../kunit/test_data/test_multiple_prefixes.log | Bin 1832 -> 1861This diffstat is a bit annoying.
Quoted 8 lines
Oh, and another note: because you don't have the "[GIT PULL}" marker on the subject line, the pr-tracker-bot doesn't react to the pull requests, and you didn't get notified that it's been pulled.
Just FYI - I personally don't care, as your pull requests do show up in _my_ queue, because you have "git" and "pull" in the body of the message. But the automation doesn't see them.
Oops. I don't usually miss adding [GIT PULL] - will pay more attention.
I am sorry about that. My bad on my part. Can I chalk it up to this weird week?
thanks,
-- Shuah
Quoted 2 lines · Shuah Khan
Oops. I don't usually miss adding [GIT PULL] - will pay more attention.
No problem. As mentioned, my own workflow doesn't actually care as long as the body of the mail has that "please pull" and "git" mentioned.
And I wouldn't have noticed the pr-tracker-bot reply missing either, if it wasn't for the fact that I replied to the pull request for other reasons..
So no worries, just a note on how that "[GIT PULL]" marker might be helpful for _you_ to see "oh, Linus pulled it, I can forget about it".
Linus
Shuah Khan
maintainerQuoted 14 lines · Linus Torvalds
Quoted 5 lines · Shuah Khan
.../kunit/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 .../kunit/test_data/test_multiple_prefixes.log | Bin 1832 -> 1861This diffstat is a bit annoying.
And the reason is that we have
[torvalds@ryzen linux]$ cat
tools/testing/kunit/.gitattributestest_data/* binary
Quoted 9 lines
iow, you're telling git that everything in that
test_datadirectory is binary blobs. Which isn't actually true.This isn't new, but it was just more noticeable this time around.
That binary marker comes from commit
afc63da64f1e("kunit:kunit_parser: make parser more robust") and I'm not really seeing the reason for it.
You are right. It appears there is no need to add these binary blobs. Brendan and I discussed this and he will send a fix to remove the blobs and redo the test output. In other words fix commit afc63da64f1e.
Sorry for not catching this earlier.
thanks,
-- Shuah