[Piglit] [PATCH 2/8] util: Add a piglit_fatal utility

Neil Roberts nroberts at igalia.com
Wed Apr 4 22:56:49 UTC 2018


This prints a formatted error and then aborts.
---
 tests/util/piglit-util.c | 16 ++++++++++++++++
 tests/util/piglit-util.h |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index ed7d21c95..a79db3fb7 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -867,3 +867,19 @@ piglit_free_aligned(void *p)
 	free(p);
 #endif
 }
+
+void
+piglit_fatal(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+	vfprintf(stderr, format, ap);
+	va_end(ap);
+
+	fputc('\n', stderr);
+
+	fflush(stderr);
+
+	abort();
+}
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index 3dfb5d6c5..3c9ca9fce 100644
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -460,6 +460,8 @@ piglit_alloc_aligned(size_t alignment, size_t size);
 void
 piglit_free_aligned(void *p);
 
+NORETURN void
+piglit_fatal(const char *format, ...) PRINTFLIKE(1, 2);
 
 #ifdef __cplusplus
 } /* end extern "C" */
-- 
2.14.3



More information about the Piglit mailing list