test: genericxml2xml: test graphics listen= compat

* 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
This commit is contained in:
Cole Robinson 2016-04-08 13:16:12 -04:00
parent c493d21642
commit 313272e074
4 changed files with 99 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@ -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);