From nobody Thu May 2 12:28:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150955907604361.80999956653784; Wed, 1 Nov 2017 10:57:56 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 492B4C01FA91; Wed, 1 Nov 2017 17:57:54 +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 4EF1946E64; Wed, 1 Nov 2017 17:57:53 +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 AA7071800BC8; Wed, 1 Nov 2017 17:57:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vA1Hvm61001971 for ; Wed, 1 Nov 2017 13:57:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 260075D757; Wed, 1 Nov 2017 17:57:48 +0000 (UTC) Received: from mamuti.net (ovpn-204-82.brq.redhat.com [10.40.204.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEEF35D758 for ; Wed, 1 Nov 2017 17:57:45 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 0ACD81008F5; Wed, 1 Nov 2017 18:57:44 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 492B4C01FA91 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 1 Nov 2017 18:57:42 +0100 Message-Id: <54e1e8819466e22f75e953bf7dc010afc9056a2d.1509559062.git.jdenemar@redhat.com> Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] cputest: Skip tests requiring JSON_MODELS if QEMU is disabled 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 01 Nov 2017 17:57:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some tests require JSON_MODELS to be parsed into qemuCaps and applied when computing CPU models and such test cannot succeed if QEMU driver is disabled. Let's mark the tests with JSON_MODELS_REQUIRED and skip the appropriate parts if building without QEMU. On the other hand, CPU tests with JSON_MODELS should succeed even if model definitions from QEMU are not parsed and applied. Let's explicitly test this by repeating the tests without JSON_MODELS set. This fixes the build with QEMU driver disabled, e.g., on some architectures on RHEL/CentOS. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- tests/cputest.c | 70 ++++++++++++++++++++++++++++++++++++++++-------------= ---- 1 file changed, 49 insertions(+), 21 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 5d1fe7d99..8e94c2152 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -464,6 +464,7 @@ typedef enum { JSON_NONE, JSON_HOST, JSON_MODELS, + JSON_MODELS_REQUIRED, } cpuTestCPUIDJson; =20 #if WITH_QEMU && WITH_YAJL @@ -491,7 +492,8 @@ cpuTestMakeQEMUCaps(const struct data *data) goto error; =20 virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM); - if (data->flags =3D=3D JSON_MODELS) + if (data->flags =3D=3D JSON_MODELS || + data->flags =3D=3D JSON_MODELS_REQUIRED) virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS); =20 virQEMUCapsSetArch(qemuCaps, data->arch); @@ -517,32 +519,41 @@ cpuTestMakeQEMUCaps(const struct data *data) } =20 =20 -static virDomainCapsCPUModelsPtr -cpuTestGetCPUModels(const struct data *data) +static int +cpuTestGetCPUModels(const struct data *data, + virDomainCapsCPUModelsPtr *models) { - virDomainCapsCPUModelsPtr models =3D NULL; virQEMUCapsPtr qemuCaps; =20 - if (data->flags !=3D JSON_MODELS) - return NULL; + *models =3D NULL; + + if (data->flags !=3D JSON_MODELS && + data->flags !=3D JSON_MODELS_REQUIRED) + return 0; =20 if (!(qemuCaps =3D cpuTestMakeQEMUCaps(data))) - return NULL; + return -1; =20 - models =3D virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM); - virObjectRef(models); + *models =3D virQEMUCapsGetCPUDefinitions(qemuCaps, VIR_DOMAIN_VIRT_KVM= ); + virObjectRef(*models); =20 virObjectUnref(qemuCaps); =20 - return models; + return 0; } =20 #else /* if WITH_QEMU && WITH_YAJL */ =20 -static virDomainCapsCPUModelsPtr -cpuTestGetCPUModels(const struct data *data ATTRIBUTE_UNUSED) +static int +cpuTestGetCPUModels(const struct data *data, + virDomainCapsCPUModelsPtr *models) { - return NULL; + *models =3D NULL; + + if (data->flags =3D=3D JSON_MODELS_REQUIRED) + return EXIT_AM_SKIP; + + return 0; } =20 #endif @@ -580,8 +591,15 @@ cpuTestCPUID(bool guest, const void *arg) cpu->type =3D VIR_CPU_TYPE_HOST; } =20 - if (guest) - models =3D cpuTestGetCPUModels(data); + if (guest) { + int rc; + + rc =3D cpuTestGetCPUModels(data, &models); + if (rc !=3D 0) { + ret =3D rc; + goto cleanup; + } + } =20 if (cpuDecode(cpu, hostData, models) < 0) goto cleanup; @@ -755,11 +773,17 @@ cpuTestUpdateLive(const void *arg) virDomainCapsCPUModelPtr hvModel; char **blockers =3D NULL; virDomainCapsCPUUsable usable =3D VIR_DOMCAPS_CPU_USABLE_UNKNOWN; + int rc; =20 if (!(models =3D virDomainCapsCPUModelsNew(0))) goto cleanup; =20 - hvModels =3D cpuTestGetCPUModels(data); + rc =3D cpuTestGetCPUModels(data, &hvModels); + if (rc !=3D 0) { + ret =3D rc; + goto cleanup; + } + hvModel =3D virDomainCapsCPUModelsGet(hvModels, expected->model); =20 if (hvModel) { @@ -969,15 +993,19 @@ mymain(void) host, cpu, models, 0, result) =20 #if WITH_QEMU && WITH_YAJL -# define DO_TEST_CPUID_JSON(arch, host, json) \ +# define DO_TEST_JSON(arch, host, json) \ do { \ + if (json =3D=3D JSON_MODELS) { = \ + DO_TEST(arch, cpuTestGuestCPUID, host, host, \ + NULL, NULL, 0, 0); \ + } \ if (json !=3D JSON_NONE) { \ DO_TEST(arch, cpuTestJSONCPUID, host, host, \ NULL, NULL, json, 0); \ } \ } while (0) #else -# define DO_TEST_CPUID_JSON(arch, host, json) +# define DO_TEST_JSON(arch, host, json) #endif =20 #define DO_TEST_CPUID(arch, host, json) \ @@ -986,7 +1014,7 @@ mymain(void) NULL, NULL, 0, 0); \ DO_TEST(arch, cpuTestGuestCPUID, host, host, \ NULL, NULL, json, 0); \ - DO_TEST_CPUID_JSON(arch, host, json); \ + DO_TEST_JSON(arch, host, json); \ if (json !=3D JSON_NONE) { \ DO_TEST(arch, cpuTestUpdateLive, host, host, \ NULL, NULL, json, 0); \ @@ -1126,7 +1154,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i5-4670T", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i5-6600", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-2600", JSON_HOST); - DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-2600-xsaveopt", JSON_MODELS); + DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-2600-xsaveopt", JSON_MODELS_RE= QUIRED); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-3520M", JSON_NONE); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-3740QM", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Core-i7-3770", JSON_HOST); @@ -1150,7 +1178,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2630", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E5-2650", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7-4820", JSON_HOST); - DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7-4830", JSON_MODELS); + DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7-4830", JSON_MODELS_REQUIRED); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7-8890", JSON_MODELS); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Gold-6148", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-W3520", JSON_HOST); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list