Skip to content

Commit aded3ca

Browse files
svanheuleshuahkh
authored andcommitted
kunit: fix assert_type for comparison macros
When replacing KUNIT_BINARY_*_MSG_ASSERTION() macros with KUNIT_BINARY_INT_ASSERTION(), the assert_type parameter was not always correctly transferred. Specifically, the following errors were introduced: - KUNIT_EXPECT_LE_MSG() uses KUNIT_ASSERTION - KUNIT_ASSERT_LT_MSG() uses KUNIT_EXPECTATION - KUNIT_ASSERT_GT_MSG() uses KUNIT_EXPECTATION A failing KUNIT_EXPECT_LE_MSG() test thus prevents further tests from running, while failing KUNIT_ASSERT_{LT,GT}_MSG() tests do not prevent further tests from running. This is contrary to the documentation, which states that failing KUNIT_EXPECT_* macros allow further tests to run, while failing KUNIT_ASSERT_* macros should prevent this. Revert the KUNIT_{ASSERTION,EXPECTATION} switches to fix the behaviour for the affected macros. Fixes: 40f3977 ("kunit: decrease macro layering for integer asserts") Signed-off-by: Sander Vanheule <[email protected]> Reviewed-by: Daniel Latypov <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 41a5556 commit aded3ca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/kunit/test.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ do { \
826826

827827
#define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \
828828
KUNIT_BINARY_INT_ASSERTION(test, \
829-
KUNIT_ASSERTION, \
829+
KUNIT_EXPECTATION, \
830830
left, <=, right, \
831831
fmt, \
832832
##__VA_ARGS__)
@@ -1116,7 +1116,7 @@ do { \
11161116

11171117
#define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \
11181118
KUNIT_BINARY_INT_ASSERTION(test, \
1119-
KUNIT_EXPECTATION, \
1119+
KUNIT_ASSERTION, \
11201120
left, <, right, \
11211121
fmt, \
11221122
##__VA_ARGS__)
@@ -1157,7 +1157,7 @@ do { \
11571157

11581158
#define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \
11591159
KUNIT_BINARY_INT_ASSERTION(test, \
1160-
KUNIT_EXPECTATION, \
1160+
KUNIT_ASSERTION, \
11611161
left, >, right, \
11621162
fmt, \
11631163
##__VA_ARGS__)

0 commit comments

Comments
 (0)