testutils.h 1.6 KB
Newer Older
K
Karel Zak 已提交
1 2 3
/*
 * utils.c: test utils
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2005, 2008-2011 Red Hat, Inc.
K
Karel Zak 已提交
5 6 7 8 9 10 11
 *
 * See COPYING.LIB for the License of this software
 *
 * Karel Zak <kzak@redhat.com>
 */

#ifndef __VIT_TEST_UTILS_H__
12
# define __VIT_TEST_UTILS_H__
K
Karel Zak 已提交
13

14
# include <stdio.h>
15

16
# define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
E
Eric Blake 已提交
17 18 19 20
# define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */

extern char *progname;
extern char *abs_srcdir;
21

22 23
double virtTestCountAverage(double *items,
                            int nitems);
K
Karel Zak 已提交
24

25
void virtTestResult(const char *name, int ret, const char *msg, ...);
26 27 28 29 30 31 32 33 34 35
int virtTestRun(const char *title,
                int nloops,
                int (*body)(const void *data),
                const void *data);
int virtTestLoadFile(const char *name,
                     char **buf,
                     int buflen);
int virtTestCaptureProgramOutput(const char *const argv[],
                                 char **buf,
                                 int buflen);
36

37 38
int virtTestClearLineRegex(const char *pattern,
                           char *string);
K
Karel Zak 已提交
39

40 41 42
int virtTestDifference(FILE *stream,
                       const char *expect,
                       const char *actual);
K
Karel Zak 已提交
43

44 45
unsigned int virTestGetDebug(void);
unsigned int virTestGetVerbose(void);
46

47 48
char *virtTestLogContentAndReset(void);

49 50
int virtTestMain(int argc,
                 char **argv,
E
Eric Blake 已提交
51
                 int (*func)(void));
52

E
Eric Blake 已提交
53 54 55 56
/* Setup, then call func() */
# define VIRT_TEST_MAIN(func)                   \
    int main(int argc, char **argv) {           \
        return virtTestMain(argc, argv, func);  \
57 58
    }

K
Karel Zak 已提交
59
#endif /* __VIT_TEST_UTILS_H__ */