kunit.action=list prints the name of every suite and test in one burst during boot, which on a large configuration such as --alltests comes to several thousand lines. That is more than the default 128KiB printk ring buffer (CONFIG_LOG_BUF_SHIFT=17, overridden by many defconfigs) can hold, and since the console drains more slowly than the executor prints the buffer wraps and lines can easily be dropped.
If the KTAP header is dropped _list_tests() fails with: ValueError: LineStream: going past EOF, last line was but otherwise the loss is silent, --list_tests prints an incomplete list and --run_isolated=test will execute a timing dependent sent of tests. Pass log_buf_len=4M on the kernel command line when booting to list tests so that the whole list fits in the buffer, at least until we get substantially more tests than we currently have. Signed-off-by: Mark Brown <[email protected]> --- tools/testing/kunit/kunit.py | 11 +++++++++-- tools/testing/kunit/kunit_tool_test.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index aea67b6a72c4..971e70b0fb1a 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -109,8 +109,15 @@ def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree, return build_tests(linux, request) +# kunit.action=list prints every suite and test name in one burst at boot, +# which can be thousands of lines on a large config. That easily overflows +# the default 128KiB printk buffer before the console has drained it, so +# lines (sometimes including the KTAP header) are dropped and the list +# comes out incomplete. Give the kernel a large enough buffer to hold it. +_LIST_KERNEL_ARGS = ['log_buf_len=4M'] + def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> List[str]: - args = ['kunit.action=list'] + args = ['kunit.action=list'] + _LIST_KERNEL_ARGS if request.kernel_args: args.extend(request.kernel_args) @@ -129,7 +136,7 @@ def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) return [l for l in lines if re.match(r'^[^\s.]+\.[^\s.]+$', l)] def _list_tests_attr(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> Iterable[str]: - args = ['kunit.action=list_attr'] + args = ['kunit.action=list_attr'] + _LIST_KERNEL_ARGS if request.kernel_args: args.extend(request.kernel_args) diff --git a/tools/testing/kunit/kunit_tool_test.py b/tools/testing/kunit/kunit_tool_test.py index 4590108e4306..17f926ef2820 100755 --- a/tools/testing/kunit/kunit_tool_test.py +++ b/tools/testing/kunit/kunit_tool_test.py @@ -979,7 +979,7 @@ class KUnitMainTest(unittest.TestCase): self.assertEqual(got, want) # Should respect the user's filter glob when listing tests. self.linux_source_mock.run_kernel.assert_called_once_with( - args=['kunit.action=list'], build_dir='.kunit', filter_glob='suite*', filter='', filter_action=None, timeout=300) + args=['kunit.action=list', 'log_buf_len=4M'], build_dir='.kunit', filter_glob='suite*', filter='', filter_action=None, timeout=300) def test_list_tests_with_prefix(self): want = ['suite.test1', 'suite.test2', 'suite2.test1'] -- 2.47.3

