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 MainFunc();
19 const char *descr, *idstr;
23 static WvTest *first, *last;
24 static int fails, runs;
25 static time_t start_time;
26 static bool run_twice;
28 static void alarm_handler(int sig);
30 static void print_result(bool start, const char *file, int line,
31 const char *condstr, bool result);
33 WvTest(const char *_descr, const char *_idstr, MainFunc *_main, int _slow);
34 static int run_all(const char * const *prefixes = NULL);
35 static void start(const char *file, int line, const char *condstr);
36 static void check(bool cond);
37 static inline bool start_check(const char *file, int line,
38 const char *condstr, bool cond)
39 { start(file, line, condstr); check(cond); return cond; }
40 static bool start_check_eq(const char *file, int line,
41 const char *a, const char *b, bool expect_pass);
42 static bool start_check_eq(const char *file, int line, int a, int b,
44 static bool start_check_lt(const char *file, int line,
45 const char *a, const char *b);
46 static bool start_check_lt(const char *file, int line, int a, int b);
50 #define WVPASS(cond) \
51 WvTest::start_check(__FILE__, __LINE__, #cond, (cond))
52 #define WVPASSEQ(a, b) \
53 WvTest::start_check_eq(__FILE__, __LINE__, (a), (b), true)
54 #define WVPASSLT(a, b) \
55 WvTest::start_check_lt(__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 WVPASSNE(a, b) WVFAILEQ(a, b)
61 #define WVFAILNE(a, b) WVPASSEQ(a, b)
63 #define WVTEST_MAIN3(descr, ff, ll, slowness) \
64 static void _wvtest_main_##ll(); \
65 static WvTest _wvtest_##ll(descr, ff, _wvtest_main_##ll, slowness); \
66 static void _wvtest_main_##ll()
67 #define WVTEST_MAIN2(descr, ff, ll, slowness) \
68 WVTEST_MAIN3(descr, ff, ll, slowness)
69 #define WVTEST_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 0)
70 #define WVTEST_SLOW_MAIN(descr) WVTEST_MAIN2(descr, __FILE__, __LINE__, 1)