Re: [PATCH v1 1/2] kunit: improve KTAP compliance of KUnit test output

Daniel Latypov
2022-11-07T22:27:39Z

On Fri, Nov 4, 2022 at 12:48 PM Rae Moar <rmoar@google.com> wrote:
>
> Change KUnit test output to comply with KTAP version 1 specifications
> found here: https://kernel.org/doc/html/latest/dev-tools/ktap.html.
> 1) Use "KTAP version 1" instead of "TAP version 14" as test output header
> 2) Remove '-' between test number and test name on test result lines
> 2) Add KTAP version lines to each subtest header as well
>
> Original output:
>
> TAP version 14
> 1..1
> # Subtest: kunit-test-suite
> 1..3
> ok 1 - kunit_test_1
> ok 2 - kunit_test_2
> ok 3 - kunit_test_3
> # kunit-test-suite: pass:3 fail:0 skip:0 total:3
> # Totals: pass:3 fail:0 skip:0 total:3
> ok 1 - kunit-test-suite
>
> New output:
>
> KTAP version 1
> 1..1
> # Subtest: kunit-test-suite
> KTAP version 1
> 1..3
> ok 1 kunit_test_1
> ok 2 kunit_test_2
> ok 3 kunit_test_3
> # kunit-test-suite: pass:3 fail:0 skip:0 total:3
> # Totals: pass:3 fail:0 skip:0 total:3
> ok 1 kunit-test-suite
>
> Signed-off-by: Rae Moar <rmoar@google.com>

Reviewed-by: Daniel Latypov <dlatypov@google.com>

I had been worried initially that this needed kunit_parser.py changes to work.
But it doesn't, this change can go in now with minimal side effects.

More details below:
This code treats the new "KTAP version 1" subheaders as random kernel
output, so it puts it into the `test.log`

E.g. if I change to `not ok 1 kunit_test_1`, it'll print
KTAP version 1
1..3
not ok 1 kunit_test_1

After the next patch, it just prints
not ok 1 kunit_test_1

This bit of extra output on failure is something we can live with,
esp. since it gets addressed by the next patch.