#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <stdbool.h>
#include <sys/types.h>
#include <fcntl.h>
}
static int testCompareXMLToArgvFiles(const char *xml,
- const char *cmdfile) {
+ const char *cmdfile,
+ bool expect_warning) {
char xmlData[MAX_FILE];
char cmdData[MAX_FILE];
char *expectxml = &(xmlData[0]);
char *cmd = &(cmdData[0]);
int ret = -1;
virDomainDefPtr vmdef = NULL;
+ char *log;
if (virtTestLoadFile(cmdfile, &cmd, MAX_FILE) < 0)
goto fail;
if (!(vmdef = qemuParseCommandLineString(driver.caps, cmd)))
goto fail;
+ if ((log = virtTestLogContentAndReset()) == NULL)
+ goto fail;
+ if ((*log != '\0') != expect_warning) {
+ free(log);
+ goto fail;
+ }
+ free(log);
+
if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail;
abs_srcdir, info->name);
snprintf(args, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.args",
abs_srcdir, info->name);
- return testCompareXMLToArgvFiles(xml, args);
+ return testCompareXMLToArgvFiles(xml, args, !!info->extraFlags);
}
DO_TEST_FULL("restore-v2", 0, "exec:cat");
DO_TEST_FULL("migrate", 0, "tcp:10.0.0.1:5000");
- DO_TEST("qemu-ns-no-env");
+ DO_TEST_FULL("qemu-ns-no-env", 1, NULL);
free(driver.stateDir);
virCapabilitiesFree(driver.caps);
/*
* testutils.c: basic test utils
*
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
#include "util.h"
#include "threads.h"
#include "virterror_internal.h"
+#include "buf.h"
+#include "logging.h"
#if TEST_OOM_TRACE
# include <execinfo.h>
{ }
#endif
+struct virtTestLogData {
+ virBuffer buf;
+};
+
+static struct virtTestLogData testLog = { VIR_BUFFER_INITIALIZER };
+
+static int
+virtTestLogOutput(const char *category ATTRIBUTE_UNUSED,
+ int priority ATTRIBUTE_UNUSED,
+ const char *funcname ATTRIBUTE_UNUSED,
+ long long lineno ATTRIBUTE_UNUSED,
+ const char *str, int len, void *data)
+{
+ struct virtTestLogData *log = data;
+ virBufferAdd(&log->buf, str, len);
+ return len;
+}
+
+static void
+virtTestLogClose(void *data)
+{
+ struct virtTestLogData *log = data;
+
+ virBufferFreeAndReset(&log->buf);
+}
+
+/* Return a malloc'd string (possibly with strlen of 0) of all data
+ * logged since the last call to this function, or NULL on failure. */
+char *
+virtTestLogContentAndReset(void)
+{
+ char *ret;
+
+ if (virBufferError(&testLog.buf))
+ return NULL;
+ ret = virBufferContentAndReset(&testLog.buf);
+ return ret ? ret : strdup("");
+}
+
#if TEST_OOM_TRACE
static void
virtTestErrorHook(int n, void *data ATTRIBUTE_UNUSED)
virRandomInitialize(time(NULL) ^ getpid()))
return 1;
+ if (virLogDefineOutput(virtTestLogOutput, virtTestLogClose, &testLog,
+ 0, 0, NULL, 0) < 0)
+ return 1;
#if TEST_OOM
if ((oomStr = getenv("VIR_TEST_OOM")) != NULL) {
/*
* utils.c: test utils
*
- * Copyright (C) 2005, 2008-2009 Red Hat, Inc.
+ * Copyright (C) 2005, 2008-2010 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
unsigned int virTestGetDebug(void);
unsigned int virTestGetVerbose(void);
+char *virtTestLogContentAndReset(void);
+
int virtTestMain(int argc,
char **argv,
int (*func)(int, char **));