On Thu, Mar 29, 2018 at 01:51:10PM +0200, Peter Krempa wrote:
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: Peter Krempa <pkrempa(a)redhat.com>
---
tests/Makefile.am | 1 +
tests/qemuxml2argvtest.c | 42 +++++++++++++++-
.../disk-drive-shared.xml | 56 ++++++++++++++++++++++
3 files changed, 97 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2startupxmloutdata/disk-drive-shared.xml
@@ -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);
double space
+
+ cleanup:
+ VIR_FREE(xml);
+ VIR_FREE(actual);
+ return ret;
+}
+
+
ACK
Jano