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 int wvtest_run_all(char * const *prefixes);
28 void wvtest_start(const char *file, int line, const char *condstr);
29 void wvtest_check(bool cond, const char *reason);
30 static inline bool wvtest_start_check(const char *file, int line,
31 const char *condstr, bool cond)
32 { wvtest_start(file, line, condstr); wvtest_check(cond, NULL); return cond; }
33 bool wvtest_start_check_eq(const char *file, int line,
34 const char *a, const char *b, bool expect_pass);
35 bool wvtest_start_check_lt(const char *file, int line,
36 const char *a, const char *b);
37 int wvtest_start_check_frsh(const char *file, int line,
38 const char *condstr, int frsh_retval);
41 #define WVPASS(cond) \
42 wvtest_start_check(__FILE__, __LINE__, #cond, (cond))
43 #define WVPASSEQ(a, b) \
44 wvtest_start_check_eq(__FILE__, __LINE__, (a), (b), true)
45 #define WVPASSLT(a, b) \
46 wvtest_start_check_lt(__FILE__, __LINE__, (a), (b))
47 #define WVFAIL(cond) \
48 wvtest_start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
49 #define WVFAILEQ(a, b) \
50 wvtest_start_check_eq(__FILE__, __LINE__, (a), (b), false)
51 #define WVPASSNE(a, b) WVFAILEQ(a, b)
52 #define WVFAILNE(a, b) WVPASSEQ(a, b)
53 #define WVFRSH(frshretval) \
54 wvtest_start_check_frsh(__FILE__, __LINE__, #frshretval, (frshretval))
57 #define WVTEST_MAIN3(_descr, ff, ll, _slowness) \
58 static void _wvtest_main_##ll(); \
59 struct WvTest _wvtest_##ll = \
60 { .descr = _descr, .idstr = ff ":" #ll, .main = _wvtest_main_##ll, .slowness = _slowness }, \
61 *_wvtest_ptr_##ll __attribute__ ((section ("wvtest"))) = &_wvtest_##ll; \
62 static void _wvtest_main_##ll()
63 #define WVTEST_MAIN2(descr, ff, ll, slowness) \
64 WVTEST_MAIN3(descr, ff, ll, slowness)
65 #define WVTEST_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 0)
66 #define WVTEST_SLOW_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 1)