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"
19 typedef void MainFunc();
20 const char *descr, *idstr;
24 static WvTest *first, *last;
25 static int fails, runs;
26 static time_t start_time;
27 static bool run_twice;
29 static void alarm_handler(int sig);
31 static void print_result(bool start, const char *file, int line,
32 const char *condstr, bool result);
34 WvTest(const char *_descr, const char *_idstr, MainFunc *_main, int _slow);
35 static int run_all(const char * const *prefixes = NULL);
36 static void start(const char *file, int line, const char *condstr);
37 static void check(bool cond);
38 static inline bool start_check(const char *file, int line,
39 const char *condstr, bool cond)
40 { start(file, line, condstr); check(cond); return cond; }
41 static bool start_check_eq(const char *file, int line,
42 const char *a, const char *b, bool expect_pass);
43 static bool start_check_eq(const char *file, int line,
44 const std::string &a, const std::string &b,
46 static bool start_check_eq(const char *file, int line, int a, int b,
48 static bool start_check_lt(const char *file, int line,
49 const char *a, const char *b);
50 static bool start_check_lt(const char *file, int line, int a, int b);
54 #define WVPASS(cond) \
55 WvTest::start_check(__FILE__, __LINE__, #cond, (cond))
56 #define WVPASSEQ(a, b) \
57 WvTest::start_check_eq(__FILE__, __LINE__, (a), (b), true)
58 #define WVPASSLT(a, b) \
59 WvTest::start_check_lt(__FILE__, __LINE__, (a), (b))
60 #define WVFAIL(cond) \
61 WvTest::start_check(__FILE__, __LINE__, "NOT(" #cond ")", !(cond))
62 #define WVFAILEQ(a, b) \
63 WvTest::start_check_eq(__FILE__, __LINE__, (a), (b), false)
64 #define WVPASSNE(a, b) WVFAILEQ(a, b)
65 #define WVFAILNE(a, b) WVPASSEQ(a, b)
67 #define WVTEST_MAIN3(descr, ff, ll, slowness) \
68 static void _wvtest_main_##ll(); \
69 static WvTest _wvtest_##ll(descr, ff, _wvtest_main_##ll, slowness); \
70 static void _wvtest_main_##ll()
71 #define WVTEST_MAIN2(descr, ff, ll, slowness) \
72 WVTEST_MAIN3(descr, ff, ll, slowness)
73 #define WVTEST_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 0)
74 #define WVTEST_SLOW_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 1)