Commit 6125a5c7 authored by Daniel Latypov's avatar Daniel Latypov Committed by Shuah Khan

kunit: decrease macro layering for EQ/NE asserts

Introduce KUNIT_BINARY_PTR_ASSERTION to match KUNIT_BINARY_INT_ASSERTION
and make KUNIT_EXPECT_EQ and KUNIT_EXPECT_PTREQ use these instead of
shared intermediate macros that only remove the need to type "==" or
"!=".

The current macro chain looks like:
KUNIT_EXPECT_EQ_MSG => KUNIT_BINARY_EQ_MSG_ASSERTION => KUNIT_BASE_EQ_MSG_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
KUNIT_EXPECT_PTR_EQ_MSG => KUNIT_BINARY_PTR_EQ_MSG_ASSERTION => KUNIT_BASE_EQ_MSG_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
<ditto for NE and ASSERT>

After this change:
KUNIT_EXPECT_EQ_MSG => KUNIT_BINARY_INT_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
KUNIT_EXPECT_PTR_EQ_MSG => KUNIT_BINARY_PTR_ASSERTION => KUNIT_BASE_BINARY_ASSERTION
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 40f39777
......@@ -888,48 +888,6 @@ do { \
##__VA_ARGS__); \
} while (0)
#define KUNIT_BASE_EQ_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_NE_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_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, \
##__VA_ARGS__)
#define KUNIT_BINARY_INT_ASSERTION(test, \
assert_type, \
left, \
......@@ -945,43 +903,18 @@ do { \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BASE_EQ_MSG_ASSERTION(test, \
kunit_binary_ptr_assert, \
KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_NE_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_NE_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \
#define KUNIT_BINARY_PTR_ASSERTION(test, \
assert_type, \
left, \
op, \
right, \
fmt, \
...) \
KUNIT_BASE_NE_MSG_ASSERTION(test, \
KUNIT_BASE_BINARY_ASSERTION(test, \
kunit_binary_ptr_assert, \
KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
left, op, right, \
fmt, \
##__VA_ARGS__)
......@@ -1082,10 +1015,9 @@ do { \
KUNIT_EXPECT_EQ_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
......@@ -1104,10 +1036,9 @@ do { \
KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_PTR_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \
KUNIT_BINARY_PTR_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
......@@ -1126,10 +1057,9 @@ do { \
KUNIT_EXPECT_NE_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_NE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_NE_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1148,10 +1078,9 @@ do { \
KUNIT_EXPECT_PTR_NE_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_PTR_NE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \
KUNIT_BINARY_PTR_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1358,10 +1287,9 @@ do { \
KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
......@@ -1379,10 +1307,9 @@ do { \
KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_PTR_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \
KUNIT_BINARY_PTR_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
......@@ -1400,10 +1327,9 @@ do { \
KUNIT_ASSERT_NE_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_NE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_NE_MSG_ASSERTION(test, \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_ASSERTION, \
left, \
right, \
left, !=, right, \
fmt, \
##__VA_ARGS__)
......@@ -1422,10 +1348,9 @@ do { \
KUNIT_ASSERT_PTR_NE_MSG(test, left, right, NULL)
#define KUNIT_ASSERT_PTR_NE_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \
KUNIT_BINARY_PTR_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