From nobody Tue Feb 10 07:41:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1601467309; cv=none; d=zohomail.com; s=zohoarc; b=JE+2iT9I8Lc1snZdkurZ768omNlLlFDpa+shxJVFnZaPfpCQzNDyg1bzX/Z/WOA57zWyFovVK5zKqIOTdpZ7wbQUMHLmiHFtbTrMH12qN94ksi8iTVBk7dMaFJ06miL9GmCQYd+wqcl8pEDFzRYs3rYoCBDec34XACuwIhC0Juo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601467309; h=Content-Type:Content-Transfer-Encoding:Cc: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=54KRcTe5IDE10kZaqV464mdJ0reVFSWr+4hVy9lKp8Q=; b=eb1k70VJsin53dvozCuZgIMrP2zO0Ty4GyKyaqdLJev8ZR1vnVUOjiUGnAxg62lyhfHWRmQe3gNetE3zEstI+h3rxF/SkMaQCLQ+OZH20xq9mB53tc5HNqIvNb+3Kpx3vIGts4QmiR1XqUgvu5KvQYpmCKUOSBDvvMvUBNk+/ao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601467309953889.3149176655621; Wed, 30 Sep 2020 05:01:49 -0700 (PDT) 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-362-OlWpGqO2Om6KI2QDqH8-Sw-1; Wed, 30 Sep 2020 08:01:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A1CD80046B; Wed, 30 Sep 2020 12:01:39 +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 4F3681992F; Wed, 30 Sep 2020 12:01:39 +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 1807B79FF4; Wed, 30 Sep 2020 12:01:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08UBtLA7024559 for ; Wed, 30 Sep 2020 07:55:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0B95E1992F; Wed, 30 Sep 2020 11:55:21 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-147.ams2.redhat.com [10.36.112.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5227919D61; Wed, 30 Sep 2020 11:55:20 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601467308; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=54KRcTe5IDE10kZaqV464mdJ0reVFSWr+4hVy9lKp8Q=; b=RYPzMy/sydVmnxmw5Kkd/TsETCbZ/sMm1PnhqHDL1OlpwN67Kss+j6s6zH8fmEGROeOQ7e o2lU73z2h04WSA/QPfR1heisITUSyrS/+rz8NlIecFYhjlfvBuXCS8ooqdjY5mZvOUd1zj iMBzREJWPsPSYoYNidfJYfmqXHNyRPs= X-MC-Unique: OlWpGqO2Om6KI2QDqH8-Sw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v3 8/8] tests: Add tests for unknown elements and attributes in cpu defintion Date: Wed, 30 Sep 2020 13:55:05 +0200 Message-Id: <20200930115505.215061-9-twiederh@redhat.com> In-Reply-To: <20200930115505.215061-1-twiederh@redhat.com> References: <20200930115505.215061-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake --- tests/cputest.c | 25 +++++++++++++++----- tests/cputestdata/x86_64-bogus-attribute.xml | 2 ++ tests/cputestdata/x86_64-bogus-element.xml | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 tests/cputestdata/x86_64-bogus-attribute.xml create mode 100644 tests/cputestdata/x86_64-bogus-element.xml diff --git a/tests/cputest.c b/tests/cputest.c index 78a7f2437a..b612116596 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -81,7 +81,7 @@ cpuTestLoadXML(virArch arch, const char *name) if (!(doc =3D virXMLParseFileCtxt(xml, &ctxt))) goto cleanup; =20 - virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false); + virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, true); =20 cleanup: xmlXPathFreeContext(ctxt); @@ -205,12 +205,18 @@ cpuTestCompare(const void *arg) virCPUDefPtr host =3D NULL; virCPUDefPtr cpu =3D NULL; virCPUCompareResult result; + bool validate =3D !!(data->flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XM= L); =20 - if (!(host =3D cpuTestLoadXML(data->arch, data->host)) || - !(cpu =3D cpuTestLoadXML(data->arch, data->name))) + host =3D cpuTestLoadXML(data->arch, data->host); + cpu =3D cpuTestLoadXML(data->arch, data->name); + + if (host && cpu) + result =3D virCPUCompare(host->arch, host, cpu, false); + else if (validate) + result =3D VIR_CPU_COMPARE_ERROR; + else goto cleanup; =20 - result =3D virCPUCompare(host->arch, host, cpu, false); if (data->result =3D=3D VIR_CPU_COMPARE_ERROR) virResetLastError(); =20 @@ -1020,10 +1026,13 @@ mymain(void) VIR_FREE(testLabel); \ } while (0) =20 -#define DO_TEST_COMPARE(arch, host, cpu, result) \ +#define DO_TEST_COMPARE_FLAGS(arch, host, cpu, result, flags) \ DO_TEST(arch, cpuTestCompare, \ host "/" cpu " (" #result ")", \ - host, cpu, NULL, 0, result) + host, cpu, NULL, flags, result) + +#define DO_TEST_COMPARE(arch, host, cpu, result) \ + DO_TEST_COMPARE_FLAGS(arch, host, cpu, result, 0) =20 #define DO_TEST_UPDATE_ONLY(arch, host, cpu) \ DO_TEST(arch, cpuTestUpdate, \ @@ -1093,6 +1102,10 @@ mymain(void) } \ } while (0) =20 + /* invalid xml */ + DO_TEST_COMPARE_FLAGS(VIR_ARCH_X86_64, "host", "bogus-element", VIR_CP= U_COMPARE_ERROR, VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); + DO_TEST_COMPARE_FLAGS(VIR_ARCH_X86_64, "host", "bogus-attribute", VIR_= CPU_COMPARE_ERROR, VIR_CONNECT_COMPARE_CPU_VALIDATE_XML); + /* host to host comparison */ DO_TEST_COMPARE(VIR_ARCH_X86_64, "host", "host", VIR_CPU_COMPARE_IDENT= ICAL); DO_TEST_COMPARE(VIR_ARCH_X86_64, "host", "host-better", VIR_CPU_COMPAR= E_INCOMPATIBLE); diff --git a/tests/cputestdata/x86_64-bogus-attribute.xml b/tests/cputestda= ta/x86_64-bogus-attribute.xml new file mode 100644 index 0000000000..46a801f8b9 --- /dev/null +++ b/tests/cputestdata/x86_64-bogus-attribute.xml @@ -0,0 +1,2 @@ + + diff --git a/tests/cputestdata/x86_64-bogus-element.xml b/tests/cputestdata= /x86_64-bogus-element.xml new file mode 100644 index 0000000000..34bd32aca9 --- /dev/null +++ b/tests/cputestdata/x86_64-bogus-element.xml @@ -0,0 +1,3 @@ + + + --=20 2.26.2