summaryrefslogtreecommitdiff
path: root/include/kunit
diff options
context:
space:
mode:
Diffstat (limited to 'include/kunit')
-rw-r--r--include/kunit/test.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/kunit/test.h b/include/kunit/test.h
index b26400731c02..12cabd15449a 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -12,6 +12,7 @@
#include <kunit/assert.h>
#include <kunit/try-catch.h>
+#include <linux/compiler.h>
#include <linux/container_of.h>
#include <linux/err.h>
#include <linux/init.h>
@@ -770,18 +771,18 @@ void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
*/
#define KUNIT_SUCCEED(test) do {} while (0)
-void kunit_do_assertion(struct kunit *test,
- struct kunit_assert *assert,
- bool pass,
- const char *fmt, ...);
+void kunit_do_failed_assertion(struct kunit *test,
+ struct kunit_assert *assert,
+ const char *fmt, ...);
#define KUNIT_ASSERTION(test, pass, assert_class, INITIALIZER, fmt, ...) do { \
- struct assert_class __assertion = INITIALIZER; \
- kunit_do_assertion(test, \
- &__assertion.assert, \
- pass, \
- fmt, \
- ##__VA_ARGS__); \
+ if (unlikely(!(pass))) { \
+ struct assert_class __assertion = INITIALIZER; \
+ kunit_do_failed_assertion(test, \
+ &__assertion.assert, \
+ fmt, \
+ ##__VA_ARGS__); \
+ } \
} while (0)