[Intel-gfx] [PATCH 6/8] lib: Introduce igt_fail_on/_f

Daniel Vetter daniel.vetter at ffwll.ch
Fri Jun 13 18:29:59 CEST 2014


I've yet again totally screwed things up (this time automated with
cocci even, but not yet pushed luckily). So finally add a new version
for easier conversion and adjust the cocci script.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 lib/igt.cocci  |  9 ++++++++-
 lib/igt_core.h | 28 ++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/lib/igt.cocci b/lib/igt.cocci
index e944c7d12f4f..b5c0bfe658de 100644
--- a/lib/igt.cocci
+++ b/lib/igt.cocci
@@ -13,7 +13,14 @@ expression list[n] Ep;
 )
 - igt_fail(...);
 - }
-+ igt_assert_f(Ec, Ep);
++ igt_fail_on_f(Ec, Ep);
+@@
+expression Ec;
+@@
+- if (Ec) {
+- igt_fail(...);
+- }
++ igt_fail_on(Ec);
 @@
 expression Ec;
 expression list[n] Ep;
diff --git a/lib/igt_core.h b/lib/igt_core.h
index b54ef61565d0..e252eba7be53 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -204,7 +204,7 @@ void igt_exit(void) __attribute__((noreturn));
  * igt_assert:
  * @expr: condition to test
  *
- * Fails (sub-)test if the condition is not met
+ * Fails (sub-)test if the condition is not met.
  *
  * Should be used everywhere where a test checks results.
  */
@@ -218,7 +218,7 @@ void igt_exit(void) __attribute__((noreturn));
  * @expr: condition to test
  * @...: format string and optional arguments
  *
- * Fails (sub-)test if the condition is not met
+ * Fails (sub-)test if the condition is not met.
  *
  * Should be used everywhere where a test checks results.
  *
@@ -231,6 +231,30 @@ void igt_exit(void) __attribute__((noreturn));
 	} while (0)
 
 /**
+ * igt_fail_on:
+ * @expr: condition to test
+ *
+ * Fails (sub-)test if the condition is met.
+ *
+ * Should be used everywhere where a test checks results.
+ */
+#define igt_fail_on(expr) igt_assert(!(expr))
+
+/**
+ * igt_assert_f:
+ * @expr: condition to test
+ * @...: format string and optional arguments
+ *
+ * Fails (sub-)test if the condition is met.
+ *
+ * Should be used everywhere where a test checks results.
+ *
+ * In addition to the plain igt_assert() helper this allows to print additional
+ * information to help debugging test failures.
+ */
+#define igt_fail_on_f(expr, f...) igt_assert_f(!(expr), f)
+
+/**
  * igt_assert_cmpint:
  * @n1: first value
  * @cmp: compare operator
-- 
2.0.0




More information about the Intel-gfx mailing list