Centos-kernel-stream-9/lib/kunit
Dave Airlie 5485de0156 kunit: Add a macro to wrap a deferred action function
JIRA: https://issues.redhat.com/browse/RHEL-24101
Upstream Status: v6.8-rc1

The conflict is due to missing string stream logging support, which seems
like a more intricate backport than I'm up for.

Conflicts:
        lib/kunit/kunit-test.c

commit 56778b49c9a2cbc32c6b0fbd3ba1a9d64192d3af
Author:     David Gow <davidgow@google.com>
AuthorDate: Tue Nov 28 15:24:05 2023 +0800
Commit:     Shuah Khan <skhan@linuxfoundation.org>
CommitDate: Mon Dec 18 13:21:14 2023 -0700

    KUnit's deferred action API accepts a void(*)(void *) function pointer
    which is called when the test is exited. However, we very frequently
    want to use existing functions which accept a single pointer, but which
    may not be of type void*. While this is probably dodgy enough to be on
    the wrong side of the C standard, it's been often used for similar
    callbacks, and gcc's -Wcast-function-type seems to ignore cases where
    the only difference is the type of the argument, assuming it's
    compatible (i.e., they're both pointers to data).

    However, clang 16 has introduced -Wcast-function-type-strict, which no
    longer permits any deviation in function pointer type. This seems to be
    because it'd break CFI, which validates the type of function calls.

    This rather ruins our attempts to cast functions to defer them, and
    leaves us with a few options. The one we've chosen is to implement a
    macro which will generate a wrapper function which accepts a void*, and
    casts the argument to the appropriate type.

    For example, if you were trying to wrap:
    void foo_close(struct foo *handle);
    you could use:
    KUNIT_DEFINE_ACTION_WRAPPER(kunit_action_foo_close,
    			    foo_close,
    			    struct foo *);

    This would create a new kunit_action_foo_close() function, of type
    kunit_action_t, which could be passed into kunit_add_action() and
    similar functions.

    In addition to defining this macro, update KUnit and its tests to use
    it.

    Link: https://github.com/ClangBuiltLinux/linux/issues/1750
    Reviewed-by: Nathan Chancellor <nathan@kernel.org>
    Tested-by: Nathan Chancellor <nathan@kernel.org>
    Acked-by: Daniel Vetter <daniel@ffwll.ch>
    Reviewed-by: Maxime Ripard <mripard@kernel.org>
    Signed-off-by: David Gow <davidgow@google.com>
    Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Signed-off-by: Dave Airlie <airlied@redhat.com>
2024-04-17 10:46:57 +10:00
..
.kunitconfig
Kconfig kunit: Allow kunit test modules to use test filtering 2023-11-02 15:26:59 -06:00
Makefile kunit: Add APIs for managing devices 2024-04-17 10:46:57 +10:00
assert.c kunit: fix bug in KUNIT_EXPECT_MEMEQ 2023-11-02 15:26:55 -06:00
attributes.c kunit: fix struct kunit_attr header 2023-11-02 15:26:58 -06:00
debugfs.c kunit: include debugfs header file 2023-11-02 15:26:57 -06:00
debugfs.h
device-impl.h kunit: device: Unregister the kunit_bus on shutdown 2024-04-17 10:46:57 +10:00
device.c kunit: Fix some comments which were mistakenly kerneldoc 2024-04-17 10:46:57 +10:00
executor.c kunit: Fix possible memory leak in kunit_filter_suites() 2023-11-02 15:29:34 -06:00
executor_test.c kunit: test: Fix the possible memory leak in executor_test 2023-11-02 15:29:34 -06:00
hooks-impl.h kunit: Add printf attribute to fail_current_test_impl 2023-11-02 15:26:56 -06:00
hooks.c kunit: Add "hooks" to call into KUnit when it's built as a module 2023-11-02 15:26:55 -06:00
kunit-example-test.c kunit: Add speed attribute 2023-11-02 15:26:57 -06:00
kunit-test.c kunit: Fix a NULL vs IS_ERR() bug 2024-04-17 10:46:57 +10:00
resource.c kunit: Add kunit_add_action() to defer a call until test exit 2023-11-02 15:26:57 -06:00
static_stub.c kunit: Expose 'static stub' API to redirect functions 2023-11-02 15:26:56 -06:00
string-stream-test.c
string-stream.c kunit: remove unused structure definition 2023-11-02 15:26:54 -06:00
string-stream.h kunit: drop test pointer in string_stream_fragment 2023-11-02 15:26:54 -06:00
test.c kunit: Add a macro to wrap a deferred action function 2024-04-17 10:46:57 +10:00
try-catch-impl.h
try-catch.c