From nobody Mon Feb 9 14:14:30 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=1600693700; cv=none; d=zohomail.com; s=zohoarc; b=BHoxQ7BCL2Rq5ZvVpUC7yBXTyWSsieP9jpdD8hQBoFzRR3lwEdkN9tZyO2ojXqhQu0n8t+Ufc+XxmhR0Rb8tZ3Rf2BCAhwf/CtCqipKU1XHTcYq3jmGFxD6QIPjdKxpCG6k55X8ifAb+Vx87LvuK56ni1RXZ01D+q4shwbmPaKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600693700; 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=Yr27yPs16P8P/082UR3zx7xgURQnlRbIMZ0nHJ77v/s=; b=FqrwFFe/WSiqrAEclWAG2CS2sKOKQacOKEnKSC5rCHLFOOjb5kALxaWGGsA5UNdQ2ROlToc3Dk66i8vFVvSg41YN0rvdWo6TCnPl8nHZB+2u5cm0+qhC9PACr6u7VOLJ7NauOr8ywiYoUtWxIaCIt68mcYS3azrZv+aoFI6bvqs= 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 1600693700327981.2919974322382; Mon, 21 Sep 2020 06:08:20 -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-468-vS9iK171PxySRq_ab1yqGA-1; Mon, 21 Sep 2020 09:08:16 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42B171891E93; Mon, 21 Sep 2020 13:08:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21282610AF; Mon, 21 Sep 2020 13:08:10 +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 DB4C418561B4; Mon, 21 Sep 2020 13:08:09 +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 08LD7mEn020144 for ; Mon, 21 Sep 2020 09:07:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3810627BC3; Mon, 21 Sep 2020 13:07:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-154.ams2.redhat.com [10.36.112.154]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E4571A913; Mon, 21 Sep 2020 13:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600693699; 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=Yr27yPs16P8P/082UR3zx7xgURQnlRbIMZ0nHJ77v/s=; b=iWjubOHkH4OJ4ACle8TyKBb9puzB/J7qrMSj2XsMAA4gKkScgLenknvsCF0bG0EhCR9LrT 1cubueng1/Qfezu6OthJ2Wiv0nK14/hR10jBWP3X3YEjBuVBbOVlJAuSMOS7FSfg4YqeDH l2DQzEI7YUpyHdtgYxjjGRUcJfDT6Cc= X-MC-Unique: vS9iK171PxySRq_ab1yqGA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 8/9] tests: cpu: Allow passing flags to cpuTestLoadXML Date: Mon, 21 Sep 2020 15:07:31 +0200 Message-Id: <20200921130732.305622-9-twiederh@redhat.com> In-Reply-To: <20200921130732.305622-1-twiederh@redhat.com> References: <20200921130732.305622-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.79 on 10.5.11.12 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 | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index b40fd7f7f2..30a125c3da 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -68,7 +68,7 @@ static virQEMUDriver driver; =20 =20 static virCPUDefPtr -cpuTestLoadXML(virArch arch, const char *name) +cpuTestLoadXML(virArch arch, const char *name, bool validate) { char *xml =3D NULL; xmlDocPtr doc =3D NULL; @@ -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, validate); =20 cleanup: xmlXPathFreeContext(ctxt); @@ -203,12 +203,20 @@ 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))) - goto cleanup; + host =3D cpuTestLoadXML(data->arch, data->host, validate); + cpu =3D cpuTestLoadXML(data->arch, data->name, validate); + + if (!host || !cpu) { + if (validate) + result =3D VIR_CPU_COMPARE_ERROR; + else + goto cleanup; + } else { + result =3D virCPUCompare(host->arch, host, cpu, false); + } =20 - result =3D virCPUCompare(host->arch, host, cpu, false); if (data->result =3D=3D VIR_CPU_COMPARE_ERROR) virResetLastError(); =20 @@ -240,9 +248,10 @@ cpuTestGuestCPU(const void *arg) virCPUCompareResult cmpResult; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *result =3D NULL; + 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))) + if (!(host =3D cpuTestLoadXML(data->arch, data->host, validate)) || + !(cpu =3D cpuTestLoadXML(data->arch, data->name, validate))) goto cleanup; =20 if (virCPUConvertLegacy(host->arch, cpu) < 0) @@ -381,9 +390,10 @@ cpuTestUpdate(const void *arg) virCPUDefPtr migHost =3D NULL; virCPUDefPtr cpu =3D NULL; char *result =3D NULL; + 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))) + if (!(host =3D cpuTestLoadXML(data->arch, data->host, validate)) || + !(cpu =3D cpuTestLoadXML(data->arch, data->name, validate))) goto cleanup; =20 if (!(migHost =3D virCPUCopyMigratable(data->arch, host))) @@ -413,8 +423,9 @@ cpuTestHasFeature(const void *arg) virCPUDefPtr host =3D NULL; virCPUDataPtr hostData =3D NULL; int result; + bool validate =3D !!(data->flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XM= L); =20 - if (!(host =3D cpuTestLoadXML(data->arch, data->host))) + if (!(host =3D cpuTestLoadXML(data->arch, data->host, validate))) goto cleanup; =20 if (cpuEncode(host->arch, host, NULL, &hostData, @@ -794,9 +805,10 @@ cpuTestUpdateLive(const void *arg) virDomainCapsCPUModelsPtr hvModels =3D NULL; virDomainCapsCPUModelsPtr models =3D NULL; int ret =3D -1; + bool validate =3D !!(data->flags & VIR_CONNECT_COMPARE_CPU_VALIDATE_XM= L); =20 cpuFile =3D g_strdup_printf("cpuid-%s-guest", data->host); - if (!(cpu =3D cpuTestLoadXML(data->arch, cpuFile))) + if (!(cpu =3D cpuTestLoadXML(data->arch, cpuFile, validate))) goto cleanup; =20 enabledFile =3D g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xm= l", @@ -812,7 +824,7 @@ cpuTestUpdateLive(const void *arg) goto cleanup; =20 expectedFile =3D g_strdup_printf("cpuid-%s-json", data->host); - if (!(expected =3D cpuTestLoadXML(data->arch, expectedFile))) + if (!(expected =3D cpuTestLoadXML(data->arch, expectedFile, validate))) goto cleanup; =20 /* In case the host CPU signature does not exactly match any CPU model= from @@ -1018,10 +1030,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, \ --=20 2.26.2