From nobody Sun Apr 28 22:34:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1676043329; cv=none; d=zohomail.com; s=zohoarc; b=hH9/U7XW7N11L5J3cZsp6gxFA63IuVa7//GB+XgZinVUWSpADSP+2CeOdSwPBNTuGNoD6dVfDYnHEl65+VYItCscMOd2fi6u638qhWwMcUBuxFV4NxVx9sqtFUEkkErLD9ECb/iTOYh6+r6jgnNjDlz7vTeagQzfRYVutGGOaR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676043329; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=TwrOoOQuxek4Z8jygMhVKxQPbyiKgRl5UyX0rBQ9eEw=; b=L+RQ/y+I86iCDbAgzrRoAkq8aVR1D48mFDwxEDOXe3HROopAz3UTq3vDVkiZZDiSLVgr2uKn/Lm2Jkn760NYaqZTEqF47laARYqJ9evhTXzWp5IR7pTm1m88LBjErMBgzeYxKirUMB+hgnGxEzcOa7RvTiL4lNqmzJ3KciISWGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676043329670279.28431077447476; Fri, 10 Feb 2023 07:35:29 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-6fW18mkRPfu6MBPBilxsLQ-1; Fri, 10 Feb 2023 10:35:23 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADB75857F40; Fri, 10 Feb 2023 15:35:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 086E6400DB37; Fri, 10 Feb 2023 15:35:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 96FA71946597; Fri, 10 Feb 2023 15:35:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 362D11946597 for ; Fri, 10 Feb 2023 15:35:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 09C8E40B42D4; Fri, 10 Feb 2023 15:35:04 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5C5B401014B for ; Fri, 10 Feb 2023 15:35:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676043328; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=TwrOoOQuxek4Z8jygMhVKxQPbyiKgRl5UyX0rBQ9eEw=; b=MNtwsgn0vuEP4GxFoweCZxcpiB0hXfQH+Na66ONRE6JcO5/RXNGr6Wh8fuV8ao2JbY+VVT +u0eFpquIvGESBCVya6uInMy1hjsOEIS4RAFWan/YyxTsBq0YQoCkyPATZT+hZViUQ0mo2 1IGrtUv1F3zfzA6nhlpCPIVRs0yfM8U= X-MC-Unique: 6fW18mkRPfu6MBPBilxsLQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] test: Introduce chxml2xmltest Date: Fri, 10 Feb 2023 16:35:02 +0100 Message-Id: <34519d6f2c35d2e324931583ad527e09f38808d0.1676043002.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676043330392100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Whilst reviewing a patch upstream (that ended up as v9.0.0-200-g092176e5ec), I realized we don't have a single xml2xml test for CH driver. Well, introduce the test with one simple test case for now. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- We could also benefit from xml2arg test, but I'll leave that for future ourselves. tests/chxml2xmlin/basic.xml | 30 ++++++++++++++ tests/chxml2xmlout/basic.xml | 1 + tests/chxml2xmltest.c | 77 ++++++++++++++++++++++++++++++++++++ tests/meson.build | 6 +++ 4 files changed, 114 insertions(+) create mode 100644 tests/chxml2xmlin/basic.xml create mode 120000 tests/chxml2xmlout/basic.xml create mode 100644 tests/chxml2xmltest.c diff --git a/tests/chxml2xmlin/basic.xml b/tests/chxml2xmlin/basic.xml new file mode 100644 index 0000000000..911aa7c621 --- /dev/null +++ b/tests/chxml2xmlin/basic.xml @@ -0,0 +1,30 @@ + + cloudhypervisor + 4dea22b3-1d52-d8f3-2516-782e98ab3fa0 + 2097152 + 2097152 + 2 + + hvm + hypervisor-fw + + + + destroy + restart + destroy + + /usr/local/bin/cloud-hypervisor + + + + + + + + + + + + + diff --git a/tests/chxml2xmlout/basic.xml b/tests/chxml2xmlout/basic.xml new file mode 120000 index 0000000000..eb8df546aa --- /dev/null +++ b/tests/chxml2xmlout/basic.xml @@ -0,0 +1 @@ +../chxml2xmlin/basic.xml \ No newline at end of file diff --git a/tests/chxml2xmltest.c b/tests/chxml2xmltest.c new file mode 100644 index 0000000000..97b485dc4a --- /dev/null +++ b/tests/chxml2xmltest.c @@ -0,0 +1,77 @@ +#include + +#include + +#include "ch/ch_conf.h" + +struct testInfo { + const char *name; + virCHDriver *driver; + testCompareDomXML2XMLResult expectResult; +}; + +typedef enum { + FLAG_IS_DIFFERENT =3D 1 << 0, + FLAG_EXPECT_FAILURE =3D 1 << 1, +} virBhyveXMLToXMLTestFlags; + +static int +testCompareXMLToXMLHelper(const void *data) +{ + const struct testInfo *info =3D data; + g_autofree char *xml_in =3D NULL; + g_autofree char *xml_out =3D NULL; + + xml_in =3D g_strdup_printf("%s/chxml2xmlin/%s.xml", + abs_srcdir, info->name); + xml_out =3D g_strdup_printf("%s/chxml2xmlout/%s.xml", + abs_srcdir, info->name); + + return testCompareDomXML2XMLFiles(NULL, info->driver->xmlopt, + xml_in, xml_out, false, 0, + info->expectResult); +} + +static int +mymain(void) +{ + int ret =3D 0; + virCHDriver *driver =3D NULL; + + driver =3D g_new0(virCHDriver, 1); + + if (!(driver->caps =3D virCHDriverCapsInit())) { + fprintf(stderr, "unable to initialize driver capabilities\n"); + goto cleanup; + } + + if (!(driver->xmlopt =3D chDomainXMLConfInit(driver))) { + fprintf(stderr, "unable to initialize driver XMLOPT\n"); + goto cleanup; + } + +#define DO_TEST_FULL(name, expectResult) \ + do { \ + const struct testInfo info =3D {name, driver, expectResult}; \ + if (virTestRun("CH XML-2-XML " name, \ + testCompareXMLToXMLHelper, &info) < 0) \ + ret =3D -1; \ + } while (0) + +#define DO_TEST(name) \ + DO_TEST_FULL(name, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) + +#define DO_TEST_FAIL_PARSE(name) \ + DO_TEST_FULL(name, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE) + + DO_TEST("basic"); + + cleanup: + virObjectUnref(driver->xmlopt); + virObjectUnref(driver->caps); + g_free(driver); + + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; +} + +VIR_TEST_MAIN(mymain) diff --git a/tests/meson.build b/tests/meson.build index 3365dce307..15b049c6ac 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -347,6 +347,12 @@ if conf.has('WITH_BHYVE') ] endif =20 +if conf.has('WITH_CH') + tests +=3D [ + { 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] }, + ] +endif + if conf.has('WITH_ESX') tests +=3D [ { 'name': 'esxutilstest', 'deps': [ esx_dep ] }, --=20 2.39.1