[PATCH 1/6] tests: Test qemuxml2xml when expected xml changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add tests for auto memballon, implicit IDE, SCSI, virtio channel
controllers, and console/serial back compat.

Additionally, an explicit qemuxml2argvtest for scsi disks is added.

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 tests/Makefile.am                                  |    1 +
 tests/domainschematest                             |    2 +-
 .../qemuxml2argv-balloon-device-auto.args          |    1 +
 .../qemuxml2argv-balloon-device-auto.xml           |   22 ++++++
 .../qemuxml2argv-console-compat-auto.args          |    1 +
 .../qemuxml2argv-console-compat-auto.xml           |   28 +++++++
 .../qemuxml2argv-disk-scsi-device-auto.args        |    1 +
 .../qemuxml2argv-disk-scsi-device-auto.xml         |   28 +++++++
 .../qemuxml2argv-disk-scsi-device.args             |    1 +
 .../qemuxml2argv-disk-scsi-device.xml              |   31 ++++++++
 tests/qemuxml2argvtest.c                           |    7 ++
 .../qemuxml2xmlout-balloon-device-auto.xml         |   25 ++++++
 .../qemuxml2xmlout-channel-virtio-auto.xml         |   54 +++++++++++++
 .../qemuxml2xmlout-console-compat-auto.xml         |   31 ++++++++
 .../qemuxml2xmlout-disk-scsi-device-auto.xml       |   31 ++++++++
 tests/qemuxml2xmltest.c                            |   79 +++++++++++++++-----
 16 files changed, 324 insertions(+), 19 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml

diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3661f6..71c2c74 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,6 +43,7 @@ EXTRA_DIST =		\
         oomtrace.pl     \
 	test-lib.sh	\
 	qemuxml2argvdata \
+	qemuxml2xmloutdata \
 	nodeinfodata     \
 	schematestutils.sh \
 	capabilityschematest \
diff --git a/tests/domainschematest b/tests/domainschematest
index d513f5a..7557cef 100755
--- a/tests/domainschematest
+++ b/tests/domainschematest
@@ -4,7 +4,7 @@
 . $srcdir/test-lib.sh
 . $abs_srcdir/schematestutils.sh
 
-DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata"
+DIRS="domainschemadata qemuxml2argvdata sexpr2xmldata xmconfigdata xml2sexprdata qemuxml2xmloutdata"
 SCHEMA="domain.rng"
 
 check_schema "$DIRS" "$SCHEMA"
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
new file mode 100644
index 0000000..08f0b8a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
new file mode 100644
index 0000000..26c9b25
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
@@ -0,0 +1,22 @@
+<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' bus='ide'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
new file mode 100644
index 0000000..fd42462
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
new file mode 100644
index 0000000..f0e875e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
@@ -0,0 +1,28 @@
+<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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
new file mode 100644
index 0000000..e29a4e8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
new file mode 100644
index 0000000..df50a27
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
@@ -0,0 +1,28 @@
+<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' bus='ide'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <disk type='file' device='disk'>
+      <source file='/tmp/scsidisk.img'/>
+      <target dev='sda' bus='scsi'/>
+    </disk>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
new file mode 100644
index 0000000..e29a4e8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device lsi,id=scsi0,bus=pci.0,addr=0x2 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-0 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 -drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 -device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
new file mode 100644
index 0000000..a250940
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
@@ -0,0 +1,31 @@
+<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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <source file='/tmp/scsidisk.img'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <controller type='scsi' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 3d6c583..566ab6b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -273,6 +273,10 @@ mymain(int argc, char **argv)
     DO_TEST("disk-usb", 0);
     DO_TEST("disk-usb-device", QEMUD_CMD_FLAG_DRIVE |
             QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
+    DO_TEST("disk-scsi-device", QEMUD_CMD_FLAG_DRIVE |
+            QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
+    DO_TEST("disk-scsi-device-auto", QEMUD_CMD_FLAG_DRIVE |
+            QEMUD_CMD_FLAG_DEVICE | QEMUD_CMD_FLAG_NODEFCONFIG);
     DO_TEST("graphics-vnc", 0);
 
     driver.vncSASL = 1;
@@ -318,6 +322,7 @@ mymain(int argc, char **argv)
     DO_TEST("serial-many", 0);
     DO_TEST("parallel-tcp", 0);
     DO_TEST("console-compat", 0);
+    DO_TEST("console-compat-auto", 0);
 
     DO_TEST("serial-vc-chardev", QEMUD_CMD_FLAG_CHARDEV|QEMUD_CMD_FLAG_DEVICE |
             QEMUD_CMD_FLAG_NODEFCONFIG);
@@ -354,6 +359,8 @@ mymain(int argc, char **argv)
             QEMUD_CMD_FLAG_NODEFCONFIG);
     DO_TEST("balloon-device", QEMUD_CMD_FLAG_DEVICE |
             QEMUD_CMD_FLAG_NODEFCONFIG);
+    DO_TEST("balloon-device-auto", QEMUD_CMD_FLAG_DEVICE |
+            QEMUD_CMD_FLAG_NODEFCONFIG);
     DO_TEST("sound", 0);
     DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE |
             QEMUD_CMD_FLAG_NODEFCONFIG);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
new file mode 100644
index 0000000..ed91e37
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
@@ -0,0 +1,25 @@
+<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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
new file mode 100644
index 0000000..7990374
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
@@ -0,0 +1,54 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu cpuset='1-4,8-20,525'>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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <controller type='virtio-serial' index='0' ports='16' vectors='4'/>
+    <controller type='virtio-serial' index='1'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </controller>
+    <controller type='virtio-serial' index='2'/>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.0'/>
+      <address type='virtio-serial' controller='0' bus='0' port='0'/>
+    </channel>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.foo'/>
+      <address type='virtio-serial' controller='1' bus='0' port='0'/>
+    </channel>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.bar'/>
+      <address type='virtio-serial' controller='1' bus='0' port='3'/>
+    </channel>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.wizz'/>
+      <address type='virtio-serial' controller='0' bus='0' port='1'/>
+    </channel>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.ooh'/>
+      <address type='virtio-serial' controller='1' bus='0' port='4'/>
+    </channel>
+    <channel type='pty'>
+      <target type='virtio' name='org.linux-kvm.port.lla'/>
+      <address type='virtio-serial' controller='2' bus='0' port='0'/>
+    </channel>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
new file mode 100644
index 0000000..611ddb8
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
@@ -0,0 +1,31 @@
+<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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <serial type='pty'>
+      <target port='0'/>
+    </serial>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
new file mode 100644
index 0000000..a250940
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
@@ -0,0 +1,31 @@
+<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' bus='ide'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <source file='/tmp/scsidisk.img'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' unit='0'/>
+    </disk>
+    <controller type='ide' index='0'/>
+    <controller type='scsi' index='0'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 69829b1..08e0e73 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -22,41 +22,63 @@ static struct qemud_driver driver;
 # define MAX_FILE 4096
 
 
-static int testCompareXMLToXMLFiles(const char *xml) {
-    char xmlData[MAX_FILE];
-    char *xmlPtr = &(xmlData[0]);
+static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) {
+    char inXmlData[MAX_FILE];
+    char *inXmlPtr = &(inXmlData[0]);
+    char outXmlData[MAX_FILE];
+    char *outXmlPtr = &(outXmlData[0]);
     char *actual = NULL;
     int ret = -1;
-    virDomainDefPtr vmdef = NULL;
+    virDomainDefPtr def = NULL;
 
-    if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+    if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
+        goto fail;
+    if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
         goto fail;
 
-    if (!(vmdef = virDomainDefParseString(driver.caps, xmlData,
+    if (!(def = virDomainDefParseString(driver.caps, inXmlData,
                                           VIR_DOMAIN_XML_INACTIVE)))
         goto fail;
 
-    if (!(actual = virDomainDefFormat(vmdef, 0)))
+    if (!(actual = virDomainDefFormat(def, 0)))
         goto fail;
 
-    if (STRNEQ(xmlData, actual)) {
-        virtTestDifference(stderr, xmlData, actual);
+
+    if (STRNEQ(outXmlData, actual)) {
+        virtTestDifference(stderr, outXmlData, actual);
         goto fail;
     }
 
     ret = 0;
-
  fail:
     free(actual);
-    virDomainDefFree(vmdef);
+    virDomainDefFree(def);
     return ret;
 }
 
+struct testInfo {
+    const char *name;
+    int different;
+};
+
 static int testCompareXMLToXMLHelper(const void *data) {
-    char xml[PATH_MAX];
-    snprintf(xml, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
-             abs_srcdir, (const char*)data);
-    return testCompareXMLToXMLFiles(xml);
+    const struct testInfo *info = data;
+    char xml_in[PATH_MAX];
+    char xml_out[PATH_MAX];
+    int ret;
+
+    snprintf(xml_in, PATH_MAX, "%s/qemuxml2argvdata/qemuxml2argv-%s.xml",
+             abs_srcdir, info->name);
+    snprintf(xml_out, PATH_MAX, "%s/qemuxml2xmloutdata/qemuxml2xmlout-%s.xml",
+             abs_srcdir, info->name);
+
+    if (info->different) {
+        ret = testCompareXMLToXMLFiles(xml_in, xml_out);
+    } else {
+        ret = testCompareXMLToXMLFiles(xml_in, xml_in);
+    }
+
+    return ret;
 }
 
 
@@ -80,10 +102,24 @@ mymain(int argc, char **argv)
     if ((driver.caps = testQemuCapsInit()) == NULL)
         return (EXIT_FAILURE);
 
+# define DO_TEST_FULL(name, is_different)                               \
+    do {                                                                \
+        const struct testInfo info = {name, is_different};              \
+        if (virtTestRun("QEMU XML-2-XML " name,                         \
+                        1, testCompareXMLToXMLHelper, &info) < 0)       \
+            ret = -1;                                                   \
+    } while (0)
+
 # define DO_TEST(name) \
-    if (virtTestRun("QEMU XML-2-XML " name, \
-                    1, testCompareXMLToXMLHelper, (name)) < 0) \
-        ret = -1
+    DO_TEST_FULL(name, 0)
+
+# define DO_TEST_DIFFERENT(name) \
+    DO_TEST_FULL(name, 1)
+
+    /* Unset or set all envvars here that are copied in qemudBuildCommandLine
+     * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
+     * values for these envvars */
+    setenv("PATH", "/bin", 1);
 
     DO_TEST("minimal");
     DO_TEST("boot-cdrom");
@@ -105,6 +141,7 @@ mymain(int argc, char **argv)
     DO_TEST("disk-drive-cache-v1-wt");
     DO_TEST("disk-drive-cache-v1-wb");
     DO_TEST("disk-drive-cache-v1-none");
+    DO_TEST("disk-scsi-device");
     DO_TEST("graphics-vnc");
     DO_TEST("graphics-vnc-sasl");
     DO_TEST("graphics-vnc-tls");
@@ -140,6 +177,12 @@ mymain(int argc, char **argv)
 
     DO_TEST("encrypted-disk");
 
+    /* These tests generate different XML */
+    DO_TEST_DIFFERENT("balloon-device-auto");
+    DO_TEST_DIFFERENT("channel-virtio-auto");
+    DO_TEST_DIFFERENT("console-compat-auto");
+    DO_TEST_DIFFERENT("disk-scsi-device-auto");
+
     virCapabilitiesFree(driver.caps);
 
     return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
-- 
1.7.1.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]