diff mbox series

[4/5] kunit: decrease macro layering for integer asserts

Message ID 20220118223506.1701553-5-dlatypov@google.com (mailing list archive)
State Accepted
Commit 40f39777ce4f8e65ca16c10f1b895bbe8306a42f
Delegated to: Brendan Higgins
Headers show
Series kunit: decrease layers of assertion macros | expand

Commit Message

Daniel Latypov Jan. 18, 2022, 10:35 p.m. UTC
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: Daniel Latypov <dlatypov@google.com>
---
 include/kunit/test.h | 199 +++++++++++--------------------------------
 1 file changed, 51 insertions(+), 148 deletions(-)

Comments

David Gow Jan. 21, 2022, 7:21 a.m. UTC | #1
On Wed, Jan 19, 2022 at 6:35 AM Daniel Latypov <dlatypov@google.com> wrote:
>
> 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.

I didn't like this until I realised the next patch in the series fixes it. :-)

>
> 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: Daniel Latypov <dlatypov@google.com>
> ---

This also seems like a win to me. While I'm not a huge fan of passing
the operation into macros in general, it's so clearly an improvement
here (and we're doing it elsewhere in the macros with good results)
that I think it's a good idea in this case.

Reviewed-by: David Gow <davidgow@google.com>


-- David

>  include/kunit/test.h | 199 +++++++++++--------------------------------
>  1 file changed, 51 insertions(+), 148 deletions(-)
>
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index d5dc1ef68bfe..48cf520b69ce 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -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,                         \
> -                                   assert_type,                               \
> -                                   left,                                      \
> -                                   right,                                     \
> -                                   fmt,                                       \
> +#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,12 +1170,11 @@ 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_EXPECTATION,                       \
> -                                     left,                                    \
> -                                     right,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, <, right,                             \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
> @@ -1281,12 +1191,11 @@ 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,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_ASSERTION,                            \
> +                                  left, <=, right,                            \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
> @@ -1303,12 +1212,11 @@ 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_EXPECTATION,                       \
> -                                     left,                                    \
> -                                     right,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, >, right,                             \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
> @@ -1325,12 +1233,11 @@ 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_EXPECTATION,                       \
> -                                     left,                                    \
> -                                     right,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, >=, right,                            \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
> @@ -1536,12 +1443,11 @@ 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,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, <, right,                             \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>  /**
>   * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
>   * @test: The test context object.
> @@ -1557,12 +1463,11 @@ 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_ASSERTION,                         \
> -                                     left,                                    \
> -                                     right,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_ASSERTION,                            \
> +                                  left, <=, right,                            \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
> @@ -1579,12 +1484,11 @@ 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,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_EXPECTATION,                          \
> +                                  left, >, right,                             \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
> @@ -1601,12 +1505,11 @@ 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_ASSERTION,                         \
> -                                     left,                                    \
> -                                     right,                                   \
> -                                     fmt,                                     \
> -                                     ##__VA_ARGS__)
> +       KUNIT_BINARY_INT_ASSERTION(test,                                       \
> +                                  KUNIT_ASSERTION,                            \
> +                                  left, >=, right,                            \
> +                                  fmt,                                        \
> +                                   ##__VA_ARGS__)
>
>  /**
>   * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.
> --
> 2.34.1.703.g22d0c6ccf7-goog
>
Brendan Higgins Jan. 21, 2022, 10:17 p.m. UTC | #2
On Tue, Jan 18, 2022 at 5:35 PM Daniel Latypov <dlatypov@google.com> wrote:
>
> 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: Daniel Latypov <dlatypov@google.com>

Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
diff mbox series

Patch

diff --git a/include/kunit/test.h b/include/kunit/test.h
index d5dc1ef68bfe..48cf520b69ce 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -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,			       \
-				    assert_type,			       \
-				    left,				       \
-				    right,				       \
-				    fmt,				       \
+#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,12 +1170,11 @@  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_EXPECTATION,		       \
-				      left,				       \
-				      right,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_EXPECTATION,			       \
+				   left, <, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_EXPECT_LE() - Expects that @left is less than or equal to @right.
@@ -1281,12 +1191,11 @@  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,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_ASSERTION,			       \
+				   left, <=, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_EXPECT_GT() - An expectation that @left is greater than @right.
@@ -1303,12 +1212,11 @@  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_EXPECTATION,		       \
-				      left,				       \
-				      right,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_EXPECTATION,			       \
+				   left, >, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_EXPECT_GE() - Expects that @left is greater than or equal to @right.
@@ -1325,12 +1233,11 @@  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_EXPECTATION,		       \
-				      left,				       \
-				      right,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_EXPECTATION,			       \
+				   left, >=, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_EXPECT_STREQ() - Expects that strings @left and @right are equal.
@@ -1536,12 +1443,11 @@  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,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_EXPECTATION,			       \
+				   left, <, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 /**
  * KUNIT_ASSERT_LE() - An assertion that @left is less than or equal to @right.
  * @test: The test context object.
@@ -1557,12 +1463,11 @@  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_ASSERTION,			       \
-				      left,				       \
-				      right,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_ASSERTION,			       \
+				   left, <=, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_ASSERT_GT() - An assertion that @left is greater than @right.
@@ -1579,12 +1484,11 @@  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,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_EXPECTATION,			       \
+				   left, >, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_ASSERT_GE() - Assertion that @left is greater than or equal to @right.
@@ -1601,12 +1505,11 @@  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_ASSERTION,			       \
-				      left,				       \
-				      right,				       \
-				      fmt,				       \
-				      ##__VA_ARGS__)
+	KUNIT_BINARY_INT_ASSERTION(test,				       \
+				   KUNIT_ASSERTION,			       \
+				   left, >=, right,			       \
+				   fmt,					       \
+				    ##__VA_ARGS__)
 
 /**
  * KUNIT_ASSERT_STREQ() - An assertion that strings @left and @right are equal.