]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blob - libkmstest/test.h
libkmstest: add FAIL_IF()
[android/external-libkmsxx.git] / libkmstest / test.h
1 #pragma once
3 #include "color.h"
4 #include "conv.h"
5 #include "testpat.h"
7 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
9 #define unlikely(x) __builtin_expect(!!(x), 0)
11 static void ASSERT_FAIL(const char *cond, const char *file,
12                            unsigned int line, const char *func) __attribute__ ((__noreturn__));
14 static void ASSERT_FAIL(const char *cond, const char *file,
15                            unsigned int line, const char *func)
16 {
17         fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", file, line, func, cond);
18         abort();
19 }
21 #define ASSERT(x) if (unlikely(!(x))) { ASSERT_FAIL( __STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__); }
23 static void FAIL_IF_FAIL(const char *txt, const char *file,
24                            unsigned int line, const char *func) __attribute__ ((__noreturn__));
26 static void FAIL_IF_FAIL(const char *txt, const char *file,
27                            unsigned int line, const char *func)
28 {
29         fprintf(stderr, "%s:%d: %s: FAIL: %s\n", file, line, func, txt);
30         abort();
31 }
33 #define FAIL_IF(x, y) if (unlikely(x)) { FAIL_IF_FAIL(y, __FILE__, __LINE__, __PRETTY_FUNCTION__); }