From nobody Tue Feb 10 01:16:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1488814062555113.5132171156489; Mon, 6 Mar 2017 07:27:42 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v26FOVpQ011794; Mon, 6 Mar 2017 10:24:31 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v26FOT9I009620 for ; Mon, 6 Mar 2017 10:24:29 -0500 Received: from andariel.redhat.com (ovpn-204-73.brq.redhat.com [10.40.204.73]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v26FONSg030039; Mon, 6 Mar 2017 10:24:28 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 6 Mar 2017 16:24:38 +0100 Message-Id: <8658794a26cd50ce30731e4657bf29b40e8bb1e7.1488813740.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/4] tests: sysinfo: Run all sysinfo tests all the time 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There's no reason why we should avoid running all sysinfo tests on all platforms. Refactor the test to get rid of the conditionally compiled cruft. --- tests/sysinfotest.c | 106 ++++++++++++------------------------------------= ---- 1 file changed, 23 insertions(+), 83 deletions(-) diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index f81a0466c..3dd569b73 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -42,14 +42,8 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#if defined (__linux__) - -# if defined(__s390__) || defined(__s390x__) || \ - defined(__powerpc__) || defined(__powerpc64__) || \ - defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \ - defined(__arm__) || defined(__aarch64__) - struct testSysinfoData { + virSysinfoDefPtr (*func)(void); /* sysinfo gathering function */ char *decoder; /* name of dmi decoder binary/script */ char *sysinfo; /* name of /proc/sysinfo substitute file */ char *cpuinfo; /* name of /proc/cpuinfo substitute file */ @@ -68,7 +62,7 @@ testSysinfo(const void *data) virSysinfoSetup(testdata->decoder, testdata->sysinfo, testdata->cpuinf= o); if (!testdata->expected || - !(ret =3D virSysinfoRead())) + !(ret =3D testdata->func())) goto cleanup; if (virSysinfoFormat(&buf, ret) < 0) @@ -91,6 +85,7 @@ testSysinfo(const void *data) static int sysinfotest_run(const char *test, + virSysinfoDefPtr (*func)(void), const char *decoder, const char *sysinfo, const char *cpuinfo, @@ -99,6 +94,8 @@ sysinfotest_run(const char *test, struct testSysinfoData testdata =3D { NULL }; int ret =3D EXIT_FAILURE; + testdata.func =3D func; + if ((decoder && virAsprintf(&testdata.decoder, "%s/%s", abs_srcdir, decoder) < 0)= || (sysinfo && @@ -122,91 +119,34 @@ sysinfotest_run(const char *test, VIR_FREE(testdata.expected); return ret; } -# endif -# if defined(__s390__) || defined(__s390x__) -static int -test_s390(void) -{ - return sysinfotest_run("s390 sysinfo", - NULL, - "/sysinfodata/s390sysinfo.data", - "/sysinfodata/s390cpuinfo.data", - "/sysinfodata/s390sysinfo.expect"); -} +#define TEST_FULL(name, func, decoder) \ + if (sysinfotest_run(name " sysinfo", func, decoder, \ + "/sysinfodata/" name "sysinfo.data", \ + "/sysinfodata/" name "cpuinfo.data", \ + "/sysinfodata/" name "sysinfo.expect") !=3D EXIT_S= UCCESS) \ + ret =3D EXIT_FAILURE -VIRT_TEST_MAIN(test_s390) -# elif defined(__powerpc__) || defined(__powerpc64__) -static int -test_ppc(void) -{ - return sysinfotest_run("ppc sysinfo", - NULL, - NULL, - "/sysinfodata/ppccpuinfo.data", - "/sysinfodata/ppcsysinfo.expect"); -} -VIRT_TEST_MAIN(test_ppc) -# elif defined(__i386__) || defined(__x86_64__) || defined(__amd64__) -static int -test_x86(void) -{ - return sysinfotest_run("x86 sysinfo", - "/sysinfodata/dmidecode.sh", - NULL, - NULL, - "/sysinfodata/x86sysinfo.expect"); -} +#define TEST(name, func) \ + TEST_FULL(name, func, NULL) -VIRT_TEST_MAIN(test_x86) -# elif defined(__arm__) static int -test_arm(void) +mymain(void) { int ret =3D EXIT_SUCCESS; - if (sysinfotest_run("arm sysinfo", - NULL, - NULL, - "/sysinfodata/armcpuinfo.data", - "/sysinfodata/armsysinfo.expect") !=3D EXIT_SUCCES= S) - ret =3D EXIT_FAILURE; - - if (sysinfotest_run("Raspberry Pi 2 sysinfo", - NULL, - NULL, - "/sysinfodata/arm-rpi2cpuinfo.data", - "/sysinfodata/arm-rpi2sysinfo.expect") !=3D EXIT_S= UCCESS) - ret =3D EXIT_FAILURE; + TEST("s390", virSysinfoReadS390); + TEST("ppc", virSysinfoReadPPC); + TEST_FULL("x86", virSysinfoReadX86, "/sysinfodata/dmidecode.sh"); + TEST("arm", virSysinfoReadARM); + TEST("arm-rpi2", virSysinfoReadARM); + TEST("aarch64", virSysinfoReadARM); return ret; } -VIRT_TEST_MAIN(test_arm) -# elif defined(__aarch64__) -static int -test_aarch64(void) -{ - return sysinfotest_run("aarch64 sysinfo", - NULL, - NULL, - "/sysinfodata/aarch64cpuinfo.data", - "/sysinfodata/aarch64sysinfo.expect"); -} +#undef TEST +#undef TEST_FULL -VIRT_TEST_MAIN(test_aarch64) -# else -int -main(void) -{ - return EXIT_AM_SKIP; -} -# endif /* defined(__s390__) ... */ -#else -int -main(void) -{ - return EXIT_AM_SKIP; -} -#endif /* defined(__linux__) */ +VIRT_TEST_MAIN(mymain) --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list