mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
tests: genericxml2xml: Add testing of backup XML files
Now that the parser and formatter are in place we can exercise it on the test files. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
02f790ffbe
commit
d0805c27f5
@ -92,6 +92,7 @@ EXTRA_DIST = \
|
||||
cputestdata \
|
||||
domaincapsdata \
|
||||
domainbackupxml2xmlin \
|
||||
domainbackupxml2xmlout \
|
||||
domainconfdata \
|
||||
domainschemadata \
|
||||
fchostdata \
|
||||
|
18
tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
Normal file
18
tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<domainbackup mode='pull'>
|
||||
<incremental>1525889631</incremental>
|
||||
<server transport='tcp' name='localhost' port='10809'/>
|
||||
<disks>
|
||||
<disk name='vda' backup='yes' type='file'>
|
||||
<driver type='qcow2'/>
|
||||
<scratch file='/path/to/file'>
|
||||
<seclabel model='dac' relabel='no'/>
|
||||
</scratch>
|
||||
</disk>
|
||||
<disk name='vdb' backup='yes' type='block'>
|
||||
<driver type='qcow2'/>
|
||||
<scratch dev='/dev/block'>
|
||||
<seclabel model='dac' relabel='no'/>
|
||||
</scratch>
|
||||
</disk>
|
||||
</disks>
|
||||
</domainbackup>
|
10
tests/domainbackupxml2xmlout/backup-pull.xml
Normal file
10
tests/domainbackupxml2xmlout/backup-pull.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<domainbackup mode='pull'>
|
||||
<incremental>1525889631</incremental>
|
||||
<server transport='tcp' name='localhost' port='10809'/>
|
||||
<disks>
|
||||
<disk name='vda' backup='yes' type='file'>
|
||||
<scratch file='/path/to/file'/>
|
||||
</disk>
|
||||
<disk name='hda' backup='no'/>
|
||||
</disks>
|
||||
</domainbackup>
|
17
tests/domainbackupxml2xmlout/backup-push-seclabel.xml
Normal file
17
tests/domainbackupxml2xmlout/backup-push-seclabel.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<domainbackup mode='push'>
|
||||
<incremental>1525889631</incremental>
|
||||
<disks>
|
||||
<disk name='vda' backup='yes' type='file'>
|
||||
<driver type='raw'/>
|
||||
<target file='/path/to/file'>
|
||||
<seclabel model='dac' relabel='no'/>
|
||||
</target>
|
||||
</disk>
|
||||
<disk name='vdb' backup='yes' type='block'>
|
||||
<driver type='qcow2'/>
|
||||
<target dev='/dev/block'>
|
||||
<seclabel model='dac' relabel='no'/>
|
||||
</target>
|
||||
</disk>
|
||||
</disks>
|
||||
</domainbackup>
|
10
tests/domainbackupxml2xmlout/backup-push.xml
Normal file
10
tests/domainbackupxml2xmlout/backup-push.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<domainbackup mode='push'>
|
||||
<incremental>1525889631</incremental>
|
||||
<disks>
|
||||
<disk name='vda' backup='yes' type='file'>
|
||||
<driver type='raw'/>
|
||||
<target file='/path/to/file'/>
|
||||
</disk>
|
||||
<disk name='hda' backup='no'/>
|
||||
</disks>
|
||||
</domainbackup>
|
1
tests/domainbackupxml2xmlout/empty.xml
Normal file
1
tests/domainbackupxml2xmlout/empty.xml
Normal file
@ -0,0 +1 @@
|
||||
<domainbackup mode='push'/>
|
@ -8,6 +8,7 @@
|
||||
#include "testutils.h"
|
||||
#include "internal.h"
|
||||
#include "virstring.h"
|
||||
#include "conf/backup_conf.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
@ -44,6 +45,41 @@ testCompareXMLToXMLHelper(const void *data)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
testCompareBackupXML(const void *data)
|
||||
{
|
||||
const char *testname = data;
|
||||
g_autofree char *xml_in = NULL;
|
||||
g_autofree char *file_in = NULL;
|
||||
g_autofree char *file_out = NULL;
|
||||
g_autoptr(virDomainBackupDef) backup = NULL;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
g_autofree char *actual = NULL;
|
||||
|
||||
file_in = g_strdup_printf("%s/domainbackupxml2xmlin/%s.xml",
|
||||
abs_srcdir, testname);
|
||||
file_out = g_strdup_printf("%s/domainbackupxml2xmlout/%s.xml",
|
||||
abs_srcdir, testname);
|
||||
|
||||
if (virFileReadAll(file_in, 1024 * 64, &xml_in) < 0)
|
||||
return -1;
|
||||
|
||||
if (!(backup = virDomainBackupDefParseString(xml_in, xmlopt, 0))) {
|
||||
VIR_TEST_VERBOSE("failed to parse backup def '%s'", file_in);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainBackupDefFormat(&buf, backup, false) < 0) {
|
||||
VIR_TEST_VERBOSE("failed to format backup def '%s'", file_in);
|
||||
return -1;
|
||||
}
|
||||
|
||||
actual = virBufferContentAndReset(&buf);
|
||||
|
||||
return virTestCompareToFile(actual, file_out);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
{
|
||||
@ -149,6 +185,16 @@ mymain(void)
|
||||
|
||||
DO_TEST_DIFFERENT("cputune");
|
||||
|
||||
#define DO_TEST_BACKUP(name) \
|
||||
if (virTestRun("QEMU BACKUP XML-2-XML " name, testCompareBackupXML, name) < 0) \
|
||||
ret = -1;
|
||||
|
||||
DO_TEST_BACKUP("empty");
|
||||
DO_TEST_BACKUP("backup-pull");
|
||||
DO_TEST_BACKUP("backup-pull-seclabel");
|
||||
DO_TEST_BACKUP("backup-push");
|
||||
DO_TEST_BACKUP("backup-push-seclabel");
|
||||
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(xmlopt);
|
||||
|
||||
|
@ -205,7 +205,8 @@ mymain(void)
|
||||
"genericxml2xmloutdata", "xlconfigdata", "libxlxml2domconfigdata",
|
||||
"qemuhotplugtestdomains");
|
||||
DO_TEST_DIR("domaincaps.rng", "domaincapsdata");
|
||||
DO_TEST_DIR("domainbackup.rng", "domainbackupxml2xmlin");
|
||||
DO_TEST_DIR("domainbackup.rng", "domainbackupxml2xmlin",
|
||||
"domainbackupxml2xmlout");
|
||||
DO_TEST_DIR("domaincheckpoint.rng", "qemudomaincheckpointxml2xmlin",
|
||||
"qemudomaincheckpointxml2xmlout");
|
||||
DO_TEST_DIR("domainsnapshot.rng", "qemudomainsnapshotxml2xmlin",
|
||||
|
Loading…
x
Reference in New Issue
Block a user