From nobody Mon Feb 9 22:24:02 2026 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; dkim=fail; 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 1535045013089828.9825725048887; Thu, 23 Aug 2018 10:23:33 -0700 (PDT) Received: from localhost ([::1]:37926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fstKT-0003f8-J5 for importer@patchew.org; Thu, 23 Aug 2018 13:23:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fssmE-0002iA-7A for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:48:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fssmA-0007I0-8j for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:48:06 -0400 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:37796) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fssm9-0007HM-VG for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:48:02 -0400 Received: by mail-wm0-x233.google.com with SMTP id n11-v6so6494819wmc.2 for ; Thu, 23 Aug 2018 09:48:01 -0700 (PDT) Received: from donizetti.redhat.com (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id s205-v6sm6183362wmf.42.2018.08.23.09.47.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Aug 2018 09:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=W1A/ywIA+SQWcvPNeFrjLOokiKwdfu+huuOs582W9uQ=; b=AnIQZUXtplC+0o5qEsTHbcbTKcirquGpfcHeoLOaJEymqRMIKcS0/fYGQl+9g62KAN dPECBcmwl64rembI1ldS9JNQ1xS6hTd973bY42TVvdl+EInuze9aKa6VMCO2Y6IqShJL xFY31m5/rReuG5e8tDo3UDvpU6q24byItCC5ToZfW1C4OL3+yNf6CPIKt/f/0R5ScimH Wsp84mum/bjYuDWu5fijKWHSS0wkvt7VjP1OYrl08oz4wFyAjNzwZX079+3vhn9gInwV xvzDBUPG1YYga/7n6jyNer/a+WsDUB3EpkerPbZKzgbxZcOv33zFX3/oXAd5U96MDjeW 8Jog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=W1A/ywIA+SQWcvPNeFrjLOokiKwdfu+huuOs582W9uQ=; b=TzZd7cbWqj7FiRfMzjRlXmouMCOOQWg/C/ZpcRhLn37YU0eVvswW3ncs/Q8UoazBGt icmYTjAQuNiIkkHruh1t3DjrQQ71xdgetN3wITlTUIaJv2W3G6RNuANht9tt+Kbi/sJ3 2u3EXPiXTFVtGX1LUkoQKekoWW6YfmhJht5OvX32Lx0dkUX/UQBqJKB1PQk7Ht9hLLq8 9DC1MAos0cRQ7uVEYkzjdB4sjmxK7LTCfkFMxr4jEwwUrMXxh+gYm7rAdKyZJys2zFeU 7GApBrMwJMTpGNxClXibYwvES43TSf+a4XmVVauXtjHHdhs2jxN+YA68YPq+PpVkuAF9 7bFA== X-Gm-Message-State: APzg51AH3/ifu15m8bEpmfqmcirkbFplfhHzJTuvle4mr41Bv6WkDSt0 03u0Emfj/ALMvh+tpZcRh23RfFd7 X-Google-Smtp-Source: ANB0VdaqEooG4vh0OFUkSYxdJXlpO5XwCgRWWsmbZWWnF3hZgJJXBp52lt4jkpJVjUDlyM64FqGGKA== X-Received: by 2002:a1c:4045:: with SMTP id n66-v6mr5424985wma.32.1535042880699; Thu, 23 Aug 2018 09:48:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 23 Aug 2018 18:47:56 +0200 Message-Id: <20180823164756.16948-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180823164756.16948-1-pbonzini@redhat.com> References: <20180823164756.16948-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::233 Subject: [Qemu-devel] [PULL 14/69] 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: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth 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 Message-Id: <1534419358-10932-6-git-send-email-thuth@redhat.com> Signed-off-by: Paolo Bonzini --- 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 f5d57da60e..3e93c8e096 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 852ccff1ce..1105c37e08 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 (!qemu_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 def1edaafa..1159b73d15 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 e6f712cbd3..73c52af3bb 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 5352c9c088..1a3a9c5099 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 2.17.1