<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/kunit, branch v5.15.53</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.15.53</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.15.53'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-10-06T23:54:07Z</updated>
<entry>
<title>kunit: fix kernel-doc warnings due to mismatched arg names</title>
<updated>2021-10-06T23:54:07Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-10-05T20:46:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=361b57df62de249dc0b2acbf48823662a5001bcd'/>
<id>urn:sha1:361b57df62de249dc0b2acbf48823662a5001bcd</id>
<content type='text'>
Commit 7122debb4367 ("kunit: introduce
kunit_kmalloc_array/kunit_kcalloc() helpers") added new functions but
called last arg `flags`, unlike the existing code that used `gfp`.
This only is an issue in test.h, test.c still used `gfp`.

But the documentation was copy-pasted with the old names, leading to
kernel-doc warnings.

Do s/flags/gfp to make the names consistent and fix the warnings.

Fixes: 7122debb4367 ("kunit: introduce kunit_kmalloc_array/kunit_kcalloc() helpers")
Reported-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'linux-kselftest-kunit-fixes-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest</title>
<updated>2021-07-02T19:58:26Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-07-02T19:58:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=a48ad6e7a35dc3f3b521249204daf4c9427628e5'/>
<id>urn:sha1:a48ad6e7a35dc3f3b521249204daf4c9427628e5</id>
<content type='text'>
Pull KUnit update from Shuah Khan:
 "Fixes and features:

   - add support for skipped tests

   - introduce kunit_kmalloc_array/kunit_kcalloc() helpers

   - add gnu_printf specifiers

   - add kunit_shutdown

   - add unit test for filtering suites by names

   - convert lib/test_list_sort.c to use KUnit

   - code organization moving default config to tools/testing/kunit

   - refactor of internal parser input handling

   - cleanups and updates to documentation

   - code cleanup related to casts"

* tag 'linux-kselftest-kunit-fixes-5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (29 commits)
  kunit: add unit test for filtering suites by names
  kasan: test: make use of kunit_skip()
  kunit: test: Add example tests which are always skipped
  kunit: tool: Support skipped tests in kunit_tool
  kunit: Support skipped tests
  thunderbolt: test: Reinstate a few casts of bitfields
  kunit: tool: internal refactor of parser input handling
  lib/test: convert lib/test_list_sort.c to use KUnit
  kunit: introduce kunit_kmalloc_array/kunit_kcalloc() helpers
  kunit: Remove the unused all_tests.config
  kunit: Move default config from arch/um -&gt; tools/testing/kunit
  kunit: arch/um/configs: Enable KUNIT_ALL_TESTS by default
  kunit: Add gnu_printf specifiers
  lib/cmdline_kunit: Remove a cast which are no-longer required
  kernel/sysctl-test: Remove some casts which are no-longer required
  thunderbolt: test: Remove some casts which are no longer required
  mmc: sdhci-of-aspeed: Remove some unnecessary casts from KUnit tests
  iio: Remove a cast in iio-test-format which is no longer required
  device property: Remove some casts in property-entry-test
  Documentation: kunit: Clean up some string casts in examples
  ...
</content>
</entry>
<entry>
<title>kunit: make test-&gt;lock irq safe</title>
<updated>2021-06-29T17:53:46Z</updated>
<author>
<name>Vlastimil Babka</name>
<email>vbabka@suse.cz</email>
</author>
<published>2021-06-29T02:34:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=26c6cb7cf830349c6518a7efe1c32ac796cd192e'/>
<id>urn:sha1:26c6cb7cf830349c6518a7efe1c32ac796cd192e</id>
<content type='text'>
The upcoming SLUB kunit test will be calling kunit_find_named_resource()
from a context with disabled interrupts.  That means kunit's test-&gt;lock
needs to be IRQ safe to avoid potential deadlocks and lockdep splats.

This patch therefore changes the test-&gt;lock usage to spin_lock_irqsave()
and spin_unlock_irqrestore().

Link: https://lkml.kernel.org/r/20210511150734.3492-1-glittao@gmail.com
Signed-off-by: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Signed-off-by: Oliver Glitta &lt;glittao@gmail.com&gt;
Reviewed-by: Brendan Higgins &lt;brendanhiggins@google.com&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Daniel Latypov &lt;dlatypov@google.com&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Marco Elver &lt;elver@google.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: Support skipped tests</title>
<updated>2021-06-25T17:31:03Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-06-25T06:58:12Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6d2426b2f258da19fbe5fa1c93a5695460390eac'/>
<id>urn:sha1:6d2426b2f258da19fbe5fa1c93a5695460390eac</id>
<content type='text'>
The kunit_mark_skipped() macro marks the current test as "skipped", with
the provided reason. The kunit_skip() macro will mark the test as
skipped, and abort the test.

The TAP specification supports this "SKIP directive" as a comment after
the "ok" / "not ok" for a test. See the "Directives" section of the TAP
spec for details:
https://testanything.org/tap-specification.html#directives

The 'success' field for KUnit tests is replaced with a kunit_status
enum, which can be SUCCESS, FAILURE, or SKIPPED, combined with a
'status_comment' containing information on why a test was skipped.

A new 'kunit_status' test suite is added to test this.

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Tested-by: Marco Elver &lt;elver@google.com&gt;
Reviewed-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: introduce kunit_kmalloc_array/kunit_kcalloc() helpers</title>
<updated>2021-06-25T17:31:03Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-05-03T20:58:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7122debb4367ee5c89237e5d36dcc0007d7ec43c'/>
<id>urn:sha1:7122debb4367ee5c89237e5d36dcc0007d7ec43c</id>
<content type='text'>
Add in:
* kunit_kmalloc_array() and wire up kunit_kmalloc() to be a special
case of it.
* kunit_kcalloc() for symmetry with kunit_kzalloc()

This should using KUnit more natural by making it more similar to the
existing *alloc() APIs.

And while we shouldn't necessarily be writing unit tests where overflow
should be a concern, it can't hurt to be safe.

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: Add gnu_printf specifiers</title>
<updated>2021-06-23T23:06:04Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-05-13T20:03:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=44acdbb250a57240ec113f12bd6229854681ea5f'/>
<id>urn:sha1:44acdbb250a57240ec113f12bd6229854681ea5f</id>
<content type='text'>
Some KUnit functions use variable arguments to implement a printf-like
format string. Use the __printf() attribute to let the compiler warn if
invalid format strings are passed in.

If the kernel is build with W=1, it complained about the lack of these
specifiers, e.g.:
../lib/kunit/test.c:72:2: warning: function ‘kunit_log_append’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Daniel Latypov &lt;dlatypov@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: Assign strings to 'const char*' in STREQ assertions</title>
<updated>2021-06-23T22:35:25Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-05-13T19:31:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3747b5c0d8ec8b03b0856e29241949baa0e67803'/>
<id>urn:sha1:3747b5c0d8ec8b03b0856e29241949baa0e67803</id>
<content type='text'>
Currently, the KUNIT_EXPECT_STREQ() and related macros assign both
string arguments to variables of their own type (via typeof()). This
seems to be to prevent the macro argument from being evaluated multiple
times.

However, this doesn't work if one of these is a fixed-length character
array, rather than a character pointer, as (for example) char[16] will
always allocate a new string.

By always using 'const char*' (the type strcmp expects), we're always
just taking a pointer to the string, which works even with character
arrays.

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-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: Do not typecheck binary assertions</title>
<updated>2021-06-23T22:34:27Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-05-13T19:31:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6e62dfa6d14f8fd2b07ad30b8a1c597d40d36ac1'/>
<id>urn:sha1:6e62dfa6d14f8fd2b07ad30b8a1c597d40d36ac1</id>
<content type='text'>
The use of typecheck() in KUNIT_EXPECT_EQ() and friends is causing more
problems than I think it's worth. Things like enums need to have their
values explicitly cast, and literals all need to be very precisely
typed, else a large warning will be printed.

While typechecking does have its uses, the additional overhead of having
lots of needless casts -- combined with the awkward error messages which
don't mention which types are involved -- makes tests less readable and
more difficult to write.

By removing the typecheck() call, the two arguments still need to be of
compatible types, but don't need to be of exactly the same time, which
seems a less confusing and more useful compromise.

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-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: 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.stealer.net/cgit.cgi/user/sven/linux.git/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.stealer.net/cgit.cgi/user/sven/linux.git/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>
