From patchwork Tue Jan 7 16:51:55 2025 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: 855508 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp320159wra; Tue, 7 Jan 2025 09:00:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVv2dfsmaGT7KKeRtHN/NnjxbwaIFIavHxC7/UFC60jndrucX2VedT6KAPulJWxQX2BVzMjCQ==@linaro.org X-Google-Smtp-Source: AGHT+IEIDitdmSl7HIcivr8HHiZ8rJO/FyL5iPCDhJmkbdKe+9tvaVkHy7OKrueZoKkK1z88idXa X-Received: by 2002:a05:620a:44c3:b0:7b6:cb8a:3d54 with SMTP id af79cd13be357-7b9ba81f45amr9644150685a.51.1736269205897; Tue, 07 Jan 2025 09:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736269205; cv=none; d=google.com; s=arc-20240605; b=TGhuPZAz26am9XRvGbj+VvKpWn3CW/PP0He5FR334w2O5s10+5SVdkMcR0PRbGKZEg aT7zpOqZZRrvxBrVpx5jVoqAFIR54cC6nWOnOeh+qWBNxVMakQa5zYu5gMRaiw/moq0f CqrPuAGwEDj7l9DqcKxzurUlCu0QN/ZNa/hin06lmHKKThSnlq6k2SHpLa7OKFPnCHww z5rMUrqTEkeEnx7oAoysWmBxnG72iJRvAcWBHQgLSNQ3+ylorXqu0WQf/UNxmXKtHD/c KgHXppHpRGduZZ2d83aeVKuGq0betZEhjw+egcHVnf5dOyLDr3jbBmMmk9w5sL1Yannu Zp9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MJxt9IGDQlJ1+KQmlOP1oYH7KxpruLFwZ7bhPRqF6vE=; fh=gCrRMsBOO2s5UczjHW2I0Xj39iNRWP/OR2J6q01yAGs=; b=SkLNlWFPyu1U4ZTZWm+WFLJ3gOU0EpU+c1N8u7+sMtdFh2RnxL9SV0780zTYckj5zr jofGPW0kXM7wOQzFuGqhWaofFcZF1N2LFbNrogATHgLz+Ha0nGoJjooWD81jyRTbmAbB tBjdZPVFG8jz8Hn562APzaFd93DCD7wEQ5Zfq2jSMU5KPpnmgpNmY91CoEjMHFK2dkjv YrYCNZFnOaltb6YIBAG4R/eMXmpzmF6LNWcq6M7XJc1vVZqVJg+XFrVNPDnp1rcE4tZR 0YI1Vif0F5KIU5JnU+S4X9GUAo20f8yjLZM+Fj8h4RW2fWA4rH0cgmqMQoNH5njj3gNV EoZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l6scB2Ue; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b9ac53e80fsi4461059285a.658.2025.01.07.09.00.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jan 2025 09:00:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l6scB2Ue; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVCuY-0002lG-3z; Tue, 07 Jan 2025 11:58:34 -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 1tVCu1-00029n-Q9 for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:58:03 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVCtv-0006u5-W7 for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:58:01 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-436202dd730so113269595e9.2 for ; Tue, 07 Jan 2025 08:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736269074; x=1736873874; 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=MJxt9IGDQlJ1+KQmlOP1oYH7KxpruLFwZ7bhPRqF6vE=; b=l6scB2UeqOFWseQ0mJKSXmNjPLWythqOImEmAn59mEIQgtVfWimw6sdfN88GJS51MP jXKRWbXW0KiBV9Bm+0psIsJ2tZz5kIcb/AI+dsY/C5Lk+DiwrlJ6AoJjr/R0aePkgfd9 0qjIFHozNcCbmARAdGakCzkOZUMurYhXR85J/RudLCyzfSa23pESMj/oGgVsmiU34p0S y6eHSJFYQyVKIEztYpoBo4s27lEdVPGyNOpZV/EnXr5F/CtHOdA2AJzKbC8IsbxqsIJH 4fA2KK/EAn9XXhArizEkbkMn6RXVo4DA2nEUIPBGQtBvZ/G5EKktKdwJnoCJx3xHpg01 /SOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736269074; x=1736873874; 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=MJxt9IGDQlJ1+KQmlOP1oYH7KxpruLFwZ7bhPRqF6vE=; b=QYGq8RidevNWMXwVE0Mdv/00Lg/E9brmk7yiEirMH2ht5jB2YfCcmLM0BPNUe6/fe8 PRgTf7kI4AkGZZlQEx/b2srztCYBzfZMJZRDJ1OtM5b4aQwU54HqwmgYYL63FMvxecRk fG9dEFE9ES3X88iGphXyyzwQ+4CXMV2MdmRDCPaLc0hCrX5DeHycGWMRdW3neJwd3kor YT1x6A1j/FzOAM3dSb/Q//hlH4mtm++iv/5Y92jjeaAV+5tIK3ceut2wmxYf+9M2CRbT 0D2uJpQluJeflqxGw9P1xx5kJfjDqUwjaNfH5Z4iGrgMBJK0hdXZqSM3B4ve9KGekD+1 dcfQ== X-Gm-Message-State: AOJu0YycZQ6QxyrDpddgamk9SBO7GZyHFOAkLlav9TKYaWydEbnX4QRN 7gaVtxANnhBay9f21PYkDu8wwrOQYLkjwk32sK88pjAmA2oeJVCf1kL2ulDvxOo= X-Gm-Gg: ASbGnctabtjVjGDwXjYLPS5bf9jc+EF2Cmz5pREzeJcdcGhK3sbjHikAaYSAS5Oznrj laYUxNQg1EmtLNuEHny4LPbM/eg8CFHhAjYf34CrC/qO4EDmV2Fj2hl+AQRk64lk2pW8D8h4O04 6z2JHCYOHlLzY+BNAs3ZqA2XklqJAxk5C056Wq5BVG0ckrW3nD/WoI86od/tELAXH/+aLeOSq2Y xiNO9spUvEMO5XRg28wBZ9OmBy+WsbEXo+BVl6QSEcTbDxvT0miU2o= X-Received: by 2002:a05:600c:4688:b0:435:b064:7dce with SMTP id 5b1f17b1804b1-4366864618emr570189795e9.18.1736269074296; Tue, 07 Jan 2025 08:57:54 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4366127c4b0sm604067075e9.35.2025.01.07.08.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 08:57:53 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 909285FC6C; Tue, 7 Jan 2025 16:52:09 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Beraldo Leal , Ed Maste , Halil Pasic , qemu-ppc@nongnu.org, John Snow , Radoslaw Biernacki , Nicholas Piggin , Markus Armbruster , Leif Lindholm , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Bin Meng , Daniel Henrique Barboza , Marcel Apfelbaum , qemu-riscv@nongnu.org, Christian Borntraeger , Wainer dos Santos Moschetta , qemu-s390x@nongnu.org, Alistair Francis , Liu Zhiwei , Fabiano Rosas , Weiwei Li , Harsh Prateek Bora , qemu-arm@nongnu.org, Li-Wen Hsu , Palmer Dabbelt , Daniel Henrique Barboza , Richard Henderson , Cleber Rosa , Marcin Juszkiewicz , Peter Maydell , Laurent Vivier , Aurelien Jarno , Eric Farman , Pavel Dovgalyuk , Jiaxun Yang , Thomas Huth , Laurent Vivier , Joel Stanley , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Bernhard Beschow , "Michael S. Tsirkin" Subject: [PATCH v3 17/29] system/qtest: properly feedback results of clock_[step|set] Date: Tue, 7 Jan 2025 16:51:55 +0000 Message-Id: <20250107165208.743958-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250107165208.743958-1-alex.bennee@linaro.org> References: <20250107165208.743958-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.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 Reviewed-by: Fabiano Rosas Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2687 --- system/qtest.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/system/qtest.c b/system/qtest.c index 99ef2042f6..e68ed0f2a8 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 {