2 * Copyright (c) 2008 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
25 * A library of utilities for writing 'make check'-based tests.
27 * Use this module like this:
28 * int test_one(void) {
30 * tu_dbg("yep, worked: %p", someptr);
35 * int main(int argc, char **argv)
37 * TestUtilsTest tests[] = {
38 * TU_TEST(test_one, 5),
39 * TU_TEST(test_two, 6),
44 * return testutils_run_tests(argc, argv, tests);
52 /* A test function, returning a boolean */
53 typedef int (*TestFunction)(void);
55 /* A struct for test functions */
56 typedef struct TestUtilsTest {
63 /* Macro to define a test array element */
64 #define TU_TEST(fn, to) { fn, #fn, to, FALSE }
65 #define TU_END() { NULL, NULL, 0, FALSE }
71 /* Debugging macro taking printf arguments. This is only enabled if the '-d' flag
72 * is given on the commandline. You can use g_debug, too, if you'd prefer. */
73 #define tu_dbg(...) if (tu_debugging_enabled) { g_fprintf(stderr, __VA_ARGS__); }
75 /* Is debugging enabled for this test run? (set internally) */
76 int tu_debugging_enabled;
82 int testutils_run_tests(int argc, char **argv, TestUtilsTest *tests);
84 #endif /* TESTUTILS_H */