[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/22] tests/qtest: Use qtest_system_reset() instead of open-coded
From: |
Fabiano Rosas |
Subject: |
[PULL 03/22] tests/qtest: Use qtest_system_reset() instead of open-coded versions |
Date: |
Thu, 12 Dec 2024 12:09:30 -0300 |
From: Peter Maydell <peter.maydell@linaro.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 <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
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)
--
2.35.3
- [PULL 00/22] QTest patches for 2024-12-12, Fabiano Rosas, 2024/12/12
- [PULL 02/22] tests/qtest: Add qtest_system_reset() utility function, Fabiano Rosas, 2024/12/12
- [PULL 01/22] tests/qtest: add TIMEOUT_MULTIPLIER, Fabiano Rosas, 2024/12/12
- [PULL 03/22] tests/qtest: Use qtest_system_reset() instead of open-coded versions,
Fabiano Rosas <=
- [PULL 04/22] tests/qtest: Use qtest_system_reset_nowait() where appropriate, Fabiano Rosas, 2024/12/12
- [PULL 05/22] tests/qtest/migration: Standardize hook names, Fabiano Rosas, 2024/12/12
- [PULL 06/22] tests/qtest/migration: Stop calling everything "test", Fabiano Rosas, 2024/12/12
- [PULL 07/22] tests/migration: Disambiguate guestperf vs. a-b, Fabiano Rosas, 2024/12/12
- [PULL 08/22] tests/qtest/migration: Move bootfile code to its own file, Fabiano Rosas, 2024/12/12
- [PULL 09/22] tests/qtest/migration: Move qmp helpers to a separate file, Fabiano Rosas, 2024/12/12
- [PULL 10/22] tests/qtest/migration: Rename migration-helpers.c, Fabiano Rosas, 2024/12/12
- [PULL 11/22] tests/qtest/migration: Move ufd_version_check to utils, Fabiano Rosas, 2024/12/12
- [PULL 12/22] tests/qtest/migration: Move kvm_dirty_ring_supported to utils, Fabiano Rosas, 2024/12/12
- [PULL 13/22] tests/qtest/migration: Isolate test initialization, Fabiano Rosas, 2024/12/12