From patchwork Tue Aug 21 17:01:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 960582 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ea1heq5s"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vy265b7Xz9s5c for ; Wed, 22 Aug 2018 03:13:50 +1000 (AEST) Received: from localhost ([::1]:54992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsAE0-0002Tm-Bq for incoming@patchwork.ozlabs.org; Tue, 21 Aug 2018 13:13:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsA4B-0001Ua-6D for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsA42-00063G-BT for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:35 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:33863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fsA3s-0005m5-KY for qemu-devel@nongnu.org; Tue, 21 Aug 2018 13:03:23 -0400 Received: by mail-wr1-x434.google.com with SMTP id g33-v6so6430307wrd.1 for ; Tue, 21 Aug 2018 10:03:19 -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=wGnGr6pPjXSG5P/b6PaiMfBx6WjEURtwGrsHV//vS1s=; b=ea1heq5spfPLUJXMqyT5zoEgYjs/UL4D3TP4qLThdJIAJVzDWEO3D+gCvmv2wDun2D z81dqMIYKdcaaP0pJSQ8MRqgqjO5jWOyPawS6/3bNcmDX98TZ/mLNpYmwBROcG174N4p 6Nr0KHh70mu9zX99gRJYCw4kZocDAYFcz/1U57icT4Ay1kvgiv8oAgxjfabqJuy2xubQ qdNJdZmkk8tTLe7kMFp5tYNk01bShIxx9qhXts5FIlQC388+HoSGpCP9SHrRvY4aEU/2 T5zPBLG+iKAjgaFKdp2ILX8yH6EXkPXg7PKx6fGEcMoNWEHCpGn1aucUwpCnkQn+rnBS PxcQ== 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=wGnGr6pPjXSG5P/b6PaiMfBx6WjEURtwGrsHV//vS1s=; b=E2kV3Nnz7jElEbrQMAkEZH5EYjm+8lI25PetEuMsA56fR5l+e3/jpY6rX6lYbeDCcV uryZG2WePZxkpebyDGqAdhbNvWvg6M8vo67vc6OPXMC9ghOtObdKZHoET7imyfcADlh5 oVslmlUMwv4WPBYG0Gp7AvtghxtlpqK1cSKePUZNQTyeOa0cKsXivT8+wpyxZmC9rtyd svmOwcMoXIn3fTeDXji/fUAHLi8wpZgWUPeHljqlXQnPI9I780AImfiAU37/X7hGpQ+B vvLa3+8SscBiV7Fb0oQ+gTIZOo5W5aJLapEqD9O0Ic80iWAKAcszuKR+3R8a0ie73jEC taxQ== X-Gm-Message-State: APzg51Dq1TZBazA8NnP2xk1p0UzL+XapMpoCVasW5PIozukitAT1qIpy VE1ixmKoTJRsWiSLIqjVsABVkPCs X-Google-Smtp-Source: ANB0VdY9qSP0fA3CaYfBo4y+QkD7zmsXyfpKEUIYR9BewMfFnweTcVWksWcBH2+5Yl2Gt03KrwltqQ== X-Received: by 2002:adf:f8ca:: with SMTP id f10-v6mr7401355wrq.237.1534870998381; Tue, 21 Aug 2018 10:03:18 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id v6-v6sm2608955wmc.43.2018.08.21.10.03.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 10:03:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 21 Aug 2018 19:01:46 +0200 Message-Id: <1534870966-9287-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> References: <1534870966-9287-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::434 Subject: [Qemu-devel] [PULL 14/74] 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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=slow" 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 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); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 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()); } 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; } -void qtest_cb_for_every_machine(void (*cb)(const char *machine)) +static bool qtest_check_machine_version(const char *mname, const char *basename, + int major, int minor) +{ + char *newname; + bool is_equal; + + newname = g_strdup_printf("%s-%i.%i", basename, major, minor); + is_equal = g_str_equal(mname, newname); + g_free(newname); + + return is_equal; +} + +static bool qtest_is_old_versioned_machine(const char *mname) +{ + const char *dash = strrchr(mname, '-'); + const char *dot = strrchr(mname, '.'); + const char *chr; + char *bname; + const int major = QEMU_VERSION_MAJOR; + const int minor = QEMU_VERSION_MINOR; + bool res = false; + + if (dash && dot && dot > dash) { + for (chr = dash + 1; *chr; chr++) { + if (!isdigit(*chr) && *chr != '.') { + 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 = g_strdup(mname); + bname[dash - mname] = 0; + res = !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 = qobject_to(QString, qobj); g_assert(qstr); mname = qstring_get_str(qstr); - cb(mname); + if (!skip_old_versioned || !qtest_is_old_versioned_machine(mname)) { + cb(mname); + } } 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_ATTR(2, 3); /** * qtest_cb_for_every_machine: * @cb: Pointer to the callback function + * @skip_old_versioned: true if versioned old machine types should be skipped * * 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); /** * 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); - qtest_cb_for_every_machine(add_machine_test_case); + qtest_cb_for_every_machine(add_machine_test_case, g_test_quick()); 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) g_test_init(&argc, &argv, NULL); - qtest_cb_for_every_machine(add_machine_test_case); + qtest_cb_for_every_machine(add_machine_test_case, g_test_quick()); /* as none machine has no memory by default, add a test case with memory */ qtest_add_data_func("hmp/none+2MB", g_strdup("none -m 2"), test_machine);