<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/tools/testing/kunit/kunit_parser.py, branch v5.19</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2022-05-16T19:22:36Z</updated>
<entry>
<title>kunit: tool: misc cleanups</title>
<updated>2022-05-16T19:22:36Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-05-09T20:49:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0453f984a7b9458f0e469afb039f2841308b1bef'/>
<id>urn:sha1:0453f984a7b9458f0e469afb039f2841308b1bef</id>
<content type='text'>
This primarily comes from running pylint over kunit tool code and
ignoring some warnings we don't care about.
If we ever got a fully clean setup, we could add this to run_checks.py,
but we're not there yet.

Fix things like
* Drop unused imports
* check `is None`, not `== None` (see PEP 8)
* remove redundant parens around returns
* remove redundant `else` / convert `elif` to `if` where appropriate
* rename make_arch_qemuconfig() param to base_kunitconfig (this is the
  name used in the subclass, and it's a better one)
* kunit_tool_test: check the exit code for SystemExit (could be 0)

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: minor cosmetic cleanups in kunit_parser.py</title>
<updated>2022-05-16T19:22:21Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-05-12T18:35:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=94507ee3e9aeafc5fcc429947b84016eabea6e64'/>
<id>urn:sha1:94507ee3e9aeafc5fcc429947b84016eabea6e64</id>
<content type='text'>
There should be no behavioral changes from this patch.

This patch removes redundant comment text, inlines a function used in
only one place, and other such minor tweaks.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: make parser stop overwriting status of suites w/ no_tests</title>
<updated>2022-05-16T19:22:12Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-05-12T18:35:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dbf0b0d53a2b5afa6ef7372dcedf52302669fc2c'/>
<id>urn:sha1:dbf0b0d53a2b5afa6ef7372dcedf52302669fc2c</id>
<content type='text'>
Consider this invocation
$ ./tools/testing/kunit/kunit.py parse &lt;&lt;EOF
  TAP version 14
  1..2
  ok 1 - suite
    # Subtest: no_tests_suite
    # catastrophic error!
  not ok 1 - no_tests_suite
EOF

It will have a 0 exit code even though there's a "not ok".

Consider this one:
$ ./tools/testing/kunit/kunit.py parse &lt;&lt;EOF
  TAP version 14
  1..2
  ok 1 - suite
  not ok 1 - no_tests_suite
EOF

It will a non-zero exit code.

Why?
We have this line in the kunit_parser.py
&gt; parent_test = parse_test_header(lines, test)
where we have special handling when we see "# Subtest" and we ignore the
explicit reported "not ok 1" status!

Also, NO_TESTS at a suite-level only results in a non-zero status code
where then there's only one suite atm.

This change is the minimal one to make sure we don't overwrite it.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: remove dead parse_crash_in_log() logic</title>
<updated>2022-05-16T19:21:54Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-05-12T18:35:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=33d4a933e9273bb9b33db8dcd0e564881319443c'/>
<id>urn:sha1:33d4a933e9273bb9b33db8dcd0e564881319443c</id>
<content type='text'>
This logic depends on the kernel logging a message containing
'kunit test case crashed', but there is no corresponding logic to do so.

This is likely a relic of the revision process KUnit initially went
through when being upstreamed.

Delete it given
1) it's been missing for years and likely won't get implemented
2) the parser has been moving to be a more general KTAP parser,
   kunit-only magic like this isn't how we'd want to implement it.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: print clearer error message when there's no TAP output</title>
<updated>2022-05-12T17:15:58Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-03-29T21:42:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9660209d9418f2295d31fea0d32e313e9b2c1200'/>
<id>urn:sha1:9660209d9418f2295d31fea0d32e313e9b2c1200</id>
<content type='text'>
Before:
$ ./tools/testing/kunit/kunit.py parse /dev/null
...
[ERROR] Test : invalid KTAP input!

After:
$ ./tools/testing/kunit/kunit.py parse /dev/null
...
[ERROR] Test &lt;missing&gt;: could not find any KTAP output!

This error message gets printed out when extract_tap_output() yielded no
lines. So while it could be because of malformed KTAP output from KUnit,
it could also be due to not having any KTAP output at all.

Try and make the error message here more clear.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: update test counts summary line format</title>
<updated>2022-05-12T17:15:26Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2022-04-08T21:51:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c249764320cba8ab42821b0c7dad75f117c853e4'/>
<id>urn:sha1:c249764320cba8ab42821b0c7dad75f117c853e4</id>
<content type='text'>
Before:
&gt; Testing complete. Passed: 137, Failed: 0, Crashed: 0, Skipped: 36, Errors: 0

After:
&gt; Testing complete. Ran 173 tests: passed: 137, skipped: 36

Even with our current set of statuses, the output is a bit verbose.
It could get worse in the future if we add more (e.g. timeout, kasan).
Let's only print the relevant ones.

I had previously been sympathetic to the argument that always
printing out all the statuses would make it easier to parse results.
But now we have commit acd8e8407b8f ("kunit: Print test statistics on
failure"), there are test counts printed out in the raw output.
We don't currently print out an overall total across all suites, but it
would be easy to add, if we see a need for that.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Co-developed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: Do not colorize output when redirected</title>
<updated>2022-04-04T21:23:50Z</updated>
<author>
<name>Kees Cook</name>
<email>keescook@chromium.org</email>
</author>
<published>2022-02-24T05:53:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d34f82d67d2b1bdbed6bf343f0c9e6d828438976'/>
<id>urn:sha1:d34f82d67d2b1bdbed6bf343f0c9e6d828438976</id>
<content type='text'>
Filling log files with color codes makes diffs and other comparisons
difficult. Only emit vt100 codes when the stdout is a TTY.

Cc: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: linux-kselftest@vger.kernel.org
Cc: kunit-dev@googlegroups.com
Signed-off-by: Kees Cook &lt;keescook@chromium.org&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: fix newly introduced typechecker errors</title>
<updated>2021-12-15T23:44:49Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-12-15T20:39:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=85310a62ca4e415980e30d9d07f904444197cfc4'/>
<id>urn:sha1:85310a62ca4e415980e30d9d07f904444197cfc4</id>
<content type='text'>
After upgrading mypy and pytype from pip, we see 2 new errors when
running ./tools/testing/kunit/run_checks.py.

Error #1: mypy and pytype
They now deduce that importlib.util.spec_from_file_location() can return
None and note that we're not checking for this.

We validate that the arch is valid (i.e. the file exists) beforehand.
Add in an `asssert spec is not None` to appease the checkers.

Error #2: pytype bug https://github.com/google/pytype/issues/1057
It doesn't like `from datetime import datetime`, specifically that a
type shares a name with a module.

We can workaround this by either
* renaming the import or just using `import datetime`
* passing the new `--fix-module-collisions` flag to pytype.

We pick the first option for now because
* the flag is quite new, only in the 2021.11.29 release.
* I'd prefer if people can just run `pytype &lt;file&gt;`

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: delete kunit_parser.TestResult type</title>
<updated>2021-12-15T18:50:56Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-12-14T19:26:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e0cc8c052a3992b01f51df1d51eaae49e5b2710f'/>
<id>urn:sha1:e0cc8c052a3992b01f51df1d51eaae49e5b2710f</id>
<content type='text'>
The `log` field is unused, and the `status` field is accessible via
`test.status`.

So it's simpler to just return the main `Test` object directly.

And since we're no longer returning a namedtuple, which has no type
annotations, this hopefully means typecheckers are better equipped to
find any errors.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: print parsed test results fully incrementally</title>
<updated>2021-12-13T20:37:38Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-10-07T21:14:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=142189f09cdf89e353e4a2dc558a7ad27b25f36d'/>
<id>urn:sha1:142189f09cdf89e353e4a2dc558a7ad27b25f36d</id>
<content type='text'>
With the parser rework [1] and run_kernel() rework [2], this allows the
parser to print out test results incrementally.

Currently, that's held up by the fact that the LineStream eagerly
pre-fetches the next line when you call pop().
This blocks parse_test_result() from returning until the line *after*
the "ok 1 - test name" line is also printed.

One can see this with the following example:
$ (echo -e 'TAP version 14\n1..3\nok 1 - fake test'; sleep 2; echo -e 'ok 2 - fake test 2'; sleep 3; echo -e 'ok 3 - fake test 3') | ./tools/testing/kunit/kunit.py parse

Before this patch [1]: there's a pause before 'fake test' is printed.
After this patch: 'fake test' is printed out immediately.

This patch also adds
* a unit test to verify LineStream's behavior directly
* a test case to ensure that it's lazily calling the generator
* an explicit exception for when users go beyond EOF

[1] https://lore.kernel.org/linux-kselftest/20211006170049.106852-1-dlatypov@google.com/
[2] https://lore.kernel.org/linux-kselftest/20211005011340.2826268-1-dlatypov@google.com/

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
</feed>
