<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/lib/kunit, branch v5.17</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.17</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.17'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2022-01-17T03:49:30Z</updated>
<entry>
<title>Merge branch 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace</title>
<updated>2022-01-17T03:49:30Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2022-01-17T03:49:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=35ce8ae9ae2e471f92759f9d6880eab42cc1c3b6'/>
<id>urn:sha1:35ce8ae9ae2e471f92759f9d6880eab42cc1c3b6</id>
<content type='text'>
Pull signal/exit/ptrace updates from Eric Biederman:
 "This set of changes deletes some dead code, makes a lot of cleanups
  which hopefully make the code easier to follow, and fixes bugs found
  along the way.

  The end-game which I have not yet reached yet is for fatal signals
  that generate coredumps to be short-circuit deliverable from
  complete_signal, for force_siginfo_to_task not to require changing
  userspace configured signal delivery state, and for the ptrace stops
  to always happen in locations where we can guarantee on all
  architectures that the all of the registers are saved and available on
  the stack.

  Removal of profile_task_ext, profile_munmap, and profile_handoff_task
  are the big successes for dead code removal this round.

  A bunch of small bug fixes are included, as most of the issues
  reported were small enough that they would not affect bisection so I
  simply added the fixes and did not fold the fixes into the changes
  they were fixing.

  There was a bug that broke coredumps piped to systemd-coredump. I
  dropped the change that caused that bug and replaced it entirely with
  something much more restrained. Unfortunately that required some
  rebasing.

  Some successes after this set of changes: There are few enough calls
  to do_exit to audit in a reasonable amount of time. The lifetime of
  struct kthread now matches the lifetime of struct task, and the
  pointer to struct kthread is no longer stored in set_child_tid. The
  flag SIGNAL_GROUP_COREDUMP is removed. The field group_exit_task is
  removed. Issues where task-&gt;exit_code was examined with
  signal-&gt;group_exit_code should been examined were fixed.

  There are several loosely related changes included because I am
  cleaning up and if I don't include them they will probably get lost.

  The original postings of these changes can be found at:
     https://lkml.kernel.org/r/87a6ha4zsd.fsf@email.froward.int.ebiederm.org
     https://lkml.kernel.org/r/87bl1kunjj.fsf@email.froward.int.ebiederm.org
     https://lkml.kernel.org/r/87r19opkx1.fsf_-_@email.froward.int.ebiederm.org

  I trimmed back the last set of changes to only the obviously correct
  once. Simply because there was less time for review than I had hoped"

* 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (44 commits)
  ptrace/m68k: Stop open coding ptrace_report_syscall
  ptrace: Remove unused regs argument from ptrace_report_syscall
  ptrace: Remove second setting of PT_SEIZED in ptrace_attach
  taskstats: Cleanup the use of task-&gt;exit_code
  exit: Use the correct exit_code in /proc/&lt;pid&gt;/stat
  exit: Fix the exit_code for wait_task_zombie
  exit: Coredumps reach do_group_exit
  exit: Remove profile_handoff_task
  exit: Remove profile_task_exit &amp; profile_munmap
  signal: clean up kernel-doc comments
  signal: Remove the helper signal_group_exit
  signal: Rename group_exit_task group_exec_task
  coredump: Stop setting signal-&gt;group_exit_task
  signal: Remove SIGNAL_GROUP_COREDUMP
  signal: During coredumps set SIGNAL_GROUP_EXIT in zap_process
  signal: Make coredump handling explicit in complete_signal
  signal: Have prepare_signal detect coredumps using signal-&gt;core_state
  signal: Have the oom killer detect coredumps using signal-&gt;core_state
  exit: Move force_uaccess back into do_exit
  exit: Guarantee make_task_dead leaks the tsk when calling do_task_exit
  ...
</content>
</entry>
<entry>
<title>kunit: Report test parameter results as (K)TAP subtests</title>
<updated>2021-12-13T20:36:29Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-11-02T07:30:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=44b7da5fcd4c99de1ec5cc783cdd605398246280'/>
<id>urn:sha1:44b7da5fcd4c99de1ec5cc783cdd605398246280</id>
<content type='text'>
Currently, the results for individial parameters in a parameterised test
are simply output as (K)TAP diagnostic lines.

As kunit_tool now supports nested subtests, report each parameter as its
own subtest.

For example, here's what the output now looks like:
	# Subtest: inode_test_xtimestamp_decoding
	ok 1 - 1901-12-13 Lower bound of 32bit &lt; 0 timestamp, no extra bits
	ok 2 - 1969-12-31 Upper bound of 32bit &lt; 0 timestamp, no extra bits
	ok 3 - 1970-01-01 Lower bound of 32bit &gt;=0 timestamp, no extra bits
	ok 4 - 2038-01-19 Upper bound of 32bit &gt;=0 timestamp, no extra bits
	ok 5 - 2038-01-19 Lower bound of 32bit &lt;0 timestamp, lo extra sec bit on
	ok 6 - 2106-02-07 Upper bound of 32bit &lt;0 timestamp, lo extra sec bit on
	ok 7 - 2106-02-07 Lower bound of 32bit &gt;=0 timestamp, lo extra sec bit on
	ok 8 - 2174-02-25 Upper bound of 32bit &gt;=0 timestamp, lo extra sec bit on
	ok 9 - 2174-02-25 Lower bound of 32bit &lt;0 timestamp, hi extra sec bit on
	ok 10 - 2242-03-16 Upper bound of 32bit &lt;0 timestamp, hi extra sec bit on
	ok 11 - 2242-03-16 Lower bound of 32bit &gt;=0 timestamp, hi extra sec bit on
	ok 12 - 2310-04-04 Upper bound of 32bit &gt;=0 timestamp, hi extra sec bit on
	ok 13 - 2310-04-04 Upper bound of 32bit&gt;=0 timestamp, hi extra sec bit 1. 1 ns
	ok 14 - 2378-04-22 Lower bound of 32bit&gt;= timestamp. Extra sec bits 1. Max ns
	ok 15 - 2378-04-22 Lower bound of 32bit &gt;=0 timestamp. All extra sec bits on
	ok 16 - 2446-05-10 Upper bound of 32bit &gt;=0 timestamp. All extra sec bits on
	# inode_test_xtimestamp_decoding: pass:16 fail:0 skip:0 total:16
	ok 1 - inode_test_xtimestamp_decoding

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: Don't crash if no parameters are generated</title>
<updated>2021-12-13T20:36:21Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-11-02T07:30:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=37dbb4c7c7442dbfc9b651e4ddd4afe30b26afc9'/>
<id>urn:sha1:37dbb4c7c7442dbfc9b651e4ddd4afe30b26afc9</id>
<content type='text'>
It's possible that a parameterised test could end up with zero
parameters. At the moment, the test function will nevertheless be called
with NULL as the parameter. Instead, don't try to run the test code, and
just mark the test as SKIPped.

Reported-by: Daniel Latypov &lt;dlatypov@google.com&gt;
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>exit: Rename complete_and_exit to kthread_complete_and_exit</title>
<updated>2021-12-13T18:04:45Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2021-11-22T17:15:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cead18552660702a4a46f58e65188fe5f36e9dfe'/>
<id>urn:sha1:cead18552660702a4a46f58e65188fe5f36e9dfe</id>
<content type='text'>
Update complete_and_exit to call kthread_exit instead of do_exit.

Change the name to reflect this change in functionality.  All of the
users of complete_and_exit are causing the current kthread to exit so
this change makes it clear what is happening.

Move the implementation of kthread_complete_and_exit from
kernel/exit.c to to kernel/kthread.c.  As this function is kthread
specific it makes most sense to live with the kthread functions.

There are no functional change.

Signed-off-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
</content>
</entry>
<entry>
<title>kunit: Reset suite count after running tests</title>
<updated>2021-10-19T20:22:02Z</updated>
<author>
<name>David Gow</name>
<email>davidgow@google.com</email>
</author>
<published>2021-10-06T04:41:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=17ac23eb43f0cbefc8bfce44ad51a9f065895f9f'/>
<id>urn:sha1:17ac23eb43f0cbefc8bfce44ad51a9f065895f9f</id>
<content type='text'>
There are some KUnit tests (KFENCE, Thunderbolt) which, for various
reasons, do not use the kunit_test_suite() macro and end up running
before the KUnit executor runs its tests. This means that their results
are printed separately, and they aren't included in the suite count used
by the executor.

This causes the executor output to be invalid TAP, however, as the suite
numbers used are no-longer 1-based, and don't match the test plan.
kunit_tool, therefore, prints a large number of warnings.

While it'd be nice to fix the tests to run in the executor, in the
meantime, reset the suite counter to 1 in __kunit_test_suites_exit.
Not only does this fix the executor, it means that if there are multiple
calls to __kunit_test_suites_init() across different tests, they'll each
get their own numbering.

kunit_tool likes this better: even if it's lacking the results for those
tests which don't use the executor (due to the lack of TAP header), the
output for the other tests is valid.

Signed-off-by: David Gow &lt;davidgow@google.com&gt;
Reviewed-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Signed-off-by: Shuah Khan &lt;skhan@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kunit: add 'kunit.action' param to allow listing out tests</title>
<updated>2021-10-19T20:18:50Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-09-30T22:20:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9c6b0e1d8993e47a3fe437af71c6a23d4ee73e12'/>
<id>urn:sha1:9c6b0e1d8993e47a3fe437af71c6a23d4ee73e12</id>
<content type='text'>
Context:
It's difficult to map a given .kunitconfig =&gt; set of enabled tests.
Letting kunit.py figure that out would be useful.

This patch:
* is intended to be an implementation detail used only by kunit.py
* adds a kunit.action module param with one valid non-null value, "list"
* for the "list" action, it simply prints out "&lt;suite&gt;.&lt;test&gt;"
* leaves the kunit.py changes to make use of this for another patch.

Note: kunit.filter_glob is respected for this and all future actions.

Hack: we print a TAP header (but no test plan) to allow kunit.py to
use the same code to pick up KUnit output that it does for normal tests.
Since this is intended to be an implementation detail, it seems fine for
now. Maybe in the future we output each test as SKIPPED or the like.

Go with a more generic "action" param, since it seems like we might
eventually have more modes besides just running or listing tests, e.g.
* perhaps a benchmark mode that reruns test cases and reports timing
* perhaps a deflake mode that reruns test cases that failed
* perhaps a mode where we randomize test order to try and catch
  hermeticity bugs like "test a only passes if run after test b"

Tested:
$ ./tools/testing/kunit/kunit.py run --kernel_arg=kunit.action=list --raw_output=kunit
...
TAP version 14
1..1
example.example_simple_test
example.example_skip_test
example.example_mark_skipped_test
reboot: System halted

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: fix too small allocation when using suite-only kunit.filter_glob</title>
<updated>2021-10-19T20:18:49Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-10-02T01:36:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cd94fbc2cafb61cc1394cdba3f92b99ce07b03ae'/>
<id>urn:sha1:cd94fbc2cafb61cc1394cdba3f92b99ce07b03ae</id>
<content type='text'>
When a user filters by a suite and not a test, e.g.
$ ./tools/testing/kunit/kunit.py run 'suite_name'

it hits this code
  const int len = strlen(filter_glob);
  ...
  parsed-&gt;suite_glob = kmalloc(len, GFP_KERNEL);
which fails to allocate space for the terminating NULL.

Somehow, it seems like we can't easily reproduce this under UML, so the
existing `parse_filter_test()` didn't catch this.

Fix this by allocating `len + 1` and switch to kzalloc() just to be a
bit more defensive. We're only going to run this code once per kernel
boot, and it should never be very long.

Also update the unit tests to be a bit more cautious.
This bug showed up as a NULL pointer dereference here:
&gt;  KUNIT_EXPECT_STREQ(test, (const char *)filtered.start[0][0]-&gt;name, "suite0");
`filtered.start[0][0]` was NULL, and `name` is at offset 0 in the struct,
so `...-&gt;name` was also NULL.

Fixes: 3b29021ddd10 ("kunit: tool: allow filtering test cases via glob")
Reported-by: kernel test robot &lt;oliver.sang@intel.com&gt;
Signed-off-by: Daniel Latypov &lt;dlatypov@google.com&gt;
Reviewed-by: David Gow &lt;davidgow@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: allow filtering test cases via glob</title>
<updated>2021-10-19T20:18:49Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-09-14T21:03:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a127b154a8f231709754b5d56a501163dd837459'/>
<id>urn:sha1:a127b154a8f231709754b5d56a501163dd837459</id>
<content type='text'>
Commit 1d71307a6f94 ("kunit: add unit test for filtering suites by
names") introduced the ability to filter which suites we run via glob.

This change extends it so we can also filter individual test cases
inside of suites as well.

This is quite useful when, e.g.
* trying to run just the tests cases you've just added or are working on
* trying to debug issues with test hermeticity

Examples:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit '*exec*.parse*'
...
============================================================
======== [PASSED] kunit_executor_test ========
[PASSED] parse_filter_test
============================================================
Testing complete. 1 tests run. 0 failed. 0 crashed.

$ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit '*.no_matching_tests'
...
[ERROR] no tests run!

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: drop assumption in kunit-log-test about current suite</title>
<updated>2021-10-19T20:18:49Z</updated>
<author>
<name>Daniel Latypov</name>
<email>dlatypov@google.com</email>
</author>
<published>2021-09-14T21:03:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b7cbaef303c7b9f26c647bcba72da04dd35396c4'/>
<id>urn:sha1:b7cbaef303c7b9f26c647bcba72da04dd35396c4</id>
<content type='text'>
This test assumes that the declared kunit_suite object is the exact one
which is being executed, which KUnit will not guarantee [1].

Specifically, `suite-&gt;log` is not initialized until a suite object is
executed. So if KUnit makes a copy of the suite and runs that instead,
this test dereferences an invalid pointer and (hopefully) segfaults.

N.B. since we no longer assume this, we can no longer verify that
`suite-&gt;log` is *not* allocated during normal execution.

An alternative to this patch that would allow us to test that would
require exposing an API for the current test to get its current suite.
Exposing that for one internal kunit test seems like overkill, and
grants users more footguns (e.g. reusing a test case in multiple suites
and changing behavior based on the suite name, dynamically modifying the
setup/cleanup funcs, storing/reading stuff out of the suite-&gt;log, etc.).

[1] In a subsequent patch, KUnit will allow running subsets of test
cases within a suite by making a copy of the suite w/ the filtered test
list. But there are other reasons KUnit might execute a copy, e.g. if it
ever wants to support parallel execution of different suites, recovering
from errors and restarting suites

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: fix reference count leak in kfree_at_end</title>
<updated>2021-10-01T19:49:38Z</updated>
<author>
<name>Xiyu Yang</name>
<email>xiyuyang19@fudan.edu.cn</email>
</author>
<published>2021-09-09T07:24:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f62314b1ced25c58b86e044fc951cd6a1ea234cf'/>
<id>urn:sha1:f62314b1ced25c58b86e044fc951cd6a1ea234cf</id>
<content type='text'>
The reference counting issue happens in the normal path of
kfree_at_end(). When kunit_alloc_and_get_resource() is invoked, the
function forgets to handle the returned resource object, whose refcount
increased inside, causing a refcount leak.

Fix this issue by calling kunit_alloc_resource() instead of
kunit_alloc_and_get_resource().

Fixed the following when applying:
Shuah Khan &lt;skhan@linuxfoundation.org&gt;

CHECK: Alignment should match open parenthesis
+	kunit_alloc_resource(test, NULL, kfree_res_free, GFP_KERNEL,
 				     (void *)to_free);

Signed-off-by: Xiyu Yang &lt;xiyuyang19@fudan.edu.cn&gt;
Signed-off-by: Xin Tan &lt;tanxin.ctf@gmail.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>
</feed>
