Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 40f39777ce4f ("kunit: decrease macro layering for integer asserts")
Signed-off-by: Sander Vanheule <sander@svanheule.net>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Sander Vanheule and committed by
Shuah Khan
aded3cad 41a55567

+3 -3
+3 -3
include/kunit/test.h
··· 826 826 827 827 #define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \ 828 828 KUNIT_BINARY_INT_ASSERTION(test, \ 829 - KUNIT_ASSERTION, \ 829 + KUNIT_EXPECTATION, \ 830 830 left, <=, right, \ 831 831 fmt, \ 832 832 ##__VA_ARGS__) ··· 1116 1116 1117 1117 #define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \ 1118 1118 KUNIT_BINARY_INT_ASSERTION(test, \ 1119 - KUNIT_EXPECTATION, \ 1119 + KUNIT_ASSERTION, \ 1120 1120 left, <, right, \ 1121 1121 fmt, \ 1122 1122 ##__VA_ARGS__) ··· 1157 1157 1158 1158 #define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \ 1159 1159 KUNIT_BINARY_INT_ASSERTION(test, \ 1160 - KUNIT_EXPECTATION, \ 1160 + KUNIT_ASSERTION, \ 1161 1161 left, >, right, \ 1162 1162 fmt, \ 1163 1163 ##__VA_ARGS__)