From nobody Wed Feb 11 10:04:51 2026 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.zoho.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 1490382347119956.5493950731452; Fri, 24 Mar 2017 12:05:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F48269182; Fri, 24 Mar 2017 19:05:46 +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 1EFEB8440A; Fri, 24 Mar 2017 19:05:46 +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 B746418523D6; Fri, 24 Mar 2017 19:05:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2OJ0kZk019558 for ; Fri, 24 Mar 2017 15:00:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 927E919630; Fri, 24 Mar 2017 19:00:46 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 164B47D569 for ; Fri, 24 Mar 2017 19:00:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4F48269182 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4F48269182 From: Martin Kletzander To: libvir-list@redhat.com Date: Fri, 24 Mar 2017 20:00:11 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/23] tests: Enhance vircaps2xml test 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 24 Mar 2017 19:05:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Instead of generating all of the capabilities, let's test more of our code by probing sysfs data. This test needs quite some mocking for now, but it paves the road for more future enhancements (hugepages probing, for example). Signed-off-by: Martin Kletzander --- tests/vircaps2xmldata/vircaps-aarch64-basic.xml | 64 ++++++++++++ tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml | 74 ------------- tests/vircaps2xmldata/vircaps-x86_64-basic.xml | 62 +++++++++++ tests/vircaps2xmldata/vircaps-x86_64-caches.xml | 33 ++++++ tests/vircaps2xmltest.c | 133 +++++++++-----------= ---- 5 files changed, 209 insertions(+), 157 deletions(-) create mode 100644 tests/vircaps2xmldata/vircaps-aarch64-basic.xml delete mode 100644 tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-basic.xml create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-caches.xml diff --git a/tests/vircaps2xmldata/vircaps-aarch64-basic.xml b/tests/vircap= s2xmldata/vircaps-aarch64-basic.xml new file mode 100644 index 000000000000..ce156a364e1c --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-aarch64-basic.xml @@ -0,0 +1,64 @@ + + + + + aarch64 + + + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + 2097152 + 4096 + 6144 + 8192 + + + + + + + + + 3145728 + 6144 + 8192 + 10240 + + + + + + + + + 4194304 + 8192 + 10240 + 12288 + + + + + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml b/tests/vircaps= 2xmldata/vircaps-basic-4-4-2G.xml deleted file mode 100644 index 8694f87d1f94..000000000000 --- a/tests/vircaps2xmldata/vircaps-basic-4-4-2G.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - x86_64 - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - 2097152 - - - - - - - - - - - - - - - - - - diff --git a/tests/vircaps2xmldata/vircaps-x86_64-basic.xml b/tests/vircaps= 2xmldata/vircaps-x86_64-basic.xml new file mode 100644 index 000000000000..1f2c6659a5cb --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-x86_64-basic.xml @@ -0,0 +1,62 @@ + + + + + x86_64 + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + 2097152 + 4096 + 6144 + 8192 + + + + + + + + + 3145728 + 6144 + 8192 + 10240 + + + + + + + + + 4194304 + 8192 + 10240 + 12288 + + + + + + + + + + + + diff --git a/tests/vircaps2xmldata/vircaps-x86_64-caches.xml b/tests/vircap= s2xmldata/vircaps-x86_64-caches.xml new file mode 100644 index 000000000000..88f2ec62277e --- /dev/null +++ b/tests/vircaps2xmldata/vircaps-x86_64-caches.xml @@ -0,0 +1,33 @@ + + + + + x86_64 + + + + + + + + + 1048576 + 2048 + 4096 + 6144 + + + + + + + + + + + + + + + + diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c index 3e9e06bc0967..4dccd452cc82 100644 --- a/tests/vircaps2xmltest.c +++ b/tests/vircaps2xmltest.c @@ -25,99 +25,51 @@ #include "testutils.h" #include "capabilities.h" #include "virbitmap.h" +#include "virsysfspriv.h" #define VIR_FROM_THIS VIR_FROM_NONE -static virCapsPtr -buildVirCapabilities(int max_cells, - int max_cpus_in_cell, - int max_mem_in_cell) -{ - virCapsPtr caps; - virCapsHostNUMACellCPUPtr cell_cpus =3D NULL; - virCapsHostNUMACellSiblingInfoPtr siblings =3D NULL; - int core_id, cell_id, nsiblings; - int id; - size_t i; - - if ((caps =3D virCapabilitiesNew(VIR_ARCH_X86_64, false, false)) =3D= =3D NULL) - goto error; - - id =3D 0; - for (cell_id =3D 0; cell_id < max_cells; cell_id++) { - if (VIR_ALLOC_N(cell_cpus, max_cpus_in_cell) < 0) - goto error; - - for (core_id =3D 0; core_id < max_cpus_in_cell; core_id++) { - cell_cpus[core_id].id =3D id; - cell_cpus[core_id].socket_id =3D cell_id; - cell_cpus[core_id].core_id =3D id + core_id; - if (!(cell_cpus[core_id].siblings =3D - virBitmapNew(max_cpus_in_cell))) - goto error; - ignore_value(virBitmapSetBit(cell_cpus[core_id].siblings, id)); - } - id++; - - if (VIR_ALLOC_N(siblings, max_cells) < 0) - goto error; - nsiblings =3D max_cells; - - for (i =3D 0; i < nsiblings; i++) { - siblings[i].node =3D i; - /* Some magical constants, see virNumaGetDistances() - * for their description. */ - siblings[i].distance =3D cell_id =3D=3D i ? 10 : 20; - } - - if (virCapabilitiesAddHostNUMACell(caps, cell_id, - max_mem_in_cell, - max_cpus_in_cell, cell_cpus, - nsiblings, siblings, - 0, NULL) < 0) - goto error; - - cell_cpus =3D NULL; - siblings =3D NULL; - } - - return caps; - - error: - virCapabilitiesClearHostNUMACellCPUTopology(cell_cpus, max_cpus_in_cel= l); - VIR_FREE(cell_cpus); - VIR_FREE(siblings); - virObjectUnref(caps); - return NULL; -} +#ifdef __linux__ - -struct virCapabilitiesFormatData { +struct virCapabilitiesData { const char *filename; - int max_cells; - int max_cpus_in_cell; - int max_mem_in_cell; + virArch arch; + bool offlineMigrate; + bool liveMigrate; }; static int -test_virCapabilitiesFormat(const void *opaque) +test_virCapabilities(const void *opaque) { - struct virCapabilitiesFormatData *data =3D (struct virCapabilitiesForm= atData *) opaque; + struct virCapabilitiesData *data =3D (struct virCapabilitiesData *) op= aque; + const char *archStr =3D virArchToString(data->arch); virCapsPtr caps =3D NULL; char *capsXML =3D NULL; char *path =3D NULL; + char *dir =3D NULL; int ret =3D -1; - if (!(caps =3D buildVirCapabilities(data->max_cells, data->max_cpus_in= _cell, - data->max_mem_in_cell))) + if (virAsprintf(&dir, "%s/vircaps2xmldata/linux-%s", + abs_srcdir, data->filename) < 0) + goto cleanup; + + virSysfsSetSystemPath(dir); + caps =3D virCapabilitiesNew(data->arch, data->offlineMigrate, data->li= veMigrate); + + if (!caps) + goto cleanup; + + if (virCapabilitiesInitNUMA(caps) < 0) goto cleanup; + virSysfsSetSystemPath(NULL); + if (!(capsXML =3D virCapabilitiesFormatXML(caps))) goto cleanup; - if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml", - abs_srcdir, data->filename) < 0) + if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml", + abs_srcdir, archStr, data->filename) < 0) goto cleanup; if (virTestCompareToFile(capsXML, path) < 0) @@ -126,6 +78,7 @@ test_virCapabilitiesFormat(const void *opaque) ret =3D 0; cleanup: + VIR_FREE(dir); VIR_FREE(path); VIR_FREE(capsXML); virObjectUnref(caps); @@ -137,19 +90,33 @@ mymain(void) { int ret =3D 0; -#define DO_TEST(filename, max_cells, = \ - max_cpus_in_cell, max_mem_in_cell) = \ - do { = \ - struct virCapabilitiesFormatData data =3D {filename, max_cells, = \ - max_cpus_in_cell, = \ - max_mem_in_cell}; = \ - if (virTestRun(filename, test_virCapabilitiesFormat, &data) < 0) = \ - ret =3D -1; = \ +# define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \ + do { \ + struct virCapabilitiesData data =3D {filename, arch, \ + offlineMigrate, \ + liveMigrate}; \ + if (virTestRun(filename, test_virCapabilities, &data) < 0) \ + ret =3D -1; \ } while (0) - DO_TEST("basic-4-4-2G", 4, 4, 2*1024*1024); +# define DO_TEST(filename, arch) DO_TEST_FULL(filename, arch, true, true) + + DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false); + DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false); + + DO_TEST("caches", VIR_ARCH_X86_64); return ret; } -VIRT_TEST_MAIN(mymain) +VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virnumamock.so") + +#else /* !__linux__ */ + +int +main(void) +{ + return EXIT_AM_SKIP; +} + +#endif /* !__linux__ */ --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list