1 /*****************************************************************************/
4 * \brief Some useful assert-style macros.
7 * \author Bjoern Doebel <doebel@tudos.org>
9 * (c) 2009 Technische Universität Dresden
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU Lesser General Public License 2.1.
12 * Please see the COPYING-LGPL-2.1 file for details.
15 /*****************************************************************************/
20 #define DO_NOTHING do {} while (0)
21 #define ASSERT_VALID(c) DO_NOTHING
22 #define ASSERT_EQUAL(a,b) DO_NOTHING
23 #define ASSERT_NOT_EQUAL(a,b) DO_NOTHING
24 #define ASSERT_LOWER_EQ(a,b) DO_NOTHING
25 #define ASSERT_GREATER_EQ(a,b) DO_NOTHING
26 #define ASSERT_BETWEEN(a,b,c) DO_NOTHING
27 #define ASSERT_IPC_OK(i) DO_NOTHING
28 #define ASSERT_OK(e) DO_NOTHING
29 #define ASSERT_NOT_NULL(p) DO_NOTHING
31 #define assert(cond) DO_NOTHING
38 #include <l4/sys/kdebug.h>
40 #define ASSERT_VALID(cap) \
42 if (l4_is_invalid_cap(cap)) { \
43 printf("%s: Cap invalid.\n", __func__); \
44 assert(l4_is_invalid_cap(cap)); \
49 #define ASSERT_EQUAL(a, b) \
52 printf("%s: "#a" (%lx) != "#b" (%lx)\n", __func__, (unsigned long)(a), (unsigned long)(b)); \
58 #define ASSERT_NOT_EQUAL(a, b) \
61 printf("%s: "#a" (%lx) == "#b" (%lx)\n", __func__, (unsigned long)(a), (unsigned long)(b)); \
67 #define ASSERT_LOWER_EQ(val, max) \
69 if ((val) > (max)) { \
70 printf("%s: "#val" (%lx) > "#max" (%lx)\n", __func__, (unsigned long)(val), (unsigned long)(max)); \
71 assert((val)<=(max)); \
76 #define ASSERT_GREATER_EQ(val, min) \
78 if ((val) < (min)) { \
79 printf("%s: "#val" (%lx) < "#min" (%lx)\n", __func__, (unsigned long)(val), (unsigned long)(min)); \
80 assert((val)>=(min)); \
85 #define ASSERT_BETWEEN(val, min, max) \
86 ASSERT_LOWER_EQ((val), (max)); \
87 ASSERT_GREATER_EQ((val), (min));
90 #define ASSERT_IPC_OK(msgtag) \
92 if (l4_ipc_error((msgtag), l4_utcb())) { \
93 printf("%s: IPC Error: %lx\n", __func__, l4_ipc_error(msgtag)); \
94 assert(!l4_ipc_error(msgtag)); \
98 #define ASSERT_OK(val) ASSERT_EQUAL((val), 0)
99 #define ASSERT_NOT_NULL(ptr) ASSERT_NOT_EQUAL((ptr), NULL)