From nobody Mon Feb 9 02:14:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1575393545; cv=none; d=zohomail.com; s=zohoarc; b=m8kJc7FQzHySs0Fzb8S6oMaUMD7zOotKUicbQaqBqnwNRW7Khf5kWi0JN1LtoU/6qp58GJIV03/D/ZTXFVR4MxkZmvRJZ9aoQcmcuRnAE4MiCpKTJRBzbAAtHb+/DXDktcxz6eJLGJm6TNz0zKvb4dZqzCjXoSudf/LBKMjV4q0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575393545; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yyHaCH07dbZoOSXhqAOrwbegBTIVegSFX7ZdZ1kJGP8=; b=D5x0pF6ZKJMVmR5X57YvCClZosJJC1Fezj7A7VUa2ZRGvbmgfYjWe7sDmSy5Raa2HeJe7NYl7WQ7/SnbNIW93s+7HNGyMpLODkWAT5An1/Feby1BGEeo+W3VYL0vv/PDZxEZlO0s/4EH/u3v+vKT46OaDAcRAycUSf6jwlyCLgw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1575393545082663.5118317405362; Tue, 3 Dec 2019 09:19:05 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-t6r0Zkj8PYqAKzlBGIMkpQ-1; Tue, 03 Dec 2019 12:18:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDF9C101F4E6; Tue, 3 Dec 2019 17:18:15 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6ED15D6B7; Tue, 3 Dec 2019 17:18:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3359E5BC12; Tue, 3 Dec 2019 17:18:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB3HHwDb002897 for ; Tue, 3 Dec 2019 12:17:58 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87541600CE; Tue, 3 Dec 2019 17:17:58 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FB0B600CC for ; Tue, 3 Dec 2019 17:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575393542; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yyHaCH07dbZoOSXhqAOrwbegBTIVegSFX7ZdZ1kJGP8=; b=dRSvsx136lmLsRVj1PbUBoeMZDevz46B1PbNi7OX6wawfW1y0ufxLVhgVZrkd/uC8al4Vj JTj2BzUpWW1b3m8ChSLtBgi4NocWbh/IwS/qseS/t5/Df6gCJ0nCtruAdxYYVogJz/E+7O M18sh4ldiCjirFjF+IuU7UzZG911mAs= From: Peter Krempa To: libvir-list@redhat.com Date: Tue, 3 Dec 2019 18:17:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 09/25] tests: genericxml2xml: Add testing of backup XML files X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: t6r0Zkj8PYqAKzlBGIMkpQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that the parser and formatter are in place we can excercise it on the test files. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Eric Blake Reviewed-by: J=C3=A1n Tomko --- 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 =3D \ 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 0000000000..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/domainbac= kupxml2xmlout/backup-pull.xml new file mode 100644 index 0000000000..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 0000000000..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/domainbac= kupxml2xmlout/backup-push.xml new file mode 100644 index 0000000000..1997c814ae --- /dev/null +++ b/tests/domainbackupxml2xmlout/backup-push.xml @@ -0,0 +1,10 @@ + + 1525889631 + + + + + + + + diff --git a/tests/domainbackupxml2xmlout/empty.xml b/tests/domainbackupxml= 2xmlout/empty.xml new file mode 100644 index 0000000000..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 =3D data; + g_autofree char *xml_in =3D NULL; + g_autofree char *file_in =3D NULL; + g_autofree char *file_out =3D NULL; + g_autoptr(virDomainBackupDef) backup =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_autofree char *actual =3D NULL; + + file_in =3D g_strdup_printf("%s/domainbackupxml2xmlin/%s.xml", + abs_srcdir, testname); + file_out =3D g_strdup_printf("%s/domainbackupxml2xmlout/%s.xml", + abs_srcdir, testname); + + if (virFileReadAll(file_in, 1024 * 64, &xml_in) < 0) + return -1; + + if (!(backup =3D 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 =3D 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, na= me) < 0) \ + ret =3D -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 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -205,7 +205,8 @@ mymain(void) "genericxml2xmloutdata", "xlconfigdata", "libxlxml2domconf= igdata", "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", --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list