linux-stable/include
David Gow e047c5eaa7 kunit: Expose 'static stub' API to redirect functions
Add a simple way of redirecting calls to functions by including a
special prologue in the "real" function which checks to see if the
replacement function should be called (and, if so, calls it).

To redirect calls to a function, make the first (non-declaration) line
of the function:

	KUNIT_STATIC_STUB_REDIRECT(function_name, [function arguments]);

(This will compile away to nothing if KUnit is not enabled, otherwise it
will check if a redirection is active, call the replacement function,
and return. This check is protected by a static branch, so has very
little overhead when there are no KUnit tests running.)

Calls to the real function can be redirected to a replacement using:

	kunit_activate_static_stub(test, real_fn, replacement_fn);

The redirection will only affect calls made from within the kthread of
the current test, and will be automatically disabled when the test
completes. It can also be manually disabled with
kunit_deactivate_static_stub().

The 'example' KUnit test suite has a more complete example.

Co-developed-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-02-08 14:28:17 -07:00
..
acpi ACPI: Fix selecting wrong ACPI fwnode for the iGPU on some Dell laptops 2023-01-10 20:23:48 +01:00
asm-generic arch: fix broken BuildID for arm64 and riscv 2022-12-30 17:21:51 +09:00
clocksource Updates for timers, timekeeping and drivers: 2022-12-12 12:52:02 -08:00
crypto
drm drm/fb-helper: Use a per-driver FB deferred I/O handler 2023-01-24 11:13:08 +01:00
dt-bindings remoteproc updates for v6.2 2022-12-21 09:37:14 -08:00
keys
kunit kunit: Expose 'static stub' API to redirect functions 2023-02-08 14:28:17 -07:00
kvm KVM: arm64: Add helper vgic_write_guest_lock() 2023-01-29 18:46:11 +00:00
linux Char/Misc driver fixes for 6.2-rc7 2023-02-05 11:52:23 -08:00
math-emu
media
memory
misc
net net: mana: Fix IRQ name - add PCI and queue number 2023-01-20 18:17:17 -08:00
pcmcia
ras
rdma RDMA: Extend RDMA kernel verbs ABI to support flush 2022-12-09 19:36:01 -04:00
rv
scsi scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress 2023-01-18 19:14:56 -05:00
soc firmware: raspberrypi: Fix type assignment 2023-01-10 13:44:04 -08:00
sound
target
trace rxrpc: Move client call connection to the I/O thread 2023-01-06 09:43:33 +00:00
uapi netfilter: conntrack: unify established states for SCTP paths 2023-01-24 09:52:52 +01:00
ufs scsi: ufs: core: Fix devfreq deadlocks 2023-01-18 19:08:37 -05:00
vdso
video fbdev: omapfb: connector-analog-tv: remove support for platform data 2022-12-14 20:01:49 +01:00
xen xen: make remove callback of xen driver void returned 2022-12-15 16:06:10 +01:00