From nobody Sat Nov 23 17:54:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1731689489; cv=none; d=zohomail.com; s=zohoarc; b=EnFkjDY0nwjkvGj0tI7TuTHnv/gKFw3F6k+Ab3ddwC+dOa5Dbys0hhodynfUNntw7YQVMoHQXQExvu03AnyCEVyGWTgGyW6PZvm4CSfinUB5LRWqmskODKRszoC69KMBmwlNqIVYCv37OG8ERtQauta1bfYJRacMcsI46shHlFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731689489; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EKGJo6RL8JtSuOntPAnWTBPQ2/3pgYHRUszkLKiPvPw=; b=CyAPgRQGqmY/zfowHLJ1fQi6pv4ATqNAQanJW54lq40S6rndmZVg/U7zjVBnmi74cX0R8DicCJVwlzSEEvfIXztxYdccgPGeApT6vcaK398nKFMAsXitgvcBxufrbJdw61aV2/85ZLZZYEALsr5uOSRzqv4THmuZ2QYlW/eOiEE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731689489516717.4024971444456; Fri, 15 Nov 2024 08:51:29 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGNQMEGZ2dAEuSPnD2h5Q/zRWVKinQgSAb6NuUEiDyfAorc+LarszXBxeFm5Lcg0OvGQ06p3Q== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1731689489781116600 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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); =20 +/** + * 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 } =20 +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 !=3D -1) { --=20 2.34.1 From nobody Sat Nov 23 17:54:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1731689510; cv=none; d=zohomail.com; s=zohoarc; b=K8zu6ggn3XFDQyAbsc0kuNScqDfGrCB5c1/vv0Ep8RQ8pLivHuDwAmOVfNpcNEePocoRBCKPvtbJAzCLmJHf1eDdJVQH8CMUQDcxBV8dq2htfnPkvYfWkRaDcJ04m9Ais30RFa7CKtDdvWR8KedVhuffoji9oqmQetl324aZjbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731689510; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VXby9Lwvv6tS8EYvlf5Sy20J6KaSCeX254YtCAwIIqo=; b=QUfOFPnkBTGF1Kfg3bTdCEKXxqGGXPzUH08nZP6CYj2HzxtcwioT9dTadLs+ajSwCVgLGorRZJYmGvgTnAVxcH47+KBA2HubpDtq+2tnyyv9xvSQw925BhNvEPZ71zJPH4o46V/k4TC41pLLpPsjQ/IJ+F56Vf5x2c+T8yXH3Gc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731689510105405.0835891076006; Fri, 15 Nov 2024 08:51:50 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IF4E47ngh7oqY3fGn4sR/cBNSBhYq+NsUWfRmisCqPr253w8gD0Egu4FDh+o8QvxOyHFQRNRQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1731689512036116600 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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); =20 /* 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); =20 /* 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 =3D read_boot_order(qts); g_assert_cmphex(actual, =3D=3D, 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 =3D read_boot_order(qts); g_assert_cmphex(actual, =3D=3D, 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, co= nst char *devid, QTestState *qts; char *joined_args; QFWCFG *fw_cfg; - QDict *response; int i; =20 joined_args =3D g_strjoinv(" ", args->argv); @@ -913,13 +912,7 @@ static void test_override_hot_unplug(TestArgs *args, c= onst char *devid, /* unplug device an restart */ qtest_qmp_device_del_send(qts, devid); =20 - response =3D 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); =20 read_bootdevices(fw_cfg, expected2); =20 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; =20 qts =3D 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) =3D=3D f= alse); =20 /* reset */ - response =3D qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': = {} }"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); + qtest_system_reset(qts); =20 /* 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; =20 @@ -237,10 +232,7 @@ static void test_smram_smbase_lock(void) } =20 /* reset */ - response =3D qtest_qmp(qts, "{'execute': 'system_reset', 'arguments': = {} }"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); + qtest_system_reset(qts); =20 /* check RAM at SMBASE is available after reset */ g_assert_cmpint(qtest_readb(qts, SMBASE), =3D=3D, 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 =3D 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); } } =20 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 offs= et) return 0x0; } =20 -static void system_reset(void) -{ - QDict *r; - r =3D 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); =20 - system_reset(); + qtest_system_reset(global_qtest); =20 uint32_t moder =3D gpio_readl(GPIO_A, MODER); uint32_t odr =3D gpio_readl(GPIO_A, ODR); diff --git a/tests/qtest/stm32l4x5_syscfg-test.c b/tests/qtest/stm32l4x5_sy= scfg-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); } =20 -static void system_reset(void) -{ - QDict *response; - response =3D 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), =3D=3D, 0xFFFFFFFF); =20 - system_reset(); + qtest_system_reset(global_qtest); } =20 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), =3D=3D, 0x00000000); =20 - system_reset(); + qtest_system_reset(global_qtest); } =20 static void test_interrupt(void) --=20 2.34.1 From nobody Sat Nov 23 17:54:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1731689521; cv=none; d=zohomail.com; s=zohoarc; b=W3uj9POyycd5lLgyRkA4MqwysUP6ewHXYIrr7zgrVWQ84KTduedlHc6UTKlysqTLvzbh0eJLBNcWXKXLGwzK8Q+WEdMkXDkJVmQ0TLs2dfvU7WKKreyJwAoXbdwGTsTBqWy/KagnWotI2525GeK93Sj48ZeYMvkVqVBxPI1UxxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731689521; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SGdMDfkgBn2W0Y27sTh83LY39xw1q9oPSugpDU4vMas=; b=fqJjQKZ/HJd59wzqXoITdQWn+crH8K0RD2tmC5Vk2TT6lJg5vib4FhnsNhhcuyF7fxBx8EBhLzh6Oj+utU6wpsuD4Vk2XueN/xCROfGshaLJyjMrUpgjtYUVBq5cGYq6PNe2lbP1u6LI5LXMN1h0NtPkbOKYGvABpg1SHgHB6R8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731689521885983.736607314064; Fri, 15 Nov 2024 08:52:01 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IE5ME5xQRxlsulJq1uJy3/7WMYG7vxzmcEfHxDuQbHr78euWlsste4OI4UhVVhGLQvQuk/HYA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1731689523782116600 Content-Type: text/plain; charset="utf-8" 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" =20 -static void system_reset(QTestState *qtest) -{ - QDict *resp; - - resp =3D 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, cons= t 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); } =20 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) =20 static void device_del(QTestState *qts, bool and_reset) { - QDict *response; - qtest_qmp_device_del_send(qts, "dev0"); =20 if (and_reset) { - response =3D qtest_qmp(qts, "{'execute': 'system_reset' }"); - g_assert(response); - g_assert(qdict_haskey(response, "return")); - qobject_unref(response); + qtest_system_reset_nowait(qts); } =20 qtest_qmp_eventwait(qts, "DEVICE_DELETED"); --=20 2.34.1