Go to file
David Gow 91e9359221 kunit: Use the static key when retrieving the current test
In order to detect if a KUnit test is running, and to access its
context, the 'kunit_test' member of the current task_struct is used.
Usually, this is accessed directly or via the kunit_fail_current_task()
function.

In order to speed up the case where no test is running, add a wrapper,
kunit_get_current_test(), which uses the static key to fail early.
Equally, Speed up kunit_fail_current_test() by using the static key.

This should make it convenient for code to call this
unconditionally in fakes or error paths, without worrying that this will
slow the code down significantly.

If CONFIG_KUNIT=n (or m), this compiles away to nothing. If
CONFIG_KUNIT=y, it will compile down to a NOP (on most architectures) if
no KUnit test is currently running.

Note that kunit_get_current_test() does not work if KUnit is built as a
module. This mirrors the existing restriction on kunit_fail_current_test().

Note that the definition of kunit_fail_current_test() still wraps an
empty, inline function if KUnit is not built-in. This is to ensure that
the printf format string __attribute__ will still work.

Also update the documentation to suggest users use the new
kunit_get_current_test() function, update the example, and to describe
the behaviour when KUnit is disabled better.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Sadiya Kazi <sadiyakazi@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2022-12-12 14:13:47 -07:00
Documentation kunit: Use the static key when retrieving the current test 2022-12-12 14:13:47 -07:00
LICENSES
arch RISC-V: 2022-10-23 15:00:43 -07:00
block block-6.1-2022-10-20 2022-10-21 15:14:14 -07:00
certs
crypto
drivers kunit: Use KUNIT_EXPECT_MEMEQ macro 2022-10-27 02:40:14 -06:00
fs First batch of EFI fixes for v6.1 2022-10-21 18:02:36 -07:00
include kunit: Use the static key when retrieving the current test 2022-12-12 14:13:47 -07:00
init init: Kconfig: fix spelling mistake "satify" -> "satisfy" 2022-10-20 21:27:22 -07:00
io_uring io_uring/net: fail zc sendmsg when unsupported by socket 2022-10-22 08:43:03 -06:00
ipc
kernel kernel/utsname_sysctl.c: Fix hostname polling 2022-10-23 12:01:01 -07:00
lib kunit: Provide a static key to check if KUnit is actively running tests 2022-12-12 14:13:47 -07:00
mm mm/huge_memory: do not clobber swp_entry_t during THP split 2022-10-20 21:27:24 -07:00
net kunit: Use KUNIT_EXPECT_MEMEQ macro 2022-10-27 02:40:14 -06:00
rust
samples
scripts
security selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context() 2022-10-19 09:55:53 -04:00
sound
tools kunit: tool: make --json do nothing if --raw_ouput is set 2022-12-12 14:13:47 -07:00
usr
virt kvm: Add support for arch compat vm ioctls 2022-10-22 05:15:23 -04:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap mailmap: update email for Qais Yousef 2022-10-20 21:27:21 -07:00
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS pci-v6.1-fixes-2 2022-10-22 15:52:36 -07:00
Makefile Linux 6.1-rc2 2022-10-23 15:27:33 -07:00
README

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.