Re: [libvirt] [PATCH v2 09/25] tests: genericxml2xml: Add testing of backup XML files

2019-12-09 Thread Ján Tomko

On Tue, Dec 03, 2019 at 06:17:31PM +0100, Peter Krempa wrote:

Now that the parser and formatter are in place we can excercise it on
the test files.

Signed-off-by: Peter Krempa 
---
tests/Makefile.am |  1 +
.../backup-pull-seclabel.xml  | 18 
tests/domainbackupxml2xmlout/backup-pull.xml  | 10 
.../backup-push-seclabel.xml  | 17 +++
tests/domainbackupxml2xmlout/backup-push.xml  | 10 
tests/domainbackupxml2xmlout/empty.xml|  1 +
tests/genericxml2xmltest.c| 46 +++
tests/virschematest.c |  3 +-
8 files changed, 105 insertions(+), 1 deletion(-)
create mode 100644 tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
create mode 100644 tests/domainbackupxml2xmlout/backup-pull.xml
create mode 100644 tests/domainbackupxml2xmlout/backup-push-seclabel.xml
create mode 100644 tests/domainbackupxml2xmlout/backup-push.xml
create mode 100644 tests/domainbackupxml2xmlout/empty.xml



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 09/25] tests: genericxml2xml: Add testing of backup XML files

2019-12-04 Thread Eric Blake

On 12/3/19 11:17 AM, Peter Krempa wrote:

Now that the parser and formatter are in place we can excercise it on


exercise


the test files.

Signed-off-by: Peter Krempa 
---

Reviewed-by: Eric Blake 

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list



Re: [libvirt] [PATCH v2 09/25] tests: genericxml2xml: Add testing of backup XML files

2019-12-04 Thread Daniel P . Berrangé
On Tue, Dec 03, 2019 at 06:17:31PM +0100, Peter Krempa wrote:
> Now that the parser and formatter are in place we can excercise it on
> the test files.
> 
> Signed-off-by: Peter Krempa 
> ---
>  tests/Makefile.am |  1 +
>  .../backup-pull-seclabel.xml  | 18 
>  tests/domainbackupxml2xmlout/backup-pull.xml  | 10 
>  .../backup-push-seclabel.xml  | 17 +++
>  tests/domainbackupxml2xmlout/backup-push.xml  | 10 
>  tests/domainbackupxml2xmlout/empty.xml|  1 +
>  tests/genericxml2xmltest.c| 46 +++
>  tests/virschematest.c |  3 +-
>  8 files changed, 105 insertions(+), 1 deletion(-)
>  create mode 100644 tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
>  create mode 100644 tests/domainbackupxml2xmlout/backup-pull.xml
>  create mode 100644 tests/domainbackupxml2xmlout/backup-push-seclabel.xml
>  create mode 100644 tests/domainbackupxml2xmlout/backup-push.xml
>  create mode 100644 tests/domainbackupxml2xmlout/empty.xml

Reviewed-by: Daniel P. Berrangé 


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v2 09/25] tests: genericxml2xml: Add testing of backup XML files

2019-12-03 Thread Peter Krempa
Now that the parser and formatter are in place we can excercise it on
the test files.

Signed-off-by: Peter Krempa 
---
 tests/Makefile.am |  1 +
 .../backup-pull-seclabel.xml  | 18 
 tests/domainbackupxml2xmlout/backup-pull.xml  | 10 
 .../backup-push-seclabel.xml  | 17 +++
 tests/domainbackupxml2xmlout/backup-push.xml  | 10 
 tests/domainbackupxml2xmlout/empty.xml|  1 +
 tests/genericxml2xmltest.c| 46 +++
 tests/virschematest.c |  3 +-
 8 files changed, 105 insertions(+), 1 deletion(-)
 create mode 100644 tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
 create mode 100644 tests/domainbackupxml2xmlout/backup-pull.xml
 create mode 100644 tests/domainbackupxml2xmlout/backup-push-seclabel.xml
 create mode 100644 tests/domainbackupxml2xmlout/backup-push.xml
 create mode 100644 tests/domainbackupxml2xmlout/empty.xml

diff --git a/tests/Makefile.am b/tests/Makefile.am
index ea9e2b2ad0..75eee0006c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -92,6 +92,7 @@ EXTRA_DIST = \
cputestdata \
domaincapsdata \
domainbackupxml2xmlin \
+   domainbackupxml2xmlout \
domainconfdata \
domainschemadata \
fchostdata \
diff --git a/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml 
b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
new file mode 100644
index 00..c631c9b979
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/backup-pull-seclabel.xml
@@ -0,0 +1,18 @@
+
+  1525889631
+  
+  
+
+  
+  
+
+  
+
+
+  
+  
+
+  
+
+  
+
diff --git a/tests/domainbackupxml2xmlout/backup-pull.xml 
b/tests/domainbackupxml2xmlout/backup-pull.xml
new file mode 100644
index 00..24fce9c0e7
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/backup-pull.xml
@@ -0,0 +1,10 @@
+
+  1525889631
+  
+  
+
+  
+
+
+  
+
diff --git a/tests/domainbackupxml2xmlout/backup-push-seclabel.xml 
b/tests/domainbackupxml2xmlout/backup-push-seclabel.xml
new file mode 100644
index 00..9986889ba3
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/backup-push-seclabel.xml
@@ -0,0 +1,17 @@
+
+  1525889631
+  
+
+  
+  
+
+  
+
+
+  
+  
+
+  
+
+  
+
diff --git a/tests/domainbackupxml2xmlout/backup-push.xml 
b/tests/domainbackupxml2xmlout/backup-push.xml
new file mode 100644
index 00..1997c814ae
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/backup-push.xml
@@ -0,0 +1,10 @@
+
+  1525889631
+  
+
+  
+  
+
+
+  
+
diff --git a/tests/domainbackupxml2xmlout/empty.xml 
b/tests/domainbackupxml2xmlout/empty.xml
new file mode 100644
index 00..b1ba4953be
--- /dev/null
+++ b/tests/domainbackupxml2xmlout/empty.xml
@@ -0,0 +1 @@
+
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index 0d04413712..1376221ef8 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -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, _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(, backup, false) < 0) {
+VIR_TEST_VERBOSE("failed to format backup def '%s'", file_in);
+return -1;
+}
+
+actual = virBufferContentAndReset();
+
+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);

diff --git a/tests/virschematest.c b/tests/virschematest.c
index 5ae2d207d1..e4a440afb0 100644