linux/tools/testing/kunit
Daniel Latypov c2bb92bc4e kunit: tool: make parser preserve whitespace when printing test log
Currently, kunit_parser.py is stripping all leading whitespace to make
parsing easier. But this means we can't accurately show kernel output
for failing tests or when the kernel crashes.

Embarassingly, this affects even KUnit's own output, e.g.
[13:40:46] Expected 2 + 1 == 2, but
[13:40:46] 2 + 1 == 3 (0x3)
[13:40:46] not ok 1 example_simple_test
[13:40:46] [FAILED] example_simple_test

After this change, here's what the output in context would look like
[13:40:46] =================== example (4 subtests) ===================
[13:40:46] # example_simple_test: initializing
[13:40:46] # example_simple_test: EXPECTATION FAILED at lib/kunit/kunit-example-test.c:29
[13:40:46] Expected 2 + 1 == 2, but
[13:40:46]     2 + 1 == 3 (0x3)
[13:40:46] [FAILED] example_simple_test
[13:40:46] [SKIPPED] example_skip_test
[13:40:46] [SKIPPED] example_mark_skipped_test
[13:40:46] [PASSED] example_all_expect_macros_test
[13:40:46]     # example: initializing suite
[13:40:46] # example: pass:1 fail:1 skip:2 total:4
[13:40:46] # Totals: pass:1 fail:1 skip:2 total:4
[13:40:46] ===================== [FAILED] example =====================

This example shows one minor cosmetic defect this approach has.
The test counts lines prevent us from dedenting the suite-level output.
But at the same time, any form of non-KUnit output would do the same
unless it happened to be indented as well.

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-12-12 14:13:48 -07:00
..
configs kunit: tool: rename all_test_uml.config, use it for --alltests 2022-09-30 13:22:55 -06:00
qemu_configs kunit: tool: Don't download risc-v opensbi firmware with wget 2022-10-07 10:16:28 -06:00
test_data kunit: tool: parse KTAP compliant test output 2022-12-12 14:13:47 -07:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
kunit_config.py kunit: tool: make --kunitconfig repeatable, blindly concat 2022-07-08 11:22:02 -06:00
kunit_json.py kunit: tool: misc cleanups 2022-05-16 13:22:36 -06:00
kunit_kernel.py kunit: tool: rename all_test_uml.config, use it for --alltests 2022-09-30 13:22:55 -06:00
kunit_parser.py kunit: tool: make parser preserve whitespace when printing test log 2022-12-12 14:13:48 -07:00
kunit_printer.py kunit: tool: refactoring printing logic into kunit_printer.py 2022-07-07 17:46:25 -06:00
kunit_tool_test.py kunit: tool: make parser preserve whitespace when printing test log 2022-12-12 14:13:48 -07:00
kunit.py kunit: tool: make parser preserve whitespace when printing test log 2022-12-12 14:13:48 -07:00
qemu_config.py kunit: tool: drop last uses of collections.namedtuple 2022-04-04 14:25:53 -06:00
run_checks.py kunit: tool: misc cleanups 2022-05-16 13:22:36 -06:00