From patchwork Fri Nov 15 16:50:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 843506 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp946488wrc; Fri, 15 Nov 2024 08:51:29 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWUTMpFnqoK9BmOThS35oEYXpobUjwhQcWC4+KJ+4Vbrn4+ICnm5QZ52UaWNWXYyRsO6OKxeA==@linaro.org X-Google-Smtp-Source: AGHT+IGlxi/BM73yL6nRD1puaDHFPK9w1xgxtdKANtPuzAHiLztC4OTAyEsLqJPqBLYBcpUz7yyS X-Received: by 2002:a05:620a:371f:b0:7a9:b9dc:1b72 with SMTP id af79cd13be357-7b3622e6b31mr390847785a.23.1731689489069; Fri, 15 Nov 2024 08:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731689489; cv=none; d=google.com; s=arc-20240605; b=QLvNq+qX7N+tsdDUJFNtm1t60RUszU3yLLB6CUjQpSdub7XRGC06EDQ3OshGDGx9+S FxScKCMKXypg7iPfxB3Wu9/mptQesheWzV2SQ2EkDd8W7KtsI7RNZLXo9RxUM1M7tA0a u97vIlxZvSbu6S5Pwkz2y7m7MoL8Wkl3+k92KPHP5lgswsjczLNchGLY9NM+1sJpgtXw bBxicpJxorlRWW/nc703oXkRb8lqJTKQPJFVFma3y/eKQb7Al3ddXbhnkdhDsNCbE047 vwJ0KiO3HGEVmJnv8qc8Ms/BCMyXSptYYhgWZHD5M/Ofkb5ftheFLXgur2fwPUt2XxCp nAXA== 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; fh=L+F+imk7SNxd+VJgpUcpWeNwCxrzN2ZHmlwvyOYjkVU=; b=XOgXCA36coiNHGF9l1w3jkNytajrcAHbVdQ5I8n4EY+5mmDyfMRfPp6KB9tRTiAfGw KYEC71Rqy5PHfNXEsKnBUaKqZz7ykYEx7sp5F/K2DMjpYftEAmgwE1wC2AEAr85BO/2a nrFrTzuo1fboKcrzOnMQkXSSFuFIONf7UHQKGcF//Khmm0z6oz/cAUFDijKB9IofD0uS Gyou6oFKnBsmCEuuRiC2ganSy/Ax54rnx/HNN4CqgDjxQHdFlCPWDrjLlA/rQO17JTF9 TvkfOjUM1oG+yfccFdgXzA3r5UabF/W0GQZCHXYmuIAvhgzQL+CguuQ4i3adFG8EAJxz YxPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rjEaBllr; 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-7b35cae7c37si401435385a.605.2024.11.15.08.51.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 08:51:29 -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=rjEaBllr; 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 1tBzX0-0007vv-4y; Fri, 15 Nov 2024 11:50:50 -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 1tBzWx-0007uv-MD for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:48 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBzWw-0003ai-1o for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:47 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4315baa51d8so7531785e9.0 for ; Fri, 15 Nov 2024 08:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731689444; x=1732294244; 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; b=rjEaBllrSSJmMJ+DLd7Y5lOdA9GXP2K97OKvoQsu4s8cl4kDZonuxkasr5ieGuVQ5p zNXtfUygGvBLPY/MVqWVMHnQ65neBcO3gZUXBOYQSIWiAdAlFPrUTSOzmvarmxwG+08P ws8/mn2bUrA5QnsmUpIt87D2tVSTPaBi/QaaKd8mtN1U0+2ZjAnKEAV/s8cf3QZerkXh m48HZcRfuOTfp3B0PVbMt9FEUTp004pR6YV3Yc0zxv5F5JiSUUZJ0aU97p8fp4OZYUqN 3+4cnkBFrvLxk7fihl43hWiFJkpVm48NHolbHKIvLVvsEkRFw5LKYVCOo/DHXi5LBc1l nkaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731689444; x=1732294244; 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=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; b=opfIdM/bBbumUb+yENdSsz4pyMS73+eQIkwS5Nti4UHd8+DNFQPcgsAbgusXlneEPh rxuzugyD1RDf3B06IjttKHUdB0KMw3xGSLRxerqZgWT8YHTXMwwWKOuIgJWn5t1FObWM GFvX8eJ1KQwVih1rnpsFNhzzK8THZNxhEu1xIbUcd9pOkhXDq2X4JUam2nSLVfcDp0vA OIP0Wauy+egVgllDrltgq0xXQMCohkz9f+vgXIrnl4e6dvNH2muonx8TxMu16spyiBor tG0gAs2ycJddtXZ9XazHAHcYnvcimuA3+DrL66Fd2XMxyYGZQeCTlM4I1UZGPRmuJxL/ jYoA== X-Gm-Message-State: AOJu0YyDEqgYxV2LSod+oJjgMyu6SFXTKDMBt6AWgQSRPR57fSvo9+US VbBVRr/axy+0aE5XqUuOgujvxO6iSN7K4wT/licgxTRj3coUpgqTtGiBqrgt56DHM9RJLEDuDL8 f X-Received: by 2002:a05:600c:1d0a:b0:42c:acb0:dda5 with SMTP id 5b1f17b1804b1-432df7179e0mr22855475e9.1.1731689443970; Fri, 15 Nov 2024 08:50:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm60386405e9.28.2024.11.15.08.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:50:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Roque Arcudia Hernandez Subject: [PATCH 1/3] tests/qtest: Add qtest_system_reset() utility function Date: Fri, 15 Nov 2024 16:50:39 +0000 Message-Id: <20241115165041.1148095-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115165041.1148095-1-peter.maydell@linaro.org> References: <20241115165041.1148095-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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 We have several qtest tests which want to reset the QEMU under test during the course of testing something. They currently generally have their own functions to do this, which work by sending a "system_reset" QMP command. However, "system_reset" only requests a reset, and many of the tests which send the QMP command forget the "and then wait for the QMP RESET event" part which is needed to ensure that the reset has completed. Provide a qtest_system_reset() function in libqtest so that we don't need to reimplement this in multiple different tests. A few tests (for example device hotplug related tests) want to perform the reset command and then wait for some other event that is produced during the reset sequence. For them we provide qtest_system_reset_nowait() so they can clearly indicate that they are deliberately not waiting for the RESET event. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- tests/qtest/libqtest.h | 25 +++++++++++++++++++++++++ tests/qtest/libqtest.c | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index beb96b18ebd..f23d80e9e5e 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -88,6 +88,31 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args); */ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd); +/** + * qtest_system_reset: + * @s: #QTestState instance to operate on. + * + * Send a "system_reset" command to the QEMU under test, and wait for + * the reset to complete before returning. + */ +void qtest_system_reset(QTestState *s); + +/** + * qtest_system_reset_nowait: + * @s: #QTestState instance to operate on. + * + * Send a "system_reset" command to the QEMU under test, but do not + * wait for the reset to complete before returning. The caller is + * responsible for waiting for either the RESET event or some other + * event of interest to them before proceeding. + * + * This function should only be used if you're specifically testing + * for some other event; in that case you can't use qtest_system_reset() + * because it will read and discard any other QMP events that arrive + * before the RESET event. + */ +void qtest_system_reset_nowait(QTestState *s); + /** * qtest_wait_qemu: * @s: #QTestState instance to operate on. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 817fd7aac52..8de5f1fde30 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -215,6 +215,22 @@ static void qtest_check_status(QTestState *s) #endif } +void qtest_system_reset_nowait(QTestState *s) +{ + /* Request the system reset, but do not wait for it to complete */ + qtest_qmp_assert_success(s, "{'execute': 'system_reset' }"); +} + +void qtest_system_reset(QTestState *s) +{ + qtest_system_reset_nowait(s); + /* + * Wait for the RESET event, which is sent once the system reset + * has actually completed. + */ + qtest_qmp_eventwait(s, "RESET"); +} + void qtest_wait_qemu(QTestState *s) { if (s->qemu_pid != -1) { From patchwork Fri Nov 15 16:50:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 843508 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp946635wrc; Fri, 15 Nov 2024 08:51:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWpgXd9NIPrvvY7NESlCE74JRbo8wnSjecowMUR3CqGv4StWsiNhUX6SvBUIHmBQogpmkHZbQ==@linaro.org X-Google-Smtp-Source: AGHT+IFFQxe1ZvDIuxIOSUetLsgThNMxWojDE1pyLxYNeRAExHWqPJKTr82+6eDKt6fn1NnKwhjd X-Received: by 2002:a05:6214:5910:b0:6d3:9b88:db62 with SMTP id 6a1803df08f44-6d3fb77cafemr42177406d6.17.1731689509673; Fri, 15 Nov 2024 08:51:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731689509; cv=none; d=google.com; s=arc-20240605; b=YB1RlHxINdKFVt/0ffzRTdspfvgabih6k9ZFLHUemzoPztEGlaS07c+XkwqzuSs+Xm Qvcpb0S45uHi4gVnKCmiSnk7JlHyZV4pWagjcWAI6xIS962cQ78USNsZRbaZfRySZGxP TTO4DPhY9kbPJZspO+El3yb6mekzHVcQgnyf5Du7mtY4iyIRS7JM1Eon5wkfhLeowwm+ WI7eW1XNR+7QpvLq8yqNaVPOT+EKGWioMlYIg4KOE8jfeFqQey9OcQ0ApnWNe6iJrZJM 3BTwDCT3FM5B5NTzFYkQPNUI3ssZbYshrk9KT9Ht/XAfCgcc0ul37eo1oel7USGAxuPD Cxug== 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=VXby9Lwvv6tS8EYvlf5Sy20J6KaSCeX254YtCAwIIqo=; fh=L+F+imk7SNxd+VJgpUcpWeNwCxrzN2ZHmlwvyOYjkVU=; b=HiYdW+Rg2TGkLnZ0m1mDWVS6oKol0bxeasaoi0wVtlG39ajHWrCC1xfuO6UUlvjt0E grUZ6KHjsAxx69ok5fm7vG7+ZT8tU2z4SRct2rDhA2A9no8kFwkbwSnFfbNOijKVsZQ8 +9wK8tX4p7Kc0Ntdmr2aNSjGaIp0BpBHgx1Ym7t8c3r898x80EwIhOQwRPd1s+1p2f1h lovdh/60SiYSJ3HJlJOWZcmnpaLaDD4JpYkMnZrUQt07Mz8MPnbNpprsT6A6n5uRGx4z Hq0qlxOZWfvHTxWV3TWqcqWO1wWWcbw/ULMSFRpcE2enW4KxQzczXe8XFuDNe2il638O ii/Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qDs7113Q; 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 6a1803df08f44-6d3ee8b7315si40786166d6.201.2024.11.15.08.51.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 08:51:49 -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=qDs7113Q; 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 1tBzX1-0007wI-PN; Fri, 15 Nov 2024 11:50:51 -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 1tBzWz-0007vQ-4q for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:49 -0500 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBzWw-0003am-RN for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:48 -0500 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2fb5be4381dso20403011fa.2 for ; Fri, 15 Nov 2024 08:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731689445; x=1732294245; 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=VXby9Lwvv6tS8EYvlf5Sy20J6KaSCeX254YtCAwIIqo=; b=qDs7113QLHm54bHLlT33WUHaM9TuEMrXxUu1c612j/f6Lsg3D0DePgR2QqnVjNiWym AN7xHkIya+XEDjae5BHDReVx2pWWYf3DQidSrfXczvTEBc9lYrR1CNkEdacZTDqbryba 8DgxVsuDsOKzsVY5lKNZs8vG45MDUmu6mpC7jWQcTWtSR3QBq8prAJLpO4jJ6X+mRvoF bR0vqVmlOziXzsAQGQn+xApjITcA5/GA8omx9Yy36MwclfeIh4juIJGZ2BvGuCZdWV+Q FTBuGuQiu3ufEaofXgQxkNLIUlP9AF+/VvUZucWEOdgQ0bikT1uoAvgkHp4Tiz7zLKwX 4Y8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731689445; x=1732294245; 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=VXby9Lwvv6tS8EYvlf5Sy20J6KaSCeX254YtCAwIIqo=; b=nyweDWm736smU6xQk9OY1XEBuC3mgxHpbTDmiDUNHjvQJsyD7qGeWxGKNVO1JrGiy4 mLjsK5RRtBKXkRf5c0T5WGHC7CRd4XuEAImkCuRL++LqmUPG4+R92vhxc/2UH6lBriwd WdA1VpSXhVWrW2xzzNCVIzIKTx0xc8VVPCU+yDD71unGgLhToMigHTHdA9mI7Mq7nTYE MoBx+qFogvb7wwIvPMKhHpdNCFCwZDK7cZIl/zx9F9QX/uLjkoNvUU++PdRkIkrqJKlh 3m1jPZqJLxRkCl2tST9PRKQoxrjPN3QzLZ+10QlUKwBB4bHJdas8+BdmyLpD0a38Ysu1 tjFw== X-Gm-Message-State: AOJu0YyhhKjTZBCKDSwalBYWFd4WsJei2rzOEHwlnl5Zg071BqIPYt+c XwvEXYq0KqvcmzJrwmuWlvcr4/j3V1tlVSYIh8vARSDkIa5NbD/c7p9OP3vMpd0DWSw10/0gjmx 2 X-Received: by 2002:a2e:a58c:0:b0:2fc:a347:6d87 with SMTP id 38308e7fff4ca-2ff6093a9b5mr19851401fa.13.1731689444747; Fri, 15 Nov 2024 08:50:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm60386405e9.28.2024.11.15.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:50:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Roque Arcudia Hernandez Subject: [PATCH 2/3] tests/qtest: Use qtest_system_reset() instead of open-coded versions Date: Fri, 15 Nov 2024 16:50:40 +0000 Message-Id: <20241115165041.1148095-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115165041.1148095-1-peter.maydell@linaro.org> References: <20241115165041.1148095-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x22a.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 Use the qtest_system_reset() function in various tests that were previously open-coding the system-reset. Note that in several cases this fixes a bug where the test did not wait for the RESET QMP event before continuing. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- I can split this patch up if people prefer, but for test code and given the size of the diffstat it didn't seem worthwhile. --- tests/qtest/bios-tables-test.c | 4 ++-- tests/qtest/boot-order-test.c | 7 +------ tests/qtest/hd-geo-test.c | 9 +-------- tests/qtest/q35-test.c | 12 ++---------- tests/qtest/qos-test.c | 3 +-- tests/qtest/stm32l4x5_gpio-test.c | 10 +--------- tests/qtest/stm32l4x5_syscfg-test.c | 12 ++---------- 7 files changed, 10 insertions(+), 47 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index e79f3a03df0..da42e6e3eb5 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -959,7 +959,7 @@ static void test_acpi_piix4_tcg_bridge(void) free_test_data(&data); /* check that reboot/reset doesn't change any ACPI tables */ - qtest_qmp_send(data.qts, "{'execute':'system_reset' }"); + qtest_system_reset(data.qts); process_acpi_tables(&data); free_test_data(&data); } @@ -1216,7 +1216,7 @@ static void test_acpi_q35_multif_bridge(void) free_test_data(&data); /* check that reboot/reset doesn't change any ACPI tables */ - qtest_qmp_send(data.qts, "{'execute':'system_reset' }"); + qtest_system_reset(data.qts); process_acpi_tables(&data); free_test_data(&data); } diff --git a/tests/qtest/boot-order-test.c b/tests/qtest/boot-order-test.c index c67b8cfe169..4c851c2cdb9 100644 --- a/tests/qtest/boot-order-test.c +++ b/tests/qtest/boot-order-test.c @@ -40,12 +40,7 @@ static void test_a_boot_order(const char *machine, machine ?: "", test_args); actual = read_boot_order(qts); g_assert_cmphex(actual, ==, expected_boot); - qtest_qmp_assert_success(qts, "{ 'execute': 'system_reset' }"); - /* - * system_reset only requests reset. We get a RESET event after - * the actual reset completes. Need to wait for that. - */ - qtest_qmp_eventwait(qts, "RESET"); + qtest_system_reset(qts); actual = read_boot_order(qts); g_assert_cmphex(actual, ==, expected_reboot); qtest_quit(qts); diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 85eb8d76687..1c73dea8f75 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -900,7 +900,6 @@ static void test_override_hot_unplug(TestArgs *args, const char *devid, QTestState *qts; char *joined_args; QFWCFG *fw_cfg; - QDict *response; int i; joined_args = g_strjoinv(" ", args->argv); @@ -913,13 +912,7 @@ static void test_override_hot_unplug(TestArgs *args, const char *devid, /* unplug device an restart */ qtest_qmp_device_del_send(qts, devid); - response = qtest_qmp(qts, - "{ 'execute': 'system_reset', 'arguments': { }}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); - - qtest_qmp_eventwait(qts, "RESET"); + qtest_system_reset(qts); read_bootdevices(fw_cfg, expected2); diff --git a/tests/qtest/q35-test.c b/tests/qtest/q35-test.c index c922d81bc02..7f58fc37469 100644 --- a/tests/qtest/q35-test.c +++ b/tests/qtest/q35-test.c @@ -83,7 +83,6 @@ static void test_smram_lock(void) { QPCIBus *pcibus; QPCIDevice *pcidev; - QDict *response; QTestState *qts; qts = qtest_init("-M q35"); @@ -107,10 +106,7 @@ static void test_smram_lock(void) g_assert(smram_test_bit(pcidev, MCH_HOST_BRIDGE_SMRAM_D_OPEN) == false); /* reset */ - response = qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': {} }"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); + qtest_system_reset(qts); /* check open is settable again */ smram_set_bit(pcidev, MCH_HOST_BRIDGE_SMRAM_D_OPEN, false); @@ -194,7 +190,6 @@ static void test_smram_smbase_lock(void) { QPCIBus *pcibus; QPCIDevice *pcidev; - QDict *response; QTestState *qts; int i; @@ -237,10 +232,7 @@ static void test_smram_smbase_lock(void) } /* reset */ - response = qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': {} }"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); + qtest_system_reset(qts); /* check RAM at SMBASE is available after reset */ g_assert_cmpint(qtest_readb(qts, SMBASE), ==, SMRAM_TEST_PATTERN); diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 114f6bef273..2f7e75a3392 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -103,8 +103,7 @@ static void restart_qemu_or_continue(char *path) old_path = g_strdup(path); qtest_start(path); } else { /* if cmd line is the same, reset the guest */ - qobject_unref(qmp("{ 'execute': 'system_reset' }")); - qmp_eventwait("RESET"); + qtest_system_reset(global_qtest); } } diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c index c0686c7b306..3c6ea71febf 100644 --- a/tests/qtest/stm32l4x5_gpio-test.c +++ b/tests/qtest/stm32l4x5_gpio-test.c @@ -169,14 +169,6 @@ static uint32_t reset(uint32_t gpio, unsigned int offset) return 0x0; } -static void system_reset(void) -{ - QDict *r; - r = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); - g_assert_false(qdict_haskey(r, "error")); - qobject_unref(r); -} - static void test_idr_reset_value(void) { /* @@ -214,7 +206,7 @@ static void test_idr_reset_value(void) gpio_writel(GPIO_H, OTYPER, 0xDEADBEEF); gpio_writel(GPIO_H, PUPDR, 0xDEADBEEF); - system_reset(); + qtest_system_reset(global_qtest); uint32_t moder = gpio_readl(GPIO_A, MODER); uint32_t odr = gpio_readl(GPIO_A, ODR); diff --git a/tests/qtest/stm32l4x5_syscfg-test.c b/tests/qtest/stm32l4x5_syscfg-test.c index d5c71e2c0e7..376c80e31ca 100644 --- a/tests/qtest/stm32l4x5_syscfg-test.c +++ b/tests/qtest/stm32l4x5_syscfg-test.c @@ -47,14 +47,6 @@ static void syscfg_set_irq(int num, int level) qtest_set_irq_in(global_qtest, SOC, NULL, num, level); } -static void system_reset(void) -{ - QDict *response; - response = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); - g_assert(qdict_haskey(response, "return")); - qobject_unref(response); -} - static void test_reset(void) { /* @@ -182,7 +174,7 @@ static void test_set_only_bits(void) syscfg_writel(SYSCFG_SWPR2, 0x00000000); g_assert_cmphex(syscfg_readl(SYSCFG_SWPR2), ==, 0xFFFFFFFF); - system_reset(); + qtest_system_reset(global_qtest); } static void test_clear_only_bits(void) @@ -194,7 +186,7 @@ static void test_clear_only_bits(void) syscfg_writel(SYSCFG_CFGR1, 0x00000001); g_assert_cmphex(syscfg_readl(SYSCFG_CFGR1), ==, 0x00000000); - system_reset(); + qtest_system_reset(global_qtest); } static void test_interrupt(void) From patchwork Fri Nov 15 16:50:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 843509 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcc:0:b0:382:184f:390f with SMTP id e12csp946724wrc; Fri, 15 Nov 2024 08:52:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVkV3cGw1+5n1HvQBiF/pJCqhSCfj+AuHtMf2wCG9yT+Zh4rfXoE98Qs41m2+5V5rShiYizZw==@linaro.org X-Google-Smtp-Source: AGHT+IFudeD5JkvZjfqHYLBoQ0bxJUYvDpxIIpa+IEY4WBR68czwGXKCyy9547ehYvkENFbJiPJH X-Received: by 2002:a0c:f40a:0:b0:6cc:a17:ba65 with SMTP id 6a1803df08f44-6d3fb8a2e4fmr39692846d6.39.1731689521561; Fri, 15 Nov 2024 08:52:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731689521; cv=none; d=google.com; s=arc-20240605; b=aEK9k0c0eDx+I8nw/g1tC2KYgkLH2x6hdqM4WETG04JO5unCO7tfCYi9pFXcE7C3pE SyldAn5KZtOhwby82SqFZih+v6NNxN/kPeaMvg4+avsg9nPTkV1IMor5nyfSW0Fghjbm 5Nhg8NxW2Hpy7dseZddh2JuZ2Hvk8pmuBrVieYL/CefxOVO3uuQ4A++YbwEU+5kZTxor hSPrB+/FYc3pjvUuB4ppJRMzzyUzOtuoobGFGSzh8g1ME4/uk0oTjhoV3cLSXZF9E/o5 CrWo69ng/xN9vmUteFGLSzfC5e4U6gAR/NKbZscgUcYEfApZt0j2Fl03ktyAjQlcLtX/ 6vMw== 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=SGdMDfkgBn2W0Y27sTh83LY39xw1q9oPSugpDU4vMas=; fh=L+F+imk7SNxd+VJgpUcpWeNwCxrzN2ZHmlwvyOYjkVU=; b=C9o9UKssLhHWHexNDrnfyo/Vjo/0cduIZhOUZskvd9VCQqKryTNpLej8kUr/hRkZ/p PrQpH8S1UnoQnrZvNO09zwmakSn12yj5F+rcFGmwS8vz+Ce8RkJvbAME3CZD3ugfQYYu uhCcK/31QxRKsCOY3L+bEmY7D4d2B9Yt6BhgwC//TB9rEQREZQs6jXseaSdKJE6DgvU5 JnlBP00K/Tfi6d+DVzhu3LzfMVfa4BjOi9bRHWGUSD83n5CKgGkja/LTR6fLLJxfkMyW 6IcsC/XCKzTQAB9ezMjiMbfSK7VL7Ycp/wkk1ndJxqWaXJyM5zRwMLxk5ieqbN2dd0Mo etsg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cIGSaNnA; 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 6a1803df08f44-6d3ee8b79d2si43614646d6.223.2024.11.15.08.52.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Nov 2024 08:52:01 -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=cIGSaNnA; 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 1tBzX1-0007wE-J0; Fri, 15 Nov 2024 11:50:51 -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 1tBzWy-0007vE-UU for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:48 -0500 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBzWx-0003ar-3f for qemu-devel@nongnu.org; Fri, 15 Nov 2024 11:50:48 -0500 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-539f76a6f0dso960430e87.1 for ; Fri, 15 Nov 2024 08:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731689445; x=1732294245; 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=SGdMDfkgBn2W0Y27sTh83LY39xw1q9oPSugpDU4vMas=; b=cIGSaNnA4Huh60ctPtljhxPSGqS06KOwkijwEJea1Ez435RYEMrnuQ10NNc7eEHgI0 JDQniir8MtVhV/cm821vEG1784eAB6IjsgfjAviy6OGfU5/M7EYK+YbtlzaV/YDA/IWe 4ll6cJgKGLKk3K8R9NqgKdvyV5Npe7BoJC1ttr+9OjrsKcSmvUYnOYTlGeMqPnuqnKFD HBuyNW3T0Cim+sJbfIEQ7aAiakHqCdTP6OwrIcMMEb+Z2dJ0qGKx4X9wVCbPabSM2lW5 nTARnVqKRquIirYDo+JVHFTR+lazCihG+5L1V522h7MEt5rZTUzjBcAqikBB8yjb3EGN f5Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731689445; x=1732294245; 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=SGdMDfkgBn2W0Y27sTh83LY39xw1q9oPSugpDU4vMas=; b=Gv/uxaJQFfm1eHJ6K/+90YqBPmGVpfJDjEQzaiflGAH8AFqUbeZrHPI3R7cypL5Tex Mh7K/z3EecUNdh0GwpUuNU8mp6dIxl05hzzd5FCKlHXODC0TxCYFVlENyPSwT9L4XyDG 7VQ5L29h4E781SRp0RUL+xb5osucCCVxRp83pv7VX55wbtBDSprbUJzqXxAVzZelCw8A LjVewJkPkAnENAHWzQzPatcjFaDEsaIOpxs3MUZVJL/3KH6NawXk+L04SNocxDVpzEyc D6NJizYTCpwkN3uKxpIBNY5ZtKGgkpmPH9YT8qIFFmKGujJ9234IAIy/9lUSXU6MiPmC GhDQ== X-Gm-Message-State: AOJu0Yz/mER4hIOJ5+XXUWTj69Nwe3siGBAZ09XYVxs3MgJyxJQ8qRBQ j4yxKTqm097Rrpj72etEE3ZoeekVz+91HnnfKZ2P2TSAWBbUG1jAw9z75wnPLn8rXbTmMjm3/mI 2 X-Received: by 2002:a2e:a586:0:b0:2fb:593c:2bf2 with SMTP id 38308e7fff4ca-2ff6064e0d9mr19254301fa.3.1731689445369; Fri, 15 Nov 2024 08:50:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432dac0aef0sm60386405e9.28.2024.11.15.08.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 08:50:45 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Laurent Vivier , Paolo Bonzini , Roque Arcudia Hernandez Subject: [PATCH 3/3] tests/qtest: Use qtest_system_reset_nowait() where appropriate Date: Fri, 15 Nov 2024 16:50:41 +0000 Message-Id: <20241115165041.1148095-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241115165041.1148095-1-peter.maydell@linaro.org> References: <20241115165041.1148095-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12a.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 In the device and drive plug/unplug tests we want to trigger a system reset and then see if we get the appropriate DEVICE_DELETED event. Use qtest_system_reset_nowait() here. Signed-off-by: Peter Maydell Reviewed-by: Fabiano Rosas --- tests/qtest/device-plug-test.c | 11 +---------- tests/qtest/drive_del-test.c | 7 +------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c index c6f33153eb4..127a7f9efea 100644 --- a/tests/qtest/device-plug-test.c +++ b/tests/qtest/device-plug-test.c @@ -15,15 +15,6 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -static void system_reset(QTestState *qtest) -{ - QDict *resp; - - resp = qtest_qmp(qtest, "{'execute': 'system_reset'}"); - g_assert(qdict_haskey(resp, "return")); - qobject_unref(resp); -} - static void wait_device_deleted_event(QTestState *qtest, const char *id) { QDict *resp, *data; @@ -58,7 +49,7 @@ static void process_device_remove(QTestState *qtest, const char *id) * handled, removing the device. */ qtest_qmp_device_del_send(qtest, id); - system_reset(qtest); + qtest_system_reset_nowait(qtest); wait_device_deleted_event(qtest, id); } diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c index 7b67a4bbee4..99f6fc2de1b 100644 --- a/tests/qtest/drive_del-test.c +++ b/tests/qtest/drive_del-test.c @@ -154,15 +154,10 @@ static void device_add(QTestState *qts) static void device_del(QTestState *qts, bool and_reset) { - QDict *response; - qtest_qmp_device_del_send(qts, "dev0"); if (and_reset) { - response = qtest_qmp(qts, "{'execute': 'system_reset' }"); - g_assert(response); - g_assert(qdict_haskey(response, "return")); - qobject_unref(response); + qtest_system_reset_nowait(qts); } qtest_qmp_eventwait(qts, "DEVICE_DELETED");