The latter test checks for memory leaks.
+If you encounter any failing tests, the VIR_TEST_DEBUG environment variable
+may provide extra information to debug the failures. Larger values of
+VIR_TEST_DEBUG may provide larger amounts of information:
+
+ VIR_TEST_DEBUG=1 make check (or)
+ VIR_TEST_DEBUG=2 make check
+
+Also, individual tests can be run from inside the 'tests/' directory, like:
+
+ ./qemuxml2xmltest
+
(6) Update tests and/or documentation, particularly if you are adding
a new feature or changing the output of a program.
if (actual == expect) {
return 0;
} else {
- if (getenv("DEBUG_TESTS"))
+ if (virtTestGetDebug())
fprintf(stderr, "Expect %-6d Actual %-6d\n", expect, actual);
return -1;
}
* register a handler to stop error messages cluttering
* up display
*/
- if (!getenv("VIR_TEST_DEBUG"))
+ if (!virtTestGetDebug())
virSetErrorFunc(NULL, testQuietError);
#define DO_TEST(dev, num) \
((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
-unsigned int testDebug = 0;
+static unsigned int testDebug = -1;
static unsigned int testOOM = 0;
static unsigned int testCounter = 0;
const char *actualStart = actual;
const char *actualEnd = actual + (strlen(actual)-1);
- if (!testDebug)
+ if (!virtTestGetDebug())
return 0;
- if (testDebug < 2) {
+ if (virtTestGetDebug() < 2) {
/* Skip to first character where they differ */
while (*expectStart && *actualStart &&
*actualStart == *expectStart) {
}
#endif
+unsigned int
+virtTestGetDebug() {
+ char *debugStr;
+ unsigned int debug;
+
+ if (testDebug != -1)
+ return testDebug;
+
+ testDebug = 0;
+
+ if ((debugStr = getenv("VIR_TEST_DEBUG")) == NULL)
+ return 0;
+
+ if (virStrToLong_ui(debugStr, NULL, 10, &debug) < 0)
+ return 0;
+
+ testDebug = debug;
+ return testDebug;
+}
int virtTestMain(int argc,
char **argv,
int (*func)(int, char **))
{
- char *debugStr;
int ret;
#if TEST_OOM
int approxAlloc = 0;
virRandomInitialize(time(NULL) ^ getpid()))
return 1;
- if ((debugStr = getenv("VIR_TEST_DEBUG")) != NULL) {
- if (virStrToLong_ui(debugStr, NULL, 10, &testDebug) < 0)
- testDebug = 0;
- }
#if TEST_OOM
if ((oomStr = getenv("VIR_TEST_OOM")) != NULL) {
goto cleanup;
#if TEST_OOM_TRACE
- if (testDebug)
+ if (virtTestGetDebug())
virAllocTestHook(virtTestErrorHook, NULL);
#endif
approxAlloc = virAllocTestCount();
testCounter++;
- if (testDebug)
+ if (virtTestGetDebug())
fprintf(stderr, "%d) OOM...\n", testCounter);
else
fprintf(stderr, "%d) OOM of %d allocs ", testCounter, approxAlloc);
if (mp &&
(n % mp) != (worker - 1))
continue;
- if (!testDebug) {
+ if (!virtTestGetDebug()) {
if (mp)
fprintf(stderr, "%d", worker);
else
}
}
- if (testDebug)
+ if (virtTestGetDebug())
fprintf(stderr, " ... OOM of %d allocs", approxAlloc);
if (ret == EXIT_SUCCESS)
const char *expect,
const char *actual);
+unsigned int virtTestGetDebug(void);
+
int virtTestMain(int argc,
char **argv,
int (*func)(int, char **));
return virtTestMain(argc,argv, func); \
}
-extern unsigned int testDebug;
-
#endif /* __VIT_TEST_UTILS_H__ */