Commit 40f39777 authored by Daniel Latypov's avatar Daniel Latypov Committed by Shuah Khan

kunit: decrease macro layering for integer asserts

Introduce a KUNIT_BINARY_INT_ASSERTION for the likes of KUNIT_EXPECT_LT.
This is analagous to KUNIT_BINARY_STR_ASSERTION.

Note: this patch leaves the EQ/NE macros untouched since those share
some intermediate macros for the pointer-based macros.

The current macro chain looks like:
KUNIT_EXPECT_LT_MSG => KUNIT_BASE_LT_MSG_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
KUNIT_EXPECT_GT_MSG => KUNIT_BASE_GT_MSG_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
<ditto for LE, GE, and ASSERT variants>

After this change:
KUNIT_EXPECT_LT_MSG => KUNIT_BINARY_INT_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
KUNIT_EXPECT_GT_MSG => KUNIT_BINARY_INT_ASSERTION => KUNIT_BASE_BINARY_ASSERTION

I.e. we've traded all the unique intermediary macros for a single shared
KUNIT_BINARY_INT_ASSERTION. The only difference is that users of
KUNIT_BINARY_INT_ASSERTION also need to pass the operation (==, <, etc.).
Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 955df7d8
......@@ -920,77 +920,28 @@ do { \
fmt, \
##__VA_ARGS__)
#define KUNIT_BASE_LT_MSG_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, <, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BASE_LE_MSG_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, <=, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BASE_GT_MSG_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
#define KUNIT_BINARY_EQ_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_EQ_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, >, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BASE_GE_MSG_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
#define KUNIT_BINARY_INT_ASSERTION(test, \
assert_type, \
left, \
op, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, >=, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_EQ_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_EQ_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
left, op, right, \
fmt, \
##__VA_ARGS__)
......@@ -1034,46 +985,6 @@ do { \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_LT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_LT_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_LE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_LE_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_GT_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_GT_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_GE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_GE_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_STR_ASSERTION(test, \
assert_type, \
left, \
......@@ -1259,10 +1170,9 @@ do { \
KUNIT_EXPECT_LT_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_LT_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_LT_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, <, right, \
fmt, \
##__VA_ARGS__)
......@@ -1281,10 +1191,9 @@ do { \
KUNIT_EXPECT_LE_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_LE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_LE_MSG_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_ASSERTION, \
left, <=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1303,10 +1212,9 @@ do { \
KUNIT_EXPECT_GT_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_GT_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_GT_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, >, right, \
fmt, \
##__VA_ARGS__)
......@@ -1325,10 +1233,9 @@ do { \
KUNIT_EXPECT_GE_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_GE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_GE_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, >=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1536,10 +1443,9 @@ do { \
KUNIT_ASSERT_LT_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_LT_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_LT_MSG_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, <, right, \
fmt, \
##__VA_ARGS__)
/**
......@@ -1557,10 +1463,9 @@ do { \
KUNIT_ASSERT_LE_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_LE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_LE_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
left, <=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1579,10 +1484,9 @@ do { \
KUNIT_ASSERT_GT_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_GT_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_GT_MSG_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, >, right, \
fmt, \
##__VA_ARGS__)
......@@ -1601,10 +1505,9 @@ do { \
KUNIT_ASSERT_GE_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_GE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_GE_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
left, >=, right, \
fmt, \
##__VA_ARGS__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment