summaryrefslogtreecommitdiff
path: root/lib/igt_core.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-08-29 13:11:40 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-08-29 13:20:36 +0100
commit3b94d3f8ce21c92d3209e73ab48fda64beb0037e (patch)
tree8467a7e779de0d82be02b212196fc6e5f39b3486 /lib/igt_core.h
parentd0a41b47ea5ed1ac5ca45f83d2917c6ad41b644a (diff)
igt: Prettify igt_assert_eq() failure messages
This just improves the language about the exact failure to reduce confusion. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r--lib/igt_core.h42
1 files changed, 39 insertions, 3 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 1d3d7fc6..3b9aa305 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -275,13 +275,22 @@ void igt_exit(void) __attribute__((noreturn));
* Like igt_assert(), but displays the values being compared on failure instead
* of simply printing the stringified expression.
*/
-#define igt_assert_cmpint(n1, cmp, n2) \
+#define igt_assert_cmpint(n1, cmp, ncmp, n2) \
do { \
int __n1 = (n1), __n2 = (n2); \
if (__n1 cmp __n2) ; else \
__igt_fail_assert(99, __FILE__, __LINE__, __func__, \
#n1 " " #cmp " " #n2, \
- "error: %d %s %d\n", __n1, #cmp, __n2); \
+ "error: %d %s %d\n", __n1, #ncmp, __n2); \
+ } while (0)
+
+#define igt_assert_cmpuint(n1, cmp, ncmp, n2) \
+ do { \
+ uint32_t __n1 = (n1), __n2 = (n2); \
+ if (__n1 cmp __n2) ; else \
+ __igt_fail_assert(99, __FILE__, __LINE__, __func__, \
+ #n1 " " #cmp " " #n2, \
+ "error: %#x %s %#x\n", __n1, #ncmp, __n2); \
} while (0)
/**
@@ -295,7 +304,34 @@ void igt_exit(void) __attribute__((noreturn));
* Like igt_assert(), but displays the values being compared on failure instead
* of simply printing the stringified expression.
*/
-#define igt_assert_eq(n1, n2) igt_assert_cmpint(n1, ==, n2)
+#define igt_assert_eq(n1, n2) igt_assert_cmpint(n1, ==, !=, n2)
+#define igt_assert_eq_u32(n1, n2) igt_assert_cmpuint(n1, ==, !=, n2)
+
+/**
+ * igt_assert_neq:
+ * @n1: first integer
+ * @n2: second integer
+ *
+ * Fails (sub-)test if the two integers are equal. Beware that for now this
+ * only works on integers.
+ *
+ * Like igt_assert(), but displays the values being compared on failure instead
+ * of simply printing the stringified expression.
+ */
+#define igt_assert_neq(n1, n2) igt_assert_cmpint(n1, !=, ==, n2)
+
+/**
+ * igt_assert_lte:
+ * @n1: first integer
+ * @n2: second integer
+ *
+ * Fails (sub-)test if the second integers is greater than the first.
+ * Beware that for now this only works on integers.
+ *
+ * Like igt_assert(), but displays the values being compared on failure instead
+ * of simply printing the stringified expression.
+ */
+#define igt_assert_lte(n1, n2) igt_assert_cmpint(n1, <=, >, n2)
/**
* igt_require: