<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/include/kunit/test-bug.h, branch v5.14</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.14</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.14'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-04-06T21:22:39Z</updated>
<entry>
<title>kunit: fix -Wunused-function warning for __kunit_fail_current_test</title>
<updated>2021-04-06T21:22:39Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-04-06T17:29:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f65968ac191bd5f31091ff132191bf2ce3aed6c8'/>
<id>urn:sha1:f65968ac191bd5f31091ff132191bf2ce3aed6c8</id>
<content type='text'>
When CONFIG_KUNIT is not enabled, __kunit_fail_current_test() an empty
static function.

But GCC complains about unused static functions, *unless* they're static
inline.  So add inline to make GCC happy.

Fixes: 359a376081d4 ("kunit: support failure from dynamic analysis tools")
Reported-by: Stephen Rothwell &lt;sfr@canb.auug.org.au&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: support failure from dynamic analysis tools</title>
<updated>2021-04-02T20:19:58Z</updated>
<author>
<name>Uriel Guajardo</name>
<email>urielguajardo@google.com</email>
</author>
<published>2021-03-11T15:23:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=359a376081d4fadfb073e3ddeb6bd6dc94d98341'/>
<id>urn:sha1:359a376081d4fadfb073e3ddeb6bd6dc94d98341</id>
<content type='text'>
Add a kunit_fail_current_test() function to fail the currently running
test, if any, with an error message.

This is largely intended for dynamic analysis tools like UBSAN and for
fakes.
E.g. say I had a fake ops struct for testing and I wanted my `free`
function to complain if it was called with an invalid argument, or
caught a double-free. Most return void and have no normal means of
signalling failure (e.g. super_operations, iommu_ops, etc.).

Key points:
* Always update current-&gt;kunit_test so anyone can use it.
  * commit 83c4e7a0363b ("KUnit: KASAN Integration") only updated it for
  CONFIG_KASAN=y

* Create a new header &lt;kunit/test-bug.h&gt; so non-test code doesn't have
to include all of &lt;kunit/test.h&gt; (e.g. lib/ubsan.c)

* Forward the file and line number to make it easier to track down
failures

* Declare the helper function for nice __printf() warnings about mismatched
format strings even when KUnit is not enabled.

Example output from kunit_fail_current_test("message"):
[15:19:34] [FAILED] example_simple_test
[15:19:34]     # example_simple_test: initializing
[15:19:34]     # example_simple_test: lib/kunit/kunit-example-test.c:24: message
[15:19:34]     not ok 1 - example_simple_test

Fixed minor check patch with checkpatch --fix option:
Shuah Khan &lt;skhan@linuxfoundation.org&gt;

Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Signed-off-by: Uriel Guajardo &lt;urielguajardo@google.com&gt;
Reviewed-by: Alan Maguire &lt;alan.maguire@oracle.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
</feed>
