From patchwork Tue Dec 10 20:43:47 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: 848894 Delivered-To: patch@linaro.org Received: by 2002:adf:ec08:0:b0:385:e875:8a9e with SMTP id x8csp542477wrn; Tue, 10 Dec 2024 12:51:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUUN81AnmZJUG39lMl7jXSrgv7UqjY1OXdVnjfVEnk6G5hOMLRSX5mLDpvCiTJsD3KMJ96h9A==@linaro.org X-Google-Smtp-Source: AGHT+IHgg8ZoRK5gre4TUeOsxuPgIhE6iLzeCzZdQJZE8T1RKXMz4YJqVN9T9UKjNAYMtS8yMc+l X-Received: by 2002:a05:620a:4594:b0:7b6:cb3c:cb81 with SMTP id af79cd13be357-7b6ebc6e5a3mr29202185a.18.1733863883435; Tue, 10 Dec 2024 12:51:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733863883; cv=none; d=google.com; s=arc-20240605; b=KBB65slCVvAIucfcymUPOcLO1aKroJKWJbWNFoMNP6n/q9zoOl8egWZ88uSZEzwb4a qnJ/rznhIQGg4bfZPOAru7Z47vo5vNj22PGdHK61Ebmrg2ctw3rzWeesZG6Z4k7C3gOz ex3UrPp4oiLM8JBanJzHRaec6jZEDlHyUsFwIM7SPHGvkk2pAbkXPi3aqUgDYYZ6c/Dj IMrzsUTPnQpnP4NM+kZ6KlSRBStSUDUXsRTBPOUrM8kdW5ZM7NXBLbbWLjlC7/BqNrpV V6o3HtdXjjS6H3JiHB1EcPd3tprh7nEL0DvVj5GkRPCuySQJUrubLYh6EdF12Y80tnHk vfFw== 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=zmufaNphf2V1gjeMaS6HYVWY1pzqo9T3TKjafKi2Pnk=; fh=FC288pp5j0mnGELUTZ0Lqjt/J7y8NvB/BPvTKfRC7hs=; b=MNmptoq3NXD0/nz6Ev7hy4JNy7wX5PTbnVwIfO5Amo23QzBtpNZyBrXkeQqwzMgNta hX/++SvWyzBFrwypCxp7+7ittlxWOHsu9x2988fq1klhCu7i0mTgC0XenzabjiBuQ0Jw VnGEFbemE8YI1OTubTSFPRD5bDHw8VsT3pF4UeDeTy8W7bjk9rgncQFofvhskaQsZ7ub CG/0If/1lseTl2znbH5Fmw9KyRY7hxfs8CPEzgljriKmLLXKATvEBLKYoCAEAIbj/RBZ ymVvf93ErjIxi6m7nzz3W44iTdoIf+vfhHEvq704exUXKR3Kg+mGrbB69CXvjuu+o4sM hLOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UVQ8n7c0; 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-7b6b5a5c902si1517965985a.208.2024.12.10.12.51.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Dec 2024 12:51:23 -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=UVQ8n7c0; 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 1tL7CO-00065p-Eh; Tue, 10 Dec 2024 15:51:16 -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 1tL7Bs-0003zn-25 for qemu-devel@nongnu.org; Tue, 10 Dec 2024 15:50:44 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tL7Bn-000372-Cj for qemu-devel@nongnu.org; Tue, 10 Dec 2024 15:50:43 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4361b0ec57aso4196915e9.0 for ; Tue, 10 Dec 2024 12:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733863838; x=1734468638; 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=UVQ8n7c0L02p6WP2pRRbzfu1rajSgjYqtxRA3jRDRHSukLDlE7FVXXfqSFpWs6U+/S w4IQb/pZ5zSv+DPIlbxzB5+OOKRuuTI1EvbdaMeIAb6zF5n+7/Fl1fGFyDq9JuyHhte5 VrZIsiAz0wzPz2PzL0YNb0xqlcByiYd20z4kcvBSj3kfV/asPvAOYvoQDSOgXGD5oIkZ hlRreFVrWwLR0NdsSQQhc4GmoQuFZZOEDU9w2KB17XlgAsV9kwAFHpiMs8b1Emx9+4Uy QxjUQPpEbPi59usm/4pPmbZDiCqQw1YmvK3osh5NHZieNliQbItar/CE1A/v/tjmdHfP fcjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733863838; x=1734468638; 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=HDmOAu0mGo81b/kFTJ5W8Nwb1AXAKoh1HkIyFfPiyNihhhE63GODCp1OAn68tBlKEz VTdm1Rh7/3V0E4SCdylff2vjU5ymd0bbLMrOrMTLmHVMnygy9wfnfViT2YgJE0hvreOs IivLvHhyj9RsctQAfTdSG+gaUOgQEkudGNIzTF4EPMxszlCi47W66B5tJQAj/HAaR0z5 anXd+tQiZxznyoPgld9IgwxVtNKx2j0QYGoJAZ6L3BAQEiWSrzn6ZLw/7GltI9FnI1An uTJE77pO7o269dGWCkIJusNGoJsRYb+Mb2assO+FtKacwjqmMgJUXvJgt+mCQkKLLsmZ hy9A== X-Gm-Message-State: AOJu0YwZZ9Rhgi1U+khGG3v5IekkzpLHVRwKvHs7C81EKBpzxMV86Dwk tWIWGoHS6gdn3DIuzJYgr1/4zC7bCJEbOLfH0deGwrvLdLhSXwCiilp5aPAhLlk= X-Gm-Gg: ASbGncuJEoG3McOrrKAP/2SsfcxeHQDG6EklZoOY0b528nqs9rfYw2OsPRVJFbplRCj 11gRGrZ9YHvaGm78SYeHQs1tt5Xb+ZOdO/uejK1GawwHfb5g7SIiFy3THrKQs4zWkOs+ZKd9xAC Yq/RMMwDxMzjLd+2MdakEuUNeBQnVGqu5VBgBiHGEsmYva9PbDp5r4o0z8UU5Ud4C6x8DLXOEfF V/GMfb0/c6Ke5WmZPBCVzS4UJHBGR5ZpV4UYOyYpytmm22W1Rij X-Received: by 2002:a05:600c:1c82:b0:434:f819:251a with SMTP id 5b1f17b1804b1-4361c396f09mr1898885e9.9.1733863837644; Tue, 10 Dec 2024 12:50:37 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-435ff2f46d3sm26878345e9.19.2024.12.10.12.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 12:50:35 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E4F1060B86; Tue, 10 Dec 2024 20:43:50 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Daniel Henrique Barboza , qemu-s390x@nongnu.org, Halil Pasic , Jiaxun Yang , Weiwei Li , Liu Zhiwei , Cleber Rosa , Palmer Dabbelt , Leif Lindholm , Eric Farman , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Harsh Prateek Bora , Aurelien Jarno , Paolo Bonzini , Joel Stanley , Bernhard Beschow , qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, Daniel Henrique Barboza , Thomas Huth , Laurent Vivier , qemu-arm@nongnu.org, Wainer dos Santos Moschetta , Fabiano Rosas , Markus Armbruster , Bin Meng , Pavel Dovgalyuk , Marcel Apfelbaum , Richard Henderson , Marcin Juszkiewicz , Christian Borntraeger , Beraldo Leal , Peter Maydell , Radoslaw Biernacki , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Nicholas Piggin , Mark Cave-Ayland , "Michael S. Tsirkin" , Alistair Francis Subject: [PATCH 18/20] system/qtest: properly feedback results of clock_[step|set] Date: Tue, 10 Dec 2024 20:43:47 +0000 Message-Id: <20241210204349.723590-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241210204349.723590-1-alex.bennee@linaro.org> References: <20241210204349.723590-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2687 Reviewed-by: Thomas Huth --- 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 {