2006-05-09 15:35:46 +00:00
|
|
|
/*
|
|
|
|
* utils.c: test utils
|
|
|
|
*
|
2012-02-02 23:16:43 +00:00
|
|
|
* Copyright (C) 2005, 2008-2012 Red Hat, Inc.
|
2006-05-09 15:35:46 +00:00
|
|
|
*
|
|
|
|
* See COPYING.LIB for the License of this software
|
|
|
|
*
|
|
|
|
* Karel Zak <kzak@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIT_TEST_UTILS_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIT_TEST_UTILS_H__
|
2006-05-09 15:35:46 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <stdio.h>
|
2012-02-02 23:16:43 +00:00
|
|
|
# include "memory.h"
|
2009-05-12 16:45:14 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
|
2011-04-29 16:21:20 +00:00
|
|
|
# define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */
|
|
|
|
|
|
|
|
extern char *progname;
|
|
|
|
extern char *abs_srcdir;
|
2009-12-15 08:43:29 +00:00
|
|
|
|
2008-08-20 20:48:35 +00:00
|
|
|
double virtTestCountAverage(double *items,
|
|
|
|
int nitems);
|
2006-05-09 15:35:46 +00:00
|
|
|
|
2009-11-30 19:01:31 +00:00
|
|
|
void virtTestResult(const char *name, int ret, const char *msg, ...);
|
2008-08-20 20:48:35 +00:00
|
|
|
int virtTestRun(const char *title,
|
|
|
|
int nloops,
|
|
|
|
int (*body)(const void *data),
|
|
|
|
const void *data);
|
2011-04-24 22:25:10 +00:00
|
|
|
int virtTestLoadFile(const char *file, char **buf);
|
|
|
|
int virtTestCaptureProgramOutput(const char *const argv[], char **buf, int maxlen);
|
2008-02-05 19:27:37 +00:00
|
|
|
|
2009-05-21 14:22:51 +00:00
|
|
|
int virtTestClearLineRegex(const char *pattern,
|
|
|
|
char *string);
|
2006-05-09 15:35:46 +00:00
|
|
|
|
2008-08-20 20:48:35 +00:00
|
|
|
int virtTestDifference(FILE *stream,
|
|
|
|
const char *expect,
|
|
|
|
const char *actual);
|
2010-12-06 17:03:22 +00:00
|
|
|
int virtTestDifferenceBin(FILE *stream,
|
|
|
|
const char *expect,
|
|
|
|
const char *actual,
|
|
|
|
size_t length);
|
2006-05-09 15:35:46 +00:00
|
|
|
|
2009-11-30 19:01:31 +00:00
|
|
|
unsigned int virTestGetDebug(void);
|
|
|
|
unsigned int virTestGetVerbose(void);
|
2009-10-16 15:37:36 +00:00
|
|
|
|
tests: silence qemuargv2xmltest noise
Before this patch, the testsuite was noisy:
TEST: qemuargv2xmltest
........................................ 40
................20:41:28.046: warning : qemuParseCommandLine:6565 : unknown QEMU argument '-unknown', adding to the qemu namespace
20:41:28.046: warning : qemuParseCommandLine:6565 : unknown QEMU argument 'parameter', adding to the qemu namespace
. 57 OK
PASS: qemuargv2xmltest
It's not a real failure (which is why the test was completing
successfully), so much as an intentional warning to the user that use
of the qemu namespace has the potential for undefined effects that
leaked through the default logging behavior. After this patch series,
all tests can access any logged data, and this particular test can
explicitly check for the presence or absence of the warning, such that
the test output becomes:
TEST: qemuargv2xmltest
........................................ 40
................. 57 OK
PASS: qemuargv2xmltest
* tests/testutils.h (virtTestLogContentAndReset): New prototype.
* tests/testutils.c (struct virtTestLogData): New struct.
(virtTestLogOutput, virtTestLogClose, virtTestLogContentAndReset):
New functions.
(virtTestMain): Always capture log data emitted during tests.
* tests/qemuargv2xmltest.c (testCompareXMLToArgvHelper, mymain):
Use flag to mark which tests expect noisy stderr.
(testCompareXMLToArgvFiles): Add parameter to test whether stderr
was appropriately silent.
2010-09-10 16:25:49 +00:00
|
|
|
char *virtTestLogContentAndReset(void);
|
|
|
|
|
2008-08-20 20:48:35 +00:00
|
|
|
int virtTestMain(int argc,
|
|
|
|
char **argv,
|
2011-04-29 16:21:20 +00:00
|
|
|
int (*func)(void));
|
2008-05-29 15:21:45 +00:00
|
|
|
|
2011-04-29 16:21:20 +00:00
|
|
|
/* Setup, then call func() */
|
|
|
|
# define VIRT_TEST_MAIN(func) \
|
|
|
|
int main(int argc, char **argv) { \
|
|
|
|
return virtTestMain(argc, argv, func); \
|
2008-05-29 15:21:45 +00:00
|
|
|
}
|
|
|
|
|
2006-05-09 15:35:46 +00:00
|
|
|
#endif /* __VIT_TEST_UTILS_H__ */
|