From nobody Wed Nov 5 12:45:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1534419627289656.0250483095625; Thu, 16 Aug 2018 04:40:27 -0700 (PDT) Received: from localhost ([::1]:54933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqGde-0005H8-2U for importer@patchew.org; Thu, 16 Aug 2018 07:40:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqGZk-0001KU-Cp for qemu-devel@nongnu.org; Thu, 16 Aug 2018 07:36:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqGZa-0003Q5-QL for qemu-devel@nongnu.org; Thu, 16 Aug 2018 07:36:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59536 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqGZZ-0003PC-B4 for qemu-devel@nongnu.org; Thu, 16 Aug 2018 07:36:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B3587788C; Thu, 16 Aug 2018 11:36:13 +0000 (UTC) Received: from thuth.com (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D7BD2156716; Thu, 16 Aug 2018 11:36:11 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2018 13:35:55 +0200 Message-Id: <1534419358-10932-6-git-send-email-thuth@redhat.com> In-Reply-To: <1534419358-10932-1-git-send-email-thuth@redhat.com> References: <1534419358-10932-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 16 Aug 2018 11:36:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 16 Aug 2018 11:36:13 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 5/8] tests: Skip old versioned machine types in quick testing mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , "Michael S. Tsirkin" , Juan Quintela , Markus Armbruster , "Dr. David Alan Gilbert" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The tests that check something for all machine types currently spend a lot of time checking old machine types (like "pc-i440fx-2.0" for example). The chances that we find something new there in addition to checking the latest version of a machine type are pretty low, so we should not waste the time of the developers by testing this again and again in the "quick" testing mode. Thus let's add some code to determine whether we are testing a current machine type or an old one, and only test the old types if we are running in "SPEED=3Dslow" mode. This decreases the testing time quite a bit now, e.g. the qom-test now finishes within 4 seconds for qemu-system-x86_64 instead of 30 seconds when testing all machines. Signed-off-by: Thomas Huth Reviewed-by: Juan Quintela --- tests/cpu-plug-test.c | 6 +++--- tests/libqtest.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++= ++-- tests/libqtest.h | 4 +++- tests/qom-test.c | 2 +- tests/test-hmp.c | 2 +- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index f5d57da..3e93c8e 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -257,11 +257,11 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { - qtest_cb_for_every_machine(add_pc_test_case); + qtest_cb_for_every_machine(add_pc_test_case, g_test_quick()); } else if (g_str_equal(arch, "ppc64")) { - qtest_cb_for_every_machine(add_pseries_test_case); + qtest_cb_for_every_machine(add_pseries_test_case, g_test_quick()); } else if (g_str_equal(arch, "s390x")) { - qtest_cb_for_every_machine(add_s390x_test_case); + qtest_cb_for_every_machine(add_s390x_test_case, g_test_quick()); } =20 return g_test_run(); diff --git a/tests/libqtest.c b/tests/libqtest.c index 852ccff..1eefad4 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -991,7 +991,53 @@ bool qtest_big_endian(QTestState *s) return s->big_endian; } =20 -void qtest_cb_for_every_machine(void (*cb)(const char *machine)) +static bool qtest_check_machine_version(const char *mname, const char *bas= ename, + int major, int minor) +{ + char *newname; + bool is_equal; + + newname =3D g_strdup_printf("%s-%i.%i", basename, major, minor); + is_equal =3D g_str_equal(mname, newname); + g_free(newname); + + return is_equal; +} + +static bool qtest_is_old_versioned_machine(const char *mname) +{ + const char *dash =3D strrchr(mname, '-'); + const char *dot =3D strrchr(mname, '.'); + const char *chr; + char *bname; + const int major =3D QEMU_VERSION_MAJOR; + const int minor =3D QEMU_VERSION_MINOR; + bool res =3D false; + + if (dash && dot && dot > dash) { + for (chr =3D dash + 1; *chr; chr++) { + if (!isdigit(*chr) && *chr !=3D '.') { + return false; + } + } + /* + * Now check if it is one of the latest versions. Check major + 1 + * and minor + 1 versions as well, since they might already exist + * in the development branch. + */ + bname =3D g_strdup(mname); + bname[dash - mname] =3D 0; + res =3D !qtest_check_machine_version(mname, bname, major + 1, 0) && + !qtest_check_machine_version(mname, bname, major, minor + 1)= && + !qtest_check_machine_version(mname, bname, major, minor); + g_free(bname); + } + + return res; +} + +void qtest_cb_for_every_machine(void (*cb)(const char *machine), + bool skip_old_versioned) { QDict *response, *minfo; QList *list; @@ -1014,7 +1060,9 @@ void qtest_cb_for_every_machine(void (*cb)(const char= *machine)) qstr =3D qobject_to(QString, qobj); g_assert(qstr); mname =3D qstring_get_str(qstr); - cb(mname); + if (!skip_old_versioned || !qtest_is_old_versioned_machine(mname))= { + cb(mname); + } } =20 qtest_end(); diff --git a/tests/libqtest.h b/tests/libqtest.h index def1eda..1159b73 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -954,10 +954,12 @@ QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_A= TTR(2, 3); /** * qtest_cb_for_every_machine: * @cb: Pointer to the callback function + * @skip_old_versioned: true if versioned old machine types should be skip= ped * * Call a callback function for every name of all available machines. */ -void qtest_cb_for_every_machine(void (*cb)(const char *machine)); +void qtest_cb_for_every_machine(void (*cb)(const char *machine), + bool skip_old_versioned); =20 /** * qtest_qmp_device_add: diff --git a/tests/qom-test.c b/tests/qom-test.c index e6f712c..73c52af 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); =20 - qtest_cb_for_every_machine(add_machine_test_case); + qtest_cb_for_every_machine(add_machine_test_case, g_test_quick()); =20 return g_test_run(); } diff --git a/tests/test-hmp.c b/tests/test-hmp.c index 5352c9c..1a3a9c5 100644 --- a/tests/test-hmp.c +++ b/tests/test-hmp.c @@ -158,7 +158,7 @@ int main(int argc, char **argv) =20 g_test_init(&argc, &argv, NULL); =20 - qtest_cb_for_every_machine(add_machine_test_case); + qtest_cb_for_every_machine(add_machine_test_case, g_test_quick()); =20 /* as none machine has no memory by default, add a test case with memo= ry */ qtest_add_data_func("hmp/none+2MB", g_strdup("none -m 2"), test_machin= e); --=20 1.8.3.1