linux-kselftest-kunit-fixes-5.10-rc3
This Kunit update for Linux 5.10-rc3 consists of several kunit_tool and documentation fixes. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAl+kIFcACgkQCwJExA0N QxyQZw//UY+j9RFweODCfP+hfYYcv71/J8ZAD+L9mcu4+zm85nrJ5vy1LAMGB7km Wwi7NvJtbzjcJ/CEdKEOL/GZJsGoUFit0keFm0CmUcul751M/SuxbXGfST5e0LTQ E7MPpQOYWklMEdu+WbofW8wy77Fk57J5k2/IfVTBiFxGuEmiAfb32HSyN9emTgYt 4xeOJfq3hl5+ns00WbScDiu3jdmrEkvEoe1FKFAPHqBWfUeOioYMY3CagggiCvrp Ml5Nhd8gqDjBv7DDaZCGq2o0ibM61EZj26l363ZvcsWYiXdSlcjfnw6rEF3T1GTD sM5ky7bUbEZEM7v6kVZa6YiUVgRr5gE794s4fIpTJqUHkSg0wURjNNQlE/yr2GUt pGV3NtEMH+27n4EdkEZbufLGpcUz3bnH2yrAPpfpGhDnkfnCjlT56rbEiCvpjfPd 7lKUJXbl6YAEJpQC1oV3HywUEW7ckyxKXseLv0xh0hjkjjMNiy3w9+SQtdaKKx2Q r6MKpUqDg+wxyz6bcb66JlZq/LRIlYydsCciU0VjIX+rAI7OTdNC7tph9qa6Vh/D 1LUJegumDhPlh6zqHvUWaH0m42cUbfGfODo7NbqlndQz2Ocg9Vg4bll0HA8WR6h8 u3UOeL5EE84gGmUP1mLicVqgoc3CLgVmpahkFHhf3lsH4iX7SKM= =2gLZ -----END PGP SIGNATURE----- Merge tag 'linux-kselftest-kunit-fixes-5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest Pull Kunit fixes from Shuah Khan: "Several kunit_tool and documentation fixes" * tag 'linux-kselftest-kunit-fixes-5.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kunit: tools: fix kunit_tool tests for parsing test plans Documentation: kunit: Update Kconfig parts for KUNIT's module support kunit: test: fix remaining kernel-doc warnings kunit: Don't fail test suites if one of them is empty kunit: Fix kunit.py --raw_output option
This commit is contained in:
commit
521b619acd
@ -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``:
|
||||
|
||||
|
@ -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
|
||||
-----------------------------------------
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
[ 0.060000] printk: console [mc-1] enabled
|
||||
[ 0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
[ 0.060000] TAP version 14
|
||||
[ 0.060000] 1..3
|
||||
[ 0.060000] # Subtest: kunit-resource-test
|
||||
[ 0.060000] 1..5
|
||||
[ 0.060000] ok 1 - kunit_resource_test_init_resources
|
||||
@ -28,4 +29,4 @@
|
||||
[ 0.060000] Stack:
|
||||
[ 0.060000] 602086f8 601bc260 705c0000 705c0000
|
||||
[ 0.060000] 602086f8 6005fcec 705c0000 6002c6ab
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
|
@ -1,6 +1,7 @@
|
||||
[ 0.060000] printk: console [mc-1] enabled
|
||||
[ 0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
[ 0.060000] TAP version 14
|
||||
[ 0.060000] 1..3
|
||||
[ 0.060000] # Subtest: kunit-resource-test
|
||||
[ 0.060000] 1..5
|
||||
[ 0.060000] ok 1 - kunit_resource_test_init_resources
|
||||
@ -34,4 +35,4 @@
|
||||
[ 0.060000] Stack:
|
||||
[ 0.060000] 602086f8 601bc260 705c0000 705c0000
|
||||
[ 0.060000] 602086f8 6005fcec 705c0000 6002c6ab
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
|
@ -1,6 +1,7 @@
|
||||
[ 0.060000] printk: console [mc-1] enabled
|
||||
[ 0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
[ 0.060000] TAP version 14
|
||||
[ 0.060000] 1..3
|
||||
[ 0.060000] # Subtest: kunit-resource-test
|
||||
[ 0.060000] 1..5
|
||||
[ 0.060000] ok 1 - kunit_resource_test_init_resources
|
||||
@ -22,4 +23,4 @@
|
||||
[ 0.060000] Stack:
|
||||
[ 0.060000] 602086f8 601bc260 705c0000 705c0000
|
||||
[ 0.060000] 602086f8 6005fcec 705c0000 6002c6ab
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
[ 0.060000] 6005fcec 601bc260 705c0000 3000000010
|
||||
|
@ -1,6 +1,7 @@
|
||||
[ 0.060000][ T1] printk: console [mc-1] enabled
|
||||
[ 0.060000][ T1] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
[ 0.060000][ T1] TAP version 14
|
||||
[ 0.060000][ T1] 1..3
|
||||
[ 0.060000][ T1] # Subtest: kunit-resource-test
|
||||
[ 0.060000][ T1] 1..5
|
||||
[ 0.060000][ T1] ok 1 - kunit_resource_test_init_resources
|
||||
@ -28,4 +29,4 @@
|
||||
[ 0.060000][ T1] Stack:
|
||||
[ 0.060000][ T1] 602086f8 601bc260 705c0000 705c0000
|
||||
[ 0.060000][ T1] 602086f8 6005fcec 705c0000 6002c6ab
|
||||
[ 0.060000][ T1] 6005fcec 601bc260 705c0000 3000000010
|
||||
[ 0.060000][ T1] 6005fcec 601bc260 705c0000 3000000010
|
||||
|
@ -1,6 +1,7 @@
|
||||
printk: console [mc-1] enabled
|
||||
random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
TAP version 14
|
||||
1..3
|
||||
# Subtest: kunit-resource-test
|
||||
1..5
|
||||
ok 1 - kunit_resource_test_init_resources
|
||||
@ -30,4 +31,4 @@
|
||||
Stack:
|
||||
602086f8 601bc260 705c0000 705c0000
|
||||
602086f8 6005fcec 705c0000 6002c6ab
|
||||
6005fcec 601bc260 705c0000 3000000010
|
||||
6005fcec 601bc260 705c0000 3000000010
|
||||
|
@ -1,6 +1,7 @@
|
||||
[ 0.060000] printk: console [mc-1] enabled
|
||||
[ 0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
|
||||
[ 0.060000] TAP version 14
|
||||
[ 0.060000] 1..3
|
||||
[ 0.060000] # Subtest: kunit-resource-test
|
||||
[ 0.060000] 1..5
|
||||
[ 0.060000] ok 1 - kunit_resource_test_init_resources
|
||||
|
Loading…
Reference in New Issue
Block a user