linux/include/kunit
David Gow 260755184c kunit: Move kunit_abort() call out of kunit_do_failed_assertion()
KUnit aborts the current thread when an assertion fails. Currently, this
is done conditionally as part of the kunit_do_failed_assertion()
function, but this hides the kunit_abort() call from the compiler
(particularly if it's in another module). This, in turn, can lead to
both suboptimal code generation (the compiler can't know if
kunit_do_failed_assertion() will return), and to static analysis tools
like smatch giving false positives.

Moving the kunit_abort() call into the macro should give the compiler
and tools a better chance at understanding what's going on. Doing so
requires exporting kunit_abort(), though it's recommended to continue to
use assertions in lieu of aborting directly.

In addition, kunit_abort() and kunit_do_failed_assertion() are renamed
to make it clear they they're intended for internal KUnit use, to:
__kunit_do_failed_assertion() and __kunit_abort()

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2023-06-01 13:04:46 -06:00
..
assert.h kunit: remove KUNIT_INIT_MEM_ASSERTION macro 2022-12-12 14:13:47 -07:00
resource.h kunit: Fix obsolete name in documentation headers (func->action) 2023-06-01 13:04:40 -06:00
static_stub.h kunit: Expose 'static stub' API to redirect functions 2023-02-08 14:28:17 -07:00
test-bug.h kunit: Expose 'static stub' API to redirect functions 2023-02-08 14:28:17 -07:00
test.h kunit: Move kunit_abort() call out of kunit_do_failed_assertion() 2023-06-01 13:04:46 -06:00
try-catch.h kunit: hide unexported try-catch interface in try-catch-impl.h 2020-01-09 16:42:09 -07:00
visibility.h kunit: add macro to allow conditionally exposing static symbols to tests 2022-12-12 14:13:48 -07:00