Re: [PATCH i-g-t v2 3/4] lib/igt_kmod: add compatibility for KUnit
From: Daniel Latypov
Date: Mon Sep 19 2022 - 20:25:58 EST
On Mon, Sep 19, 2022 at 1:43 PM Isabella Basso <isabbasso@xxxxxxxxxx> wrote:
> >> + * "(K)TAP version XX" should be the first line on all (sub)tests as per
> >> + * https://www.kernel.org/doc/html/latest/dev-tools/ktap.html#version-lines
> >> + * but actually isn't, as it currently depends on whoever writes the
> >> + * test to print this info
> >
> > FYI: we're really trying to fix cases of "missing version lines",
> > largely by making the kunit_test_suites() macro work in more
> > circumstances.
> >
> > So while it may be worth still handling the case where this is
> > missing, I don't think there are any tests in the latest versions of
> > the kernel which should have this missing.
>
> I’m not sure if I totally get how these work. Every time I run a KUnit test I
> get something like this: https://pastebin.com/7Ff31PMC
>
> As you can see it has been loaded as a module, just like we intend to do it
> from IGT, and I see no version lines whatsoever. Am I doing something wrong?
You're doing everything right.
The problem is we only print the version line for the *built-in* tests.
It never gets printed for tests in loadable modules.
Some more details below, if interested.
Specifically, it happens in
https://elixir.bootlin.com/linux/latest/C/ident/kunit_print_tap_header
What David is referring to is we had tests that weren't in modules,
but didn't use the normal built-in code path. Those were also missing
TAP version lines.
But KUnit needs to do better here in the case of modules.
The goal was that you'd be able to parse the result of module based
tests by something like
$ cat /sys/kernel/debug/kunit/*/results | ./tools/testing/kunit/kunit.py parse
but this doesn't work because of the lack of a version line.
If we add it to each module's test results, then we'll need to update
the parse to allow multiple verison lines, I think.
Daniel