[PATCH 2/2] test: genericxml2xml: test graphics listen= compat

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

 



* Add a test for listen=XXX and <listen address=YYY/> collision error
* Add an explicit test for listen=XXX duplicated to <listen address=XXX/>
  We implicitly test it elsewhere but I figure it's better to be explicit,
  and this test case can be extended in the future for additional listen
  back compat if/when we support <listen type='socket'/> syntax
---
The latter test case I added to try and exercise the potential crash that
Jan pointed out here:

https://www.redhat.com/archives/libvir-list/2016-April/msg00241.html

That patch was fixed before committing but I was still curious... the test
case doesn't tickle the crash? STREQ_NULLABLE seems to avoid it somehow
for address=NULL, yet if I try to printf address->address it understandably
crashes. Oh well :)

 ...eneric-graphics-listen-back-compat-mismatch.xml | 30 ++++++++++++++++++++++
 .../generic-graphics-listen-back-compat.xml        | 28 ++++++++++++++++++++
 .../generic-graphics-listen-back-compat.xml        | 30 ++++++++++++++++++++++
 tests/genericxml2xmltest.c                         | 16 ++++++++----
 4 files changed, 99 insertions(+), 5 deletions(-)
 create mode 100644 tests/genericxml2xmlindata/generic-graphics-listen-back-compat-mismatch.xml
 create mode 100644 tests/genericxml2xmlindata/generic-graphics-listen-back-compat.xml
 create mode 100644 tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml

diff --git a/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-mismatch.xml b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-mismatch.xml
new file mode 100644
index 0000000..eee3fed
--- /dev/null
+++ b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-mismatch.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>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>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' listen='192.168.123.123'>
+      <listen type='address' address='1.2.3.4'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmlindata/generic-graphics-listen-back-compat.xml b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat.xml
new file mode 100644
index 0000000..c60fb6e
--- /dev/null
+++ b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat.xml
@@ -0,0 +1,28 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>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>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' listen='192.168.123.123'/>
+    <video>
+      <model type='cirrus' vram='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml
new file mode 100644
index 0000000..aa00d34
--- /dev/null
+++ b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml
@@ -0,0 +1,30 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>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>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='-1' autoport='yes' listen='192.168.123.123'>
+      <listen type='address' address='192.168.123.123'/>
+    </graphics>
+    <video>
+      <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 7d504db..05563fb 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -21,6 +21,7 @@ struct testInfo {
     const char *name;
     int different;
     bool inactive_only;
+    testCompareDomXML2XMLResult expectResult;
 };
 
 static int
@@ -40,7 +41,7 @@ testCompareXMLToXMLHelper(const void *data)
     ret = testCompareDomXML2XMLFiles(caps, xmlopt, xml_in,
                                      info->different ? xml_out : xml_in,
                                      !info->inactive_only, NULL, NULL, 0,
-                                     TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS);
+                                     info->expectResult);
  cleanup:
     VIR_FREE(xml_in);
     VIR_FREE(xml_out);
@@ -59,22 +60,27 @@ mymain(void)
     if (!(xmlopt = virTestGenericDomainXMLConfInit()))
         return EXIT_FAILURE;
 
-#define DO_TEST_FULL(name, is_different, inactive)                      \
+#define DO_TEST_FULL(name, is_different, inactive, expectResult)        \
     do {                                                                \
-        const struct testInfo info = {name, is_different, inactive};    \
+        const struct testInfo info = {name, is_different, inactive,     \
+                                      expectResult};                    \
         if (virtTestRun("GENERIC XML-2-XML " name,                      \
                         testCompareXMLToXMLHelper, &info) < 0)          \
             ret = -1;                                                   \
     } while (0)
 
 #define DO_TEST(name) \
-    DO_TEST_FULL(name, 0, false)
+    DO_TEST_FULL(name, 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS)
 
 #define DO_TEST_DIFFERENT(name) \
-    DO_TEST_FULL(name, 1, false)
+    DO_TEST_FULL(name, 1, false, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS)
 
     DO_TEST_DIFFERENT("disk-virtio");
 
+    DO_TEST_DIFFERENT("graphics-listen-back-compat");
+    DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false,
+        TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE);
+
     virObjectUnref(caps);
     virObjectUnref(xmlopt);
 
-- 
2.5.5

--
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]