From patchwork Thu Dec 12 15:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 849733 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp980826wry; Thu, 12 Dec 2024 07:11:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU7JG2BHthwqyligf0iLx/9Numlu22dMtaS+Crf61N59riCylzCVze6XX6CfrhA89nJLFUYVg==@linaro.org X-Google-Smtp-Source: AGHT+IG2sb78DLhj5RIuhG1Rm04SzoEX4thimftVAHSzaf1q971hooegi/ZH6COEnWTbmrGlLSRD X-Received: by 2002:a05:6102:14a3:b0:4af:fc14:f138 with SMTP id ada2fe7eead31-4b257f66b1fmr1008420137.7.1734016295765; Thu, 12 Dec 2024 07:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734016295; cv=none; d=google.com; s=arc-20240605; b=TvJMFOhHwwRelC30SkEEdJtB3jkAe62etXO7CtEDtgmW4D9muK8XXT3RFMNMyFvwdA mJOdp+XVrykw/kZukErLcJ0NZv5A9SKnVG7I8tiiBRHAfe6noXYVSpQ9rJ+p9YLdf0tS NljbUYC7QsRu0ol/NrQ/gNrP7iAZsOpQSBfXI0Rt8A5ioyEDdr+VuGeCuHZHKfDO6j8k YH2TxQR+ce/OCJuwBwOT4sLVzH4Z9V35OoJ32aAc3aHSM/ZbESjKcOYYTKw9EkTZ/hW9 t83TLf+eASnP3rPvn4+MacKdM9j88FZi0hBv3Igha7c/dQIz/+qJoNKEq3uR6093CwNX ODFw== 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:dkim-signature:dkim-signature:dkim-signature; bh=EQndaw5sHoonjIqRW2sm/7RzQQ38owA3RD7Nq7q/xWI=; fh=alZCUczDNtN4yFLy44SM1yTUliPrh8AgZa0GP8izqo4=; b=YDTJmSU8KTR8IdncuX4hae5NYws0bsmrtIYLgXv9J4f3n9FuTg3zO5leSlHf1qFMka Y8QQPNH66X4K88iu+svMJxSYiTP7AX1jQE04mTCIR+T3d1+larrjod3lciAl4xHi1a3J dj50fxrU56nEerVQmvF2h5NcBhe8UOorFp2zA+TrYL/gSDaU9ppzDiUqXZjWKHvwc7JF TWjK+VhutaXCwSI+5DtP6dwX4S91+jBURtAExcx88AMCktBPaXO2IEtI83QZ7BksRe1D JOop6XsPDNFruGeDhwIEZxPk9F+YuwCuBYl9gjQHUKNUHSQyAOyZP8yZTZ9DMcXZf+V4 9aYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=o8QFwR47; dkim=neutral (no key) header.i=@nongnu.org header.s=susede2_ed25519 header.b=o0qXIl+z; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=o8QFwR47; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4aff01210fcsi1742456137.226.2024.12.12.07.11.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Dec 2024 07:11:35 -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=@suse.de header.s=susede2_rsa header.b=o8QFwR47; dkim=neutral (no key) header.i=@nongnu.org header.s=susede2_ed25519 header.b=o0qXIl+z; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=o8QFwR47; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLkpH-0003qu-T4; Thu, 12 Dec 2024 10:10:03 -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 1tLkpF-0003pc-Ry for qemu-devel@nongnu.org; Thu, 12 Dec 2024 10:10:01 -0500 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLkpD-0002ys-Os for qemu-devel@nongnu.org; Thu, 12 Dec 2024 10:10:01 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 196AB2110B; Thu, 12 Dec 2024 15:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734016198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EQndaw5sHoonjIqRW2sm/7RzQQ38owA3RD7Nq7q/xWI=; b=o8QFwR47RVGwBazFWT9fernsAY1jrAkWGmd5W8CUIyBGqBO4BSM5SvSGe8hFOWhWrtpWcY FclOBbDZHZDLqSO2x3ixf4yQUpqbYZ8PmDwC+gAD22M5i6sbe5OOJSw2G/0WZ/PBwIwL6m Mlva8N/DPS8816OivJIS8xZ1qqGJyeo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734016198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EQndaw5sHoonjIqRW2sm/7RzQQ38owA3RD7Nq7q/xWI=; b=o0qXIl+zjQVZiqi+AlhByq7p57mLHuJ6T6qgykeQBiIYWLypZNlYRSsoOu/eXzXxXlsORG T3rJi8haO8v/DhDg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1734016198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EQndaw5sHoonjIqRW2sm/7RzQQ38owA3RD7Nq7q/xWI=; b=o8QFwR47RVGwBazFWT9fernsAY1jrAkWGmd5W8CUIyBGqBO4BSM5SvSGe8hFOWhWrtpWcY FclOBbDZHZDLqSO2x3ixf4yQUpqbYZ8PmDwC+gAD22M5i6sbe5OOJSw2G/0WZ/PBwIwL6m Mlva8N/DPS8816OivJIS8xZ1qqGJyeo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1734016198; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EQndaw5sHoonjIqRW2sm/7RzQQ38owA3RD7Nq7q/xWI=; b=o0qXIl+zjQVZiqi+AlhByq7p57mLHuJ6T6qgykeQBiIYWLypZNlYRSsoOu/eXzXxXlsORG T3rJi8haO8v/DhDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E02F213508; Thu, 12 Dec 2024 15:09:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gEzYKMT8WmcTfQAAD6G6ig (envelope-from ); Thu, 12 Dec 2024 15:09:56 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL 03/22] tests/qtest: Use qtest_system_reset() instead of open-coded versions Date: Thu, 12 Dec 2024 12:09:30 -0300 Message-Id: <20241212150949.16806-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241212150949.16806-1-farosas@suse.de> References: <20241212150949.16806-1-farosas@suse.de> MIME-Version: 1.0 X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, linaro.org:email, suse.de:mid, suse.de:email] Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, 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 From: Peter Maydell 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é Signed-off-by: Fabiano Rosas --- 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 16d0ffbdf6..6035ec2c61 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 c67b8cfe16..4c851c2cdb 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 85eb8d7668..1c73dea8f7 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 c922d81bc0..7f58fc3746 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 114f6bef27..2f7e75a339 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 c0686c7b30..3c6ea71feb 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 d5c71e2c0e..376c80e31c 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)