提交 f0a528ce 编写于 作者: P Peter Krempa

tests: qemuxml2argv: Allow testing of config processed at startup

Add a new kind of XML output test for the files in qemuxml2argvtest
where we can validate setup and defaults applied when starting up the
VM.

This is achieved by formatting of the definition processed by the
qemuxml2argvtest into a XML and it's compared against files in
qemuxml2startupxmloutdata. This test is automatically executed if the
output file is present and it's skipped otherwise.

The first example test case is created from 'disk-drive-shared' test
case.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 6227c8ae
......@@ -127,6 +127,7 @@ EXTRA_DIST = \
qemuhotplugtestdomains \
qemumonitorjsondata \
qemuxml2argvdata \
qemuxml2startupxmloutdata \
qemuxml2xmloutdata \
qemustatusxml2xmldata \
qemuqapischema.json \
......
......@@ -277,6 +277,7 @@ struct testInfo {
unsigned int flags;
unsigned int parseFlags;
bool skipLegacyCPUs;
virDomainObjPtr vm;
};
......@@ -402,9 +403,39 @@ testUpdateQEMUCaps(const struct testInfo *info,
static int
testCompareXMLToArgv(const void *data)
testCompareXMLToStartupXML(const void *data)
{
const struct testInfo *info = data;
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
char *xml = NULL;
char *actual = NULL;
int ret = -1;
if (virAsprintf(&xml, "%s/qemuxml2startupxmloutdata/%s.xml",
abs_srcdir, info->name) < 0)
goto cleanup;
if (!virFileExists(xml)) {
ret = EXIT_AM_SKIP;
goto cleanup;
}
if (!(actual = virDomainDefFormat(info->vm->def, NULL, format_flags)))
goto cleanup;
ret = virTestCompareToFile(actual, xml);
cleanup:
VIR_FREE(xml);
VIR_FREE(actual);
return ret;
}
static int
testCompareXMLToArgv(const void *data)
{
struct testInfo *info = (void *) data;
char *xml = NULL;
char *args = NULL;
char *migrateURI = NULL;
......@@ -532,6 +563,9 @@ testCompareXMLToArgv(const void *data)
ret = 0;
}
if (!(flags & FLAG_EXPECT_FAILURE) && ret == 0)
VIR_STEAL_PTR(info->vm, vm);
cleanup:
VIR_FREE(log);
VIR_FREE(actualargv);
......@@ -625,7 +659,7 @@ mymain(void)
do { \
static struct testInfo info = { \
name, NULL, migrateFrom, migrateFd, (flags), parseFlags, \
false \
false, NULL \
}; \
info.skipLegacyCPUs = skipLegacyCPUs; \
if (testInitQEMUCaps(&info, gic) < 0) \
......@@ -634,7 +668,11 @@ mymain(void)
if (virTestRun("QEMU XML-2-ARGV " name, \
testCompareXMLToArgv, &info) < 0) \
ret = -1; \
if (info.vm && virTestRun("QEMU XML-2-startup-XML " name, \
testCompareXMLToStartupXML, &info) < 0) \
ret = -1; \
virObjectUnref(info.qemuCaps); \
virObjectUnref(info.vm); \
} while (0)
# define DO_TEST(name, ...) \
......
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</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-system-i686</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
<shareable/>
<serial>XYZXYZXYZYXXYZYZYXYZY</serial>
<alias name='ide0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest2'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<alias name='ide0-1-0'/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index='0'>
<alias name='ide'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<input type='mouse' bus='ps2'>
<alias name='input0'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input1'/>
</input>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</memballoon>
</devices>
</domain>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册