[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 31/37] tests/x86: Move common code to function in device-plug-test
From: |
Thomas Huth |
Subject: |
[PULL 31/37] tests/x86: Move common code to function in device-plug-test |
Date: |
Wed, 28 Sep 2022 09:18:37 +0200 |
From: Michael Labiuk <michael.labiuk@virtuozzo.com>
Move common code for device removing to function.
Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com>
Message-Id: <20220920104842.605530-2-michael.labiuk@virtuozzo.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/device-plug-test.c | 42 ++++++++++++++--------------------
1 file changed, 17 insertions(+), 25 deletions(-)
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index a1fb99c8ff..e595b45b66 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -61,6 +61,18 @@ static void wait_device_deleted_event(QTestState *qtest,
const char *id)
}
}
+static void process_device_remove(QTestState *qtest, const char *id)
+{
+ /*
+ * Request device removal. As the guest is not running, the request won't
+ * be processed. However during system reset, the removal will be
+ * handled, removing the device.
+ */
+ device_del(qtest, id);
+ system_reset(qtest);
+ wait_device_deleted_event(qtest, id);
+}
+
static void test_pci_unplug_request(void)
{
const char *arch = qtest_get_arch();
@@ -73,14 +85,7 @@ static void test_pci_unplug_request(void)
QTestState *qtest = qtest_initf("%s -device virtio-mouse-pci,id=dev0",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -98,14 +103,7 @@ static void test_pci_unplug_json_request(void)
"%s -device \"{'driver': 'virtio-mouse-pci', 'id': 'dev0'}\"",
machine_addition);
- /*
- * Request device removal. As the guest is not running, the request won't
- * be processed. However during system reset, the removal will be
- * handled, removing the device.
- */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -128,9 +126,7 @@ static void test_spapr_cpu_unplug_request(void)
"-device
power9_v2.0-spapr-cpu-core,core-id=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -144,9 +140,7 @@ static void test_spapr_memory_unplug_request(void)
"-device pc-dimm,id=dev0,memdev=mem0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
@@ -158,9 +152,7 @@ static void test_spapr_phb_unplug_request(void)
qtest = qtest_initf("-device spapr-pci-host-bridge,index=1,id=dev0");
/* similar to test_pci_unplug_request */
- device_del(qtest, "dev0");
- system_reset(qtest);
- wait_device_deleted_event(qtest, "dev0");
+ process_device_remove(qtest, "dev0");
qtest_quit(qtest);
}
--
2.31.1
- [PULL 17/37] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, (continued)
- [PULL 17/37] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32, Thomas Huth, 2022/09/28
- [PULL 23/37] tests/qtest: bios-tables-test: Adapt the case for win32, Thomas Huth, 2022/09/28
- [PULL 25/37] tests/qtest: ide-test: Open file in binary mode, Thomas Huth, 2022/09/28
- [PULL 29/37] tests/qtest: migration-test: Skip running some TLS cases for win32, Thomas Huth, 2022/09/28
- [PULL 08/37] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 14/37] tests/unit: test-image-locking: Avoid using hardcoded /tmp, Thomas Huth, 2022/09/28
- [PULL 37/37] docs/devel: testing: Document writing portable test cases, Thomas Huth, 2022/09/28
- [PULL 18/37] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only, Thomas Huth, 2022/09/28
- [PULL 19/37] tests/qtest: qmp-test: Skip running test_qmp_oob for win32, Thomas Huth, 2022/09/28
- [PULL 26/37] tests/qtest: virtio-net-failover: Disable migration tests for win32, Thomas Huth, 2022/09/28
- [PULL 31/37] tests/x86: Move common code to function in device-plug-test,
Thomas Huth <=
- Re: [PULL 00/37] qtests fixes, Stefan Hajnoczi, 2022/09/29