From nobody Wed Jan 15 09:25:08 2025 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1704733460601511.37149164302; Mon, 8 Jan 2024 09:04:20 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 83FA11B3C; Mon, 8 Jan 2024 12:04:19 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 59CED1A7E; Mon, 8 Jan 2024 11:09:01 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8E0631878; Mon, 8 Jan 2024 11:07:59 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4DBD21A59 for ; Mon, 8 Jan 2024 11:06:16 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-262-NfKVqlGaMb6kPQc3Y-2ozw-1; Mon, 08 Jan 2024 11:06:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48D62185A780 for ; Mon, 8 Jan 2024 16:06:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5BD9C15A0C for ; Mon, 8 Jan 2024 16:06:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: NfKVqlGaMb6kPQc3Y-2ozw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 19/23] qemuxml2argvtest: Test (inactive) def -> xml conversion Date: Mon, 8 Jan 2024 17:05:49 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: EWF432MJ2XNOVILTAJKJ3PYYXE562HPS X-Message-ID-Hash: EWF432MJ2XNOVILTAJKJ3PYYXE562HPS X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1704733462016100001 This is an intermediate step to merge qemuxml2xmltest into this common helper. This eliminates double setup/parsing of the input data as well as will ensure that all input XMLs are tested both for ARGV as well as XML output. For now we skip tests that don't have an output XML to show that the this does everything that qemuxml2xmltest does. Signed-off-by: Peter Krempa --- tests/qemuxml2argvtest.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d06bed32cb..4433b75d61 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -731,6 +731,35 @@ testQemuConfXMLCommon(testQemuInfo *info, } +static int +testCompareDef2XML(const void *data) +{ + testQemuInfo *info =3D (void *) data; + g_autofree char *actual =3D NULL; + g_autoptr(virDomainDef) def =3D NULL; + unsigned int format_flags =3D VIR_DOMAIN_DEF_FORMAT_SECURE; + int rc =3D 0; + + if (!testQemuConfXMLCommon(info, &rc)) + return rc; + + /* skip tests without output file for now */ + if (!virTestGetRegenerate() && !virFileExists(info->out_xml_inactive)) + return EXIT_AM_SKIP; + + /* we deliberately format the XML as live to catch potential test regr= essions + * as virDomainDefFormatInternalSetRootName implies _INACTIVE if 'def-= >id' + * is -1, thus VM is inactive. */ + if (!(actual =3D virDomainDefFormat(info->def, driver.xmlopt, format_f= lags))) + return -1; + + if (virTestCompareToFile(actual, info->out_xml_inactive) < 0) + return -1; + + return 0; +} + + static int testCompareXMLToArgv(const void *data) { @@ -923,6 +952,7 @@ testRun(const char *name, ...) { g_autofree char *name_parse =3D g_strdup_printf("QEMU XML def parse %s= %s", name, suffix); + g_autofree char *name_xml =3D g_strdup_printf("QEMU XML def -> XML %s%= s", name, suffix); g_autofree char *name_argv =3D g_strdup_printf("QEMU XML def -> ARGV %= s%s", name, suffix); g_autoptr(testQemuInfo) info =3D g_new0(testQemuInfo, 1); va_list ap; @@ -937,8 +967,10 @@ testRun(const char *name, info->infile =3D g_strdup_printf("%s/qemuxml2argvdata/%s.xml", abs_src= dir, info->name); info->outfile =3D g_strdup_printf("%s/qemuxml2argvdata/%s%s.args", abs= _srcdir, info->name, suffix); info->errfile =3D g_strdup_printf("%s/qemuxml2argvdata/%s%s.err", abs_= srcdir, info->name, suffix); + info->out_xml_inactive =3D g_strdup_printf("%s/qemuxml2xmloutdata/%s%s= .xml", abs_srcdir, info->name, suffix); virTestRunLog(ret, name_parse, testXMLParse, info); + virTestRunLog(ret, name_xml, testCompareDef2XML, info); virTestRunLog(ret, name_argv, testCompareXMLToArgv, info); /* clear overriden host cpu */ --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org