Create ASSERT_{EQ, NE, TRUE, FALSE} macros to make test creation easier.

Signed-off-by: André Almeida <andrealm...@igalia.com>
---
 tools/testing/selftests/futex/include/logging.h | 38 +++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/testing/selftests/futex/include/logging.h 
b/tools/testing/selftests/futex/include/logging.h
index 
874c69ce5cce9efa3a9d6de246f5972a75437dbf..a19755622a877932884570c8f58aaee7371d5f8f
 100644
--- a/tools/testing/selftests/futex/include/logging.h
+++ b/tools/testing/selftests/futex/include/logging.h
@@ -23,6 +23,44 @@
 #include <linux/futex.h>
 #include "kselftest.h"
 
+#define ASSERT_EQ(var, value)  \
+do {                           \
+       if (var != value) {     \
+               ksft_test_result_fail("%s: expected %ld, but %s has %ld\n", \
+                                     __func__, (long) value, #var, \
+                                     (long) var); \
+               return;         \
+       }                       \
+} while (0)
+
+#define ASSERT_NE(var, value)  \
+do {                           \
+       if (var == value) {     \
+               ksft_test_result_fail("%s: expected not %ld, but %s has %ld\n", 
\
+                                     __func__, (long) value, #var, \
+                                     (long) var); \
+               return; \
+       }               \
+} while (0)
+
+#define ASSERT_TRUE(var)       \
+do {                           \
+       if ((var) == 0) {       \
+               ksft_test_result_fail("%s: expected %s to be true\n", \
+                                     __func__, #var); \
+               return;         \
+       }                       \
+} while (0)
+
+#define ASSERT_FALSE(var)      \
+do {                           \
+       if (var) {              \
+               ksft_test_result_fail("%s: expected %s to be false\n", \
+                                     __func__, #var); \
+               return;         \
+       }                       \
+} while (0)
+
 /*
  * Define PASS, ERROR, and FAIL strings with and without color escape
  * sequences, default to no color.

-- 
2.49.0


Reply via email to