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