+Wed Jul 18 17:15:08 EST 2007 Daniel P. Berrange <berrange@redhat.com>
+
+ * tests/Makefile.am: Added QEMU tests
+ * tests/qemuxml2argvdata/*: Data files for QEMU tests
+ * tests/qemuxml2argvtest.c: Test XML -> argv conversion
+ * tests/qemuxml2xmltest.c: Test XML -> XML roundtrip
+
Wed Jul 18 17:11:08 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/xmlrpctest.c, src/xml2sexprtest.c: More void * to
reconnect
xmconfigtest
xencapstest
+qemuxml2xmltest
+qemuxml2argvtest
*.gcda
*.gcno
EXTRA_DIST = xmlrpcserver.py test_conf.sh
noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
- reconnect xmconfigtest xencapstest
+ reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest
-TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest xencapstest
+TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest \
+ xencapstest qemuxml2argvtest qemuxml2xmltest
if ENABLE_XEN_TESTS
TESTS += reconnect
endif
xmconfigtest_LDFLAGS =
xmconfigtest_LDADD = $(LDADDS)
+qemuxml2argvtest_SOURCES = \
+ qemuxml2argvtest.c \
+ testutils.c testutils.h
+qemuxml2argvtest_LDFLAGS =
+qemuxml2argvtest_LDADD = $(LDADDS)
+
+qemuxml2xmltest_SOURCES = \
+ qemuxml2xmltest.c \
+ testutils.c testutils.h
+qemuxml2xmltest_LDFLAGS =
+qemuxml2xmltest_LDADD = $(LDADDS)
+
virshtest_SOURCES = \
virshtest.c \
testutils.c testutils.h
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='cdrom'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/cdrom'/>
+ <target dev='hdc'/>
+ <readonly/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='fd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <disk type='file' device='floppy'>
+ <source file='/tmp/firmware.img'/>
+ <target dev='fda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='net'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc'/>
+ <readonly/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <disk type='block' device='floppy'>
+ <source dev='/dev/fd0'/>
+ <target dev='fda'/>
+ </disk>
+ <disk type='file' device='floppy'>
+ <source file='/tmp/firmware.img'/>
+ <target dev='fdb'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hdb'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/data.img'/>
+ <target dev='hdc'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/logs.img'/>
+ <target dev='hdd'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -sdl
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='sdl'/>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -vnc 127.0.0.1:3
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='vnc' port='5903' listen='127.0.0.1'/>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <input type='mouse' bus='usb'/>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <input type='tablet' bus='usb'/>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ </devices>
+</domain>
--- /dev/null
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb -nographic
\ No newline at end of file
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219200</memory>
+ <currentMemory>219200</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda'/>
+ </disk>
+ <interface type='user'>
+ <mac address='00:11:22:33:44:55'/>
+ </interface>
+ </devices>
+</domain>
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "testutils.h"
+#include "qemu_conf.h"
+#include "internal.h"
+
+static char *progname;
+struct qemud_driver driver;
+
+#define MAX_FILE 4096
+
+static int testCompareXMLToArgvFiles(const char *xml, const char *cmd) {
+ char xmlData[MAX_FILE];
+ char argvData[MAX_FILE];
+ char *xmlPtr = &(xmlData[0]);
+ char *expectargv = &(argvData[0]);
+ char *actualargv = NULL;
+ char **argv = NULL;
+ char **tmp = NULL;
+ int ret = -1, len;
+ struct qemud_vm_def *vmdef;
+ struct qemud_vm vm;
+
+ if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+ goto fail;
+
+ if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0)
+ goto fail;
+
+ if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test")))
+ goto fail;
+
+ vm.def = vmdef;
+ vm.pid = -1;
+ vm.id = -1;
+ vmdef->vncActivePort = vmdef->vncPort;
+
+ if (qemudBuildCommandLine(NULL, &driver, &vm, &argv) < 0)
+ goto fail;
+
+ tmp = argv;
+ len = 0;
+ while (*tmp) {
+ len += strlen(*tmp) + 1;
+ tmp++;
+ }
+ actualargv = malloc(sizeof(char)*len);
+ actualargv[0] = '\0';
+ tmp = argv;
+ len = 0;
+ while (*tmp) {
+ if (actualargv[0])
+ strcat(actualargv, " ");
+ strcat(actualargv, *tmp);
+ tmp++;
+ }
+
+ if (strcmp(expectargv, actualargv)) {
+ if (getenv("DEBUG_TESTS")) {
+ printf("Expect %4d '%s'\n", (int)strlen(expectargv), expectargv);
+ printf("Actual %4d '%s'\n", (int)strlen(actualargv), actualargv);
+ }
+ goto fail;
+ }
+
+ ret = 0;
+
+ fail:
+ free(actualargv);
+ if (argv) {
+ tmp = argv;
+ while (*tmp) {
+ free(*tmp);
+ tmp++;
+ }
+ free(argv);
+ }
+
+ return ret;
+}
+
+
+static int testCompareXMLToArgvHelper(const void *data) {
+ char xml[PATH_MAX];
+ char args[PATH_MAX];
+ snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data);
+ snprintf(args, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.args", (const char*)data);
+ return testCompareXMLToArgvFiles(xml, args);
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ int ret = 0;
+
+ progname = argv[0];
+
+ if (argc > 1) {
+ fprintf(stderr, "Usage: %s\n", progname);
+ exit(EXIT_FAILURE);
+ }
+
+ driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1;
+ driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON |
+ QEMUD_CMD_FLAG_NO_REBOOT;
+
+ if (virtTestRun("QEMU XML-2-ARGV minimal",
+ 1, testCompareXMLToArgvHelper, "minimal") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot CDROM",
+ 1, testCompareXMLToArgvHelper, "boot-cdrom") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot Network",
+ 1, testCompareXMLToArgvHelper, "boot-network") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot Floppy",
+ 1, testCompareXMLToArgvHelper, "boot-floppy") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Clock UTC",
+ 1, testCompareXMLToArgvHelper, "clock-utc") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Clock Localtime",
+ 1, testCompareXMLToArgvHelper, "clock-localtime") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk CDROM",
+ 1, testCompareXMLToArgvHelper, "disk-cdrom") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk Floppy",
+ 1, testCompareXMLToArgvHelper, "disk-floppy") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk Many",
+ 1, testCompareXMLToArgvHelper, "disk-many") < 0)
+ ret = -1;
+
+ if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+ 1, testCompareXMLToArgvHelper, "graphics-vnc") < 0)
+ ret = -1;
+
+ if (0 && virtTestRun("QEMU XML-2-ARGV Graphics SDL",
+ 1, testCompareXMLToArgvHelper, "graphics-sdl") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse",
+ 1, testCompareXMLToArgvHelper, "input-usbmouse") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet",
+ 1, testCompareXMLToArgvHelper, "input-usbtablet") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Misc ACPI",
+ 1, testCompareXMLToArgvHelper, "misc-acpi") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot",
+ 1, testCompareXMLToArgvHelper, "misc-no-reboot") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Net User",
+ 1, testCompareXMLToArgvHelper, "net-user") < 0)
+ ret = -1;
+
+
+ exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "testutils.h"
+#include "qemu_conf.h"
+#include "internal.h"
+
+static char *progname;
+struct qemud_driver driver;
+
+#define MAX_FILE 4096
+
+
+static int testCompareXMLToXMLFiles(const char *xml) {
+ char xmlData[MAX_FILE];
+ char *xmlPtr = &(xmlData[0]);
+ char *actual = NULL;
+ int ret = -1;
+ struct qemud_vm_def *vmdef;
+ struct qemud_vm vm;
+
+ if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+ goto fail;
+
+ if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test")))
+ goto fail;
+
+ vm.def = vmdef;
+ vm.pid = -1;
+ vm.id = -1;
+ vmdef->vncActivePort = vmdef->vncPort;
+
+ if (!(actual = qemudGenerateXML(NULL, &driver, &vm, vmdef, 0)))
+ goto fail;
+
+ if (strcmp(xmlData, actual)) {
+ if (getenv("DEBUG_TESTS")) {
+ printf("Expect %4d '%s'\n", (int)strlen(xmlData), xmlData);
+ printf("Actual %4d '%s'\n", (int)strlen(actual), actual);
+ }
+ goto fail;
+ }
+
+ ret = 0;
+
+ fail:
+ free(actual);
+
+ return ret;
+}
+
+static int testCompareXMLToXMLHelper(const void *data) {
+ char xml[PATH_MAX];
+ snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data);
+ return testCompareXMLToXMLFiles(xml);
+}
+
+
+int
+main(int argc, char **argv)
+{
+ int ret = 0;
+
+ progname = argv[0];
+
+ if (argc > 1) {
+ fprintf(stderr, "Usage: %s\n", progname);
+ exit(EXIT_FAILURE);
+ }
+
+ driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1;
+ driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON |
+ QEMUD_CMD_FLAG_NO_REBOOT;
+
+ if (virtTestRun("QEMU XML-2-ARGV minimal",
+ 1, testCompareXMLToXMLHelper, "minimal") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot CDROM",
+ 1, testCompareXMLToXMLHelper, "boot-cdrom") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot Network",
+ 1, testCompareXMLToXMLHelper, "boot-network") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Boot Floppy",
+ 1, testCompareXMLToXMLHelper, "boot-floppy") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Clock UTC",
+ 1, testCompareXMLToXMLHelper, "clock-utc") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Clock Localtime",
+ 1, testCompareXMLToXMLHelper, "clock-localtime") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk CDROM",
+ 1, testCompareXMLToXMLHelper, "disk-cdrom") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk Floppy",
+ 1, testCompareXMLToXMLHelper, "disk-floppy") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Disk Many",
+ 1, testCompareXMLToXMLHelper, "disk-many") < 0)
+ ret = -1;
+
+ if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+ 1, testCompareXMLToXMLHelper, "graphics-vnc") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Graphics SDL",
+ 1, testCompareXMLToXMLHelper, "graphics-sdl") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse",
+ 1, testCompareXMLToXMLHelper, "input-usbmouse") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet",
+ 1, testCompareXMLToXMLHelper, "input-usbtablet") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Misc ACPI",
+ 1, testCompareXMLToXMLHelper, "misc-acpi") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot",
+ 1, testCompareXMLToXMLHelper, "misc-no-reboot") < 0)
+ ret = -1;
+
+ if (virtTestRun("QEMU XML-2-ARGV Net User",
+ 1, testCompareXMLToXMLHelper, "net-user") < 0)
+ ret = -1;
+
+
+ exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+/*
+ * Local variables:
+ * indent-tabs-mode: nil
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */