<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/tools/testing/kunit/kunit_kernel.py, branch v5.11</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.11</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.11'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-01-16T00:52:12Z</updated>
<entry>
<title>kunit: tool: move kunitconfig parsing into __init__, make it optional</title>
<updated>2021-01-16T00:52:12Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-01-15T00:39:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b8fdbbf1c616300312f71fe5b21fe8f03129950'/>
<id>urn:sha1:2b8fdbbf1c616300312f71fe5b21fe8f03129950</id>
<content type='text'>
LinuxSourceTree will unceremoniously crash if the user doesn't call
read_kunitconfig() first in a number of functions.

And currently every place we create an instance, the caller also calls
create_kunitconfig() and read_kunitconfig().
Move these instead into __init__() so they can't be forgotten and to
reduce copy-paste.

The https://github.com/google/pytype type-checker complained that
_config wasn't initialized. With this, kunit_tool now type checks
under both pytype and mypy.

Add an optional boolean that can be used to disable this for use cases
in the future where we might not need/want to load the config.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: surface and address more typing issues</title>
<updated>2021-01-16T00:49:34Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-01-15T00:39:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=09641f7c7d8f1309fe9ad9ce4e6a1697016d73ba'/>
<id>urn:sha1:09641f7c7d8f1309fe9ad9ce4e6a1697016d73ba</id>
<content type='text'>
The authors of this tool were more familiar with a different
type-checker, https://github.com/google/pytype.

That's open source, but mypy seems more prevalent (and runs faster).
And unlike pytype, mypy doesn't try to infer types so it doesn't check
unanotated functions.

So annotate ~all functions in kunit tool to increase type-checking
coverage.
Note: per https://www.python.org/dev/peps/pep-0484/, `__init__()` should
be annotated as `-&gt; None`.

Doing so makes mypy discover a number of new violations.
Exclude main() since we reuse `request` for the different types of
requests, which mypy isn't happy about.

This commit fixes all but one error, where `TestSuite.status` might be
None.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Acked-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: tool: Force the use of the 'tty' console for UML</title>
<updated>2021-01-04T16:18:38Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2020-12-22T07:39:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=65a4e5299739abe0888cda0938d21f8ea3b5c606'/>
<id>urn:sha1:65a4e5299739abe0888cda0938d21f8ea3b5c606</id>
<content type='text'>
kunit_tool relies on the UML console outputting printk() output to the
tty in order to get results. Since the default console driver could
change, pass 'console=tty' to the kernel.

This is triggered by a change[1] to use ttynull as a fallback console
driver which -- by chance or by design -- seems to have changed the
default console output on UML, breaking kunit_tool. While this may be
fixed, we should be less fragile to such changes in the default.

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=757055ae8dedf5333af17b3b5b4b70ba9bc9da4e

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Fixes: 757055ae8ded ("init/console: Use ttynull as a fallback when there is no console")
Reported-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Tested-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Acked-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: Introduce get_file_path() helper</title>
<updated>2020-11-30T20:56:30Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2020-10-26T16:59:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f3ed003e64fe7faecbe4c34bd2a1f5571a23f05a'/>
<id>urn:sha1:f3ed003e64fe7faecbe4c34bd2a1f5571a23f05a</id>
<content type='text'>
Helper allows to derive file names depending on --build_dir argument.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-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 out stderr from make (like build warnings)</title>
<updated>2020-11-10T20:43:22Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2020-10-29T22:09:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=390881448b1ff1e9d82896abbbda7cdb8e0be27c'/>
<id>urn:sha1:390881448b1ff1e9d82896abbbda7cdb8e0be27c</id>
<content type='text'>
Currently the tool redirects make stdout + stderr, and only shows them
if the make command fails.
This means build warnings aren't shown to the user.

This change prints the contents of stderr even if make succeeds, under
the assumption these are only build warnings or other messages the user
likely wants to see.

We drop stdout from the raised exception since we can no longer easily
collate stdout and stderr and just showing the stderr seems fine.

Example with a warning:

[14:56:35] Building KUnit Kernel ...
../lib/kunit/kunit-test.c: In function ‘kunit_test_successful_try’:
../lib/kunit/kunit-test.c:19:6: warning: unused variable ‘unused’ [-Wunused-variable]
   19 |  int unused;
      |      ^~~~~~

[14:56:40] Starting KUnit Kernel ...

Note the stderr has a trailing \n, and since we use print, we add
another, but it helps separate make and kunit.py output.

Example with a build error:

[15:02:45] Building KUnit Kernel ...
ERROR:root:../lib/kunit/kunit-test.c: In function ‘kunit_test_successful_try’:
../lib/kunit/kunit-test.c:19:2: error: unknown type name ‘invalid_type’
   19 |  invalid_type *test = data;
      |  ^~~~~~~~~~~~
...

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: Do not pollute source directory with generated files (test.log)</title>
<updated>2020-11-10T20:31:16Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2020-10-26T16:59:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=128dc4bcc8c0c7c3bab4a3818a1ec608cccb017a'/>
<id>urn:sha1:128dc4bcc8c0c7c3bab4a3818a1ec608cccb017a</id>
<content type='text'>
When --build_dir is provided use it and do not pollute source directory
which even can be mounted over network or read-only.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: Do not pollute source directory with generated files (.kunitconfig)</title>
<updated>2020-11-10T20:12:54Z</updated>
<author>
<name>Andy Shevchenko</name>
<email>andriy.shevchenko@linux.intel.com</email>
</author>
<published>2020-10-26T16:59:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fcdb0bc08ced274078f371e1e0fe6421a97fa9f2'/>
<id>urn:sha1:fcdb0bc08ced274078f371e1e0fe6421a97fa9f2</id>
<content type='text'>
When --build_dir is provided use it and do not pollute source directory
which even can be mounted over network or read-only.

Signed-off-by: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-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 display of make errors</title>
<updated>2020-10-09T20:04:09Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2020-09-30T18:31:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1abdd39f14b25dd2d69096b624a4f86f158a9feb'/>
<id>urn:sha1:1abdd39f14b25dd2d69096b624a4f86f158a9feb</id>
<content type='text'>
CalledProcessError stores the output of the failed process as `bytes`,
not a `str`.

So when we log it on build error, the make output is all crammed into
one line with "\n" instead of actually printing new lines.

After this change, we get readable output with new lines, e.g.
&gt;   CC      lib/kunit/kunit-example-test.o
&gt; In file included from ../lib/kunit/test.c:9:
&gt; ../include/kunit/test.h:22:1: error: unknown type name ‘invalid_type_that_causes_compile’
&gt;    22 | invalid_type_that_causes_compile errors;
&gt;       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&gt; make[3]: *** [../scripts/Makefile.build:283: lib/kunit/test.o] Error 1

Secondly, trying to concat exceptions to strings will fail with
&gt; TypeError: can only concatenate str (not "OSError") to str
so fix this with an explicit cast to str.

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-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 --alltests flag</title>
<updated>2020-09-23T21:52:11Z</updated>
<author>
<name>Brendan Higgins</name>
<email>brendanhiggins@google.com</email>
</author>
<published>2020-09-23T21:19:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=67e2fae3b767fd4444f3f161f6420d0d0338a10d'/>
<id>urn:sha1:67e2fae3b767fd4444f3f161f6420d0d0338a10d</id>
<content type='text'>
Alltests flag evidently stopped working when run from outside of the
root of the source tree, so fix that. Also add an additional broken
config to the broken_on_uml config.

Signed-off-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: capture stderr on all make subprocess calls</title>
<updated>2020-07-17T20:13:19Z</updated>
<author>
<name>Will Chen</name>
<email>chenwi@google.com</email>
</author>
<published>2020-07-08T21:35:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5a9fcad71caa970f30aef99134a1cd19bc4b8eea'/>
<id>urn:sha1:5a9fcad71caa970f30aef99134a1cd19bc4b8eea</id>
<content type='text'>
Direct stderr to subprocess.STDOUT so error messages get included in the
subprocess.CalledProcessError exceptions output field. This results in
more meaningful error messages for the user.

This is already being done in the make_allyesconfig method. Do the same
for make_mrproper, make_olddefconfig, and make methods.

With this, failures on unclean trees [1] will give users an error
message that includes:
"The source tree is not clean, please run 'make ARCH=um mrproper'"

[1] https://bugzilla.kernel.org/show_bug.cgi?id=205219

Signed-off-by: Will Chen &lt;chenwi@google.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Tested-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
</feed>
