]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/commitdiff
libkmstest: add FAIL_IF()
authorTomi Valkeinen <tomi.valkeinen@iki.fi>
Fri, 2 Oct 2015 18:34:38 +0000 (21:34 +0300)
committerTomi Valkeinen <tomi.valkeinen@iki.fi>
Sat, 3 Oct 2015 13:59:19 +0000 (16:59 +0300)
libkmstest/test.h

index 0913e79b8058ccc9b3abaaa32a827954e11de370..f4cec599e7e83cc9d6c127f04650466e4d1d9594 100644 (file)
@@ -4,6 +4,8 @@
 #include "conv.h"
 #include "testpat.h"
 
 #include "conv.h"
 #include "testpat.h"
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 #define unlikely(x) __builtin_expect(!!(x), 0)
 
 static void ASSERT_FAIL(const char *cond, const char *file,
 #define unlikely(x) __builtin_expect(!!(x), 0)
 
 static void ASSERT_FAIL(const char *cond, const char *file,
@@ -18,4 +20,14 @@ static void ASSERT_FAIL(const char *cond, const char *file,
 
 #define ASSERT(x) if (unlikely(!(x))) { ASSERT_FAIL( __STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__); }
 
 
 #define ASSERT(x) if (unlikely(!(x))) { ASSERT_FAIL( __STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__); }
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+static void FAIL_IF_FAIL(const char *txt, const char *file,
+                          unsigned int line, const char *func) __attribute__ ((__noreturn__));
+
+static void FAIL_IF_FAIL(const char *txt, const char *file,
+                          unsigned int line, const char *func)
+{
+       fprintf(stderr, "%s:%d: %s: FAIL: %s\n", file, line, func, txt);
+       abort();
+}
+
+#define FAIL_IF(x, y) if (unlikely(x)) { FAIL_IF_FAIL(y, __FILE__, __LINE__, __PRETTY_FUNCTION__); }