From patchwork Wed Dec 18 16:20:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 13913933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C008E77188 for ; Wed, 18 Dec 2024 16:29:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNwsZ-0002ze-TL; Wed, 18 Dec 2024 11:26:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNwsX-0002qJ-Oi for qemu-devel@nongnu.org; Wed, 18 Dec 2024 11:26:29 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNwsT-0007qe-JF for qemu-devel@nongnu.org; Wed, 18 Dec 2024 11:26:29 -0500 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aa6b4cc7270so903310266b.0 for ; Wed, 18 Dec 2024 08:26:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734539183; x=1735143983; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zmufaNphf2V1gjeMaS6HYVWY1pzqo9T3TKjafKi2Pnk=; b=oYtCUOjmK+3uDkfBgxSM/gWYnBYeCSMun7T6MO4a2tjG7NTvpqzSqJ2rbo15BrmDh1 crB96kJDDiOVYk9xB1R8bVVXcLN/fncuplg24rhJeKt7R3WUUb9mDB+ib9iX9GZOZJ05 T15WXczI8XirrE7vG9mlMCMOP6+pIIDuIiqI3+Q/rc/KtCl39zr3HHbU1B96i8XskCx5 3xIAUo5QEUAtFtEZaOsXRJJvwMu1PGmiDrK0u01pUBtyRdwj7jVQI9EilUXCB8YGhXan oJNtZITEOqyqSaTvOG1XT+JoKQY3/j+mzsH4kG1MQldm3YrC/ugVvlaetvZ1dt2j9UU6 Yq8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734539183; x=1735143983; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zmufaNphf2V1gjeMaS6HYVWY1pzqo9T3TKjafKi2Pnk=; b=vgZHPdtPjX0pAJJxGyn+7IUT2PRE3Z/0JQR4dGsR9IRRtT/kf/skJnMKpwm6M9KWic txqUN0BvQB9QApzv/gxke9PSaNkNNVaqS8z28+q2RVXvowYUpzW/9laSNK/hJubpZIpz yFabAW6pCH5j/foy4p58Yym1XwfFSdZ1aCmCLpbXqB7X8HK2cRoeo0gIWw7lBDroU634 CWpz5GMb8xRVEwxzB91BBjqDRLQrW3Mh+TKkOxa0Ca4yR9G960J0v0qR4NBPydiTJPQ7 2koJ45JhMaL0ISP3dv9p70P2Hn9RYMYm+W24NlXjnc5GyA6sWw2UDb5lHc6QlCOYWcwV pNLw== X-Gm-Message-State: AOJu0YySiJ2/FOj5RCAJVfhpM6xRNjNw1GHRqSQxS2/rpMUlkOVA7NAA xj7e2PHGsvztqjpKF5PtUo0NXhf6nD73+RdketoyiMKkTVQz4MO2gQwSe8jKaI0= X-Gm-Gg: ASbGncs1t/SfHD74nX5SeBSFzjy7Zj/U2qB7zyWCgQnuWzYLUYIb2I326xZaq2dRR7x E+P3fHuq8d2/+m/BF7RZbx8M/2tDZqIFXjqm8VNxcwkHPN0U9RWKxg6TwvOqF0zIUteiJTBydTR sq5G2jPnKApf5FdKTvA3qQ4VYeD1WOmke1yZAgCE1Or7EOsLVrjHI0pTgXQFiop7m9Aoyuy6zMF xoMxJy1JrlnsstmDIC1bzUTy0IewgYt87+wrAhdvQUylhJZ9EQpzhY= X-Google-Smtp-Source: AGHT+IFuUEHFx13lXdUOlZYt0rXroYUwQYZ2XCyJUvfsyymkg5v6w/loru6q3NyyO0B3TN4XuvXZGg== X-Received: by 2002:a05:6402:13cf:b0:5d0:d491:2d5e with SMTP id 4fb4d7f45d1cf-5d7ee37b60dmr8142158a12.7.1734539183339; Wed, 18 Dec 2024 08:26:23 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d652ab5198sm5489266a12.8.2024.12.18.08.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 08:26:22 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id DB7CF60729; Wed, 18 Dec 2024 16:21:05 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ed Maste , Eric Farman , Thomas Huth , Li-Wen Hsu , Daniel Henrique Barboza , Aurelien Jarno , Fabiano Rosas , Radoslaw Biernacki , Mark Cave-Ayland , =?utf-8?q?Marc-Andr=C3=A9?= =?utf-8?q?_Lureau?= , =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , qemu-riscv@nongnu.org, Nicholas Piggin , Joel Stanley , Beraldo Leal , Markus Armbruster , Jiaxun Yang , Weiwei Li , Peter Maydell , Cleber Rosa , Leif Lindholm , Christian Borntraeger , John Snow , Marcel Apfelbaum , Palmer Dabbelt , Bin Meng , Daniel Henrique Barboza , Paolo Bonzini , Liu Zhiwei , Wainer dos Santos Moschetta , Laurent Vivier , Pavel Dovgalyuk , Richard Henderson , Marcin Juszkiewicz , Halil Pasic , qemu-arm@nongnu.org, Harsh Prateek Bora , qemu-ppc@nongnu.org, Bernhard Beschow , "Michael S. Tsirkin" , qemu-s390x@nongnu.org, Laurent Vivier , Alistair Francis , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 18/27] system/qtest: properly feedback results of clock_[step|set] Date: Wed, 18 Dec 2024 16:20:54 +0000 Message-Id: <20241218162104.3493551-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241218162104.3493551-1-alex.bennee@linaro.org> References: <20241218162104.3493551-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Time will not advance if the system is paused or there are no timer events set for the future. In absence of pending timer events advancing time would make no difference the system state. Attempting to do so would be a bug and the test or device under test would need fixing. Tighten up the result reporting to `FAIL` if time was not advanced. Signed-off-by: Alex Bennée Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2687 Reviewed-by: Fabiano Rosas --- system/qtest.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 12703a2045..d9501153a4 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -78,6 +78,11 @@ static void *qtest_server_send_opaque; * let you adjust the value of the clock (monotonically). All the commands * return the current value of the clock in nanoseconds. * + * If the commands FAIL then time wasn't advanced which is likely + * because the machine was in a paused state or no timer events exist + * in the future. This will cause qtest to abort and the test will + * need to check its assumptions. + * * .. code-block:: none * * > clock_step @@ -710,7 +715,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words) qtest_sendf(chr, "OK little\n"); } } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) { - int64_t ns; + int64_t old_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + int64_t ns, new_ns; if (words[1]) { int ret = qemu_strtoi64(words[1], NULL, 0, &ns); @@ -719,11 +725,10 @@ static void qtest_process_command(CharBackend *chr, gchar **words) ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, QEMU_TIMER_ATTR_ALL); } - qemu_clock_advance_virtual_time( - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); + new_ns = qemu_clock_advance_virtual_time(old_ns + ns); qtest_send_prefix(chr); - qtest_sendf(chr, "OK %"PRIi64"\n", - (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); + qtest_sendf(chr, "%s %"PRIi64"\n", + new_ns > old_ns ? "OK" : "FAIL", new_ns); } else if (strcmp(words[0], "module_load") == 0) { Error *local_err = NULL; int rv; @@ -740,16 +745,16 @@ static void qtest_process_command(CharBackend *chr, gchar **words) qtest_sendf(chr, "FAIL\n"); } } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) { - int64_t ns; + int64_t ns, new_ns; int ret; g_assert(words[1]); ret = qemu_strtoi64(words[1], NULL, 0, &ns); g_assert(ret == 0); - qemu_clock_advance_virtual_time(ns); + new_ns = qemu_clock_advance_virtual_time(ns); qtest_send_prefix(chr); - qtest_sendf(chr, "OK %"PRIi64"\n", - (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); + qtest_sendf(chr, "%s %"PRIi64"\n", + new_ns == ns ? "OK" : "FAIL", new_ns); } else if (process_command_cb && process_command_cb(chr, words)) { /* Command got consumed by the callback handler */ } else {