3 * Copyright (C) 1997-2009 Net Integration Technologies, Inc.
4 * Licensed under the GNU Library General Public License, version 2.
5 * See the included file named LICENSE for license information.
10 #ifndef WVTEST_CONFIGURED
11 # error "Missing settings: HAVE_VALGRIND_MEMCHECK_H HAVE_WVCRASH WVTEST_CONFIGURED"
18 typedef void wvtest_mainfunc();
21 const char *descr, *idstr;
22 wvtest_mainfunc *main;
27 void wvtest_register(struct WvTest *ptr);
28 int wvtest_run_all(char * const *prefixes);
29 void wvtest_start(const char *file, int line, const char *condstr);
30 void wvtest_check(bool cond, const char *reason);
31 static inline bool wvtest_start_check(const char *file, int line,
32 const char *condstr, bool cond)
33 { wvtest_start(file, line, condstr); wvtest_check(cond, NULL); return cond; }
34 bool wvtest_start_check_eq(const char *file, int line,
35 int a, int b, bool expect_pass);
36 bool wvtest_start_check_lt(const char *file, int line,
38 bool wvtest_start_check_eq_str(const char *file, int line,
39 const char *a, const char *b, bool expect_pass);
40 bool wvtest_start_check_lt_str(const char *file, int line,
41 const char *a, const char *b);
42 int wvtest_start_check_frsh(const char *file, int line,
43 const char *condstr, int frsh_retval);
46 #define WVPASS(cond) \
47 wvtest_start_check(__FILE__, __LINE__, #cond, (cond))
48 #define WVPASSEQ(a, b) \
49 wvtest_start_check_eq(__FILE__, __LINE__, (a), (b), true)
50 #define WVPASSLT(a, b) \
51 wvtest_start_check_lt(__FILE__, __LINE__, (a), (b))
52 #define WVPASSEQSTR(a, b) \
53 wvtest_start_check_eq_str(__FILE__, __LINE__, (a), (b), true)
54 #define WVPASSLTSTR(a, b) \
55 wvtest_start_check_lt_str(__FILE__, __LINE__, (a), (b))
56 #define WVFAIL(cond) \
57 wvtest_start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
58 #define WVFAILEQ(a, b) \
59 wvtest_start_check_eq(__FILE__, __LINE__, (a), (b), false)
60 #define WVFAILEQSTR(a, b) \
61 wvtest_start_check_eq_str(__FILE__, __LINE__, (a), (b), false)
62 #define WVPASSNE(a, b) WVFAILEQ(a, b)
63 #define WVPASSNESTR(a, b) WVFAILEQSTR(a, b)
64 #define WVFAILNE(a, b) WVPASSEQ(a, b)
65 #define WVFAILNESTR(a, b) WVPASSEQSTR(a, b)
66 #define WVFRSH(frshretval) \
67 wvtest_start_check_frsh(__FILE__, __LINE__, #frshretval, (frshretval))
70 #define WVTEST_MAIN3(_descr, ff, ll, _slowness) \
71 static void _wvtest_main_##ll(); \
72 struct WvTest _wvtest_##ll = \
73 { .descr = _descr, .idstr = ff ":" #ll, .main = _wvtest_main_##ll, .slowness = _slowness }; \
74 static void _wvtest_register_##ll() __attribute__ ((constructor)); \
75 static void _wvtest_register_##ll() { wvtest_register(&_wvtest_##ll); } \
76 static void _wvtest_main_##ll()
77 #define WVTEST_MAIN2(descr, ff, ll, slowness) \
78 WVTEST_MAIN3(descr, ff, ll, slowness)
79 #define WVTEST_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 0)
80 #define WVTEST_SLOW_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 1)