[PATCH v3 1/2] selftests/futex: Add ASSERT_ macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
---
 .../testing/selftests/futex/include/logging.h | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)

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





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux