From patchwork Fri Jan 10 13:17:39 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: 856252 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp223781wrc; Fri, 10 Jan 2025 05:26:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWU8ZmpHVH/Ra+fHhJI/VYfnN9UZmKPLxIFHeNiIgHSQ1VxeaYASnWEkHzTrCaKhEQhDoX2Ow==@linaro.org X-Google-Smtp-Source: AGHT+IGX1XeFjaq6OXpeGqf1yL3jG8zFh7PfWc4QG9gOHQaCOy0gSQw7IHC2EHT5nPvW9eLIPFsh X-Received: by 2002:a05:620a:2450:b0:7b6:d435:ccf7 with SMTP id af79cd13be357-7bcd9767e0cmr1466960885a.50.1736515572547; Fri, 10 Jan 2025 05:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736515572; cv=none; d=google.com; s=arc-20240605; b=FxOVQbF3IZ9/Z6JLdH36PxY0Zs1WGUn/625Ma+QXpSoVJHvRhJ8er8rjnaLd7jzfiR IuGazJHvd/sorp9go4+SbL9h4cRHmdVjmXIfBw5DnatF2OuEn9tG3OinBWVRC9z0HA0U MoNrSgLSQrOZ+cV3URoBrT8aNLF2O2yaZwQoq2pIDyp/zaRd3N8jK5QhZPBgcHJbRJm0 g0Uxho7XzciUNe+IYSA9ezNp5wKqokimnK9erajapSJ1EkcX61RNHF18pfeMJrgKBEUB FvBnP7oJMw2xz7vWEaq5JnYZ+b6QSj25wjN/Q9NjzzwqlQGoCBFTvfVs/37mQmtRq3jr BIJA== 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=41wL9S2WjuFMsg/x9Ao10h4Njo7dU6+cGfdY/1G7SPs=; fh=2iAtZVMPeHSpEU1BdrqjMAyPSzMzQN8Ofxt9dTNF4N8=; b=TO3xv2lPDLijXmvnNKzKd2yP3SEWKjUIitbuUifLlEvICGd2WNk2PaVZB5eLDFDpJc futumy3+Te5galff4T5L2gpcWbgsCcK50Gbmq7M8hpt8LkZRr3xsrxCCFUDu18aT+iWd e2LtY/ctZZ9EUzmxQXnjN3GbS9wlRr5iKzLHm907oDHQBpg5ZOf0J4/1jAsiXnkHo98A TPGhxEEI+zAs024Ag3kYFAmqOPyhJkfrUwViHw1sNB4Fa5wEyDwcXyLaPR7aAoT7m1No qPESkAQ613LfmB3rlC2WY/X915iLbceIcX1Z5c06nZp+Qhs86wBE3FZGVYmFltmQajtu rsbQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wF/YVUi+"; 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-7bce3307727si427187885a.339.2025.01.10.05.26.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Jan 2025 05:26:12 -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="wF/YVUi+"; 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 1tWEzg-0000ks-Ee; Fri, 10 Jan 2025 08:24:09 -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 1tWEzA-0008Pg-6u for qemu-devel@nongnu.org; Fri, 10 Jan 2025 08:23:36 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tWEz8-0005el-AP for qemu-devel@nongnu.org; Fri, 10 Jan 2025 08:23:35 -0500 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5d0ac27b412so2530480a12.1 for ; Fri, 10 Jan 2025 05:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736515413; x=1737120213; 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=41wL9S2WjuFMsg/x9Ao10h4Njo7dU6+cGfdY/1G7SPs=; b=wF/YVUi+jWzFRF7Kpg4PjmW2DYfcqm18U1hWyxsojY0C45THYZ9oCftjfRSJQM5err Bn5JALdBkWg5scemhuvf1tHan75iCtjBFWEpdfpRWgjheIXQQdwVDQ0sHwNAFY4mHnKV 8C7wafjtue1oikoNomdpvYb3Zcs/1ykZ6b2rniufr4nYpg5w7lt8Kl1CHFArF3cWGQ1Y hZ2kM3zYZXFaBNRpt5b26fFpxqyDbfkTH0xcKMrXNOSXEiE/5wD6oDZx/Yziq8zt9b+S IX/CHzk8ybTxkSlGbCysclKFZKYNbJc3M/jcauf2khfvmJxSXHZrDB88ob0OYc2M8S7Q /NhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736515413; x=1737120213; 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=41wL9S2WjuFMsg/x9Ao10h4Njo7dU6+cGfdY/1G7SPs=; b=FFFl4sOl7ltGLwU/IyGdHd8b3GN4AlTTfg9otryQKR46ARIGYAOdzcIxExgfoCGGWM a7LWHyVbN6T4/kv/I1lK1P3FeGlcEC1nwEuZ/14f5ruBMYdQjeAlGNKBhLEZxKsaZkX/ doFA8St+1XlIkfNGAhg3gqWFmZMP+XrsRWzeHVzbor4mc5sX7srgDb76kuhTrrU4UQU5 VMTfGij2dxw4eLEqT8r+Zk3WHQKLpCgOPFXyJp2WKm1SZa6fmsFmlgGcnSs/flCd86DU /17frNbAnhk0Z2iT6VxgHOiwOAI4r4euM2kGWL1LBSk6t+XTrXija7x4Xv77RJF+4q2l H56w== X-Gm-Message-State: AOJu0Ywiyo+pwUE3BQONqt2bz1bpWHv6C+ebZC62cjVXeORffR7qgfRd ynH5YuVCQrwwnC8/Nder4ewhHhh0rLsSiRWB008TbZuPw9XSnk1XQpGLp18tDW4= X-Gm-Gg: ASbGnctQHmkS/BvKmxfrqbUgfVkGCiGQ/VWChZIkaM9gZqC5/7LbHMOPsjEkjsiSvWc RmciYkf5EVOx6OQ7ZgfGCyRLrS/v+GrtQDpJLbXtUez2qDRPJMHqGuV74+uCOCy6MkqXKm/+dek a9eXucQM+KS0ktILryS/Roy98RyWBsrTy8AdWp3G079rYk24SQplC5S18wVjAHW2FW/dO/nBHXw /fX4ocLOS6dqLeFBIWeg8UtvLumW6NzbdBdN7Kut6NIJnbjkMwAvcY= X-Received: by 2002:a05:6402:2690:b0:5d2:7199:ae5 with SMTP id 4fb4d7f45d1cf-5d972dfbe9amr9522973a12.5.1736515412795; Fri, 10 Jan 2025 05:23:32 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9903c4598sm1637061a12.53.2025.01.10.05.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jan 2025 05:23:31 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A0C40609B6; Fri, 10 Jan 2025 13:17:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL 17/32] system/qtest: properly feedback results of clock_[step|set] Date: Fri, 10 Jan 2025 13:17:39 +0000 Message-Id: <20250110131754.2769814-18-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250110131754.2769814-1-alex.bennee@linaro.org> References: <20250110131754.2769814-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52d.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+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. Reviewed-by: Fabiano Rosas Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2687 Signed-off-by: Alex Bennée Message-Id: <20250108121054.1126164-18-alex.bennee@linaro.org> 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 {