On 20/09/2022 12.48, Michael Labiuk wrote:
Configure pci bridge setting to run tests on 'q35' machine type.
Signed-off-by: Michael Labiuk <michael.lab...@virtuozzo.com>
---
tests/qtest/drive_del-test.c | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 5e6d58b4dd..3a2ddecf22 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
...
@@ -294,6 +315,45 @@ static void test_device_add_and_del(void)
qtest_quit(qts);
}
+static void device_add_q35(QTestState *qts)
+{
+ QDict *response;
+ char driver[32];
+ snprintf(driver, sizeof(driver), "virtio-blk-%s",
+ qvirtio_get_dev_type());
array + snprintf is somewhat ugly, could you please either use
g_autofree char *driver = g_strdup_printf(...)
instead or ...
+ response = qtest_qmp(qts, "{'execute': 'device_add',"
+ " 'arguments': {"
+ " 'driver': %s,"
... simply use " 'driver': vrtio-blk-%s, " here?
+ " 'drive': 'drive0',"
+ " 'id': 'dev0',"
+ " 'bus': 'b1'"
+ "}}", driver);
+ g_assert(response);
+ g_assert(qdict_haskey(response, "return"));
+ qobject_unref(response);
+}
...
@@ -342,8 +421,29 @@ static void test_blockdev_add_device_add_and_del(void)
qtest_quit(qts);
}
+static void test_blockdev_add_device_add_and_del_q35(void)
+{
+ QTestState *qts;
+
+ qts = qtest_init("-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1");
+
+ /*
+ * blockdev_add/device_add and device_del. The it drive is used by a
s/The it drive/The drive/
+ * device that unplugs after reset, but it doesn't go away.
+ */
+ blockdev_add_with_media(qts);
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(has_blockdev(qts));
+
+ qtest_quit(qts);
+}
+
int main(int argc, char **argv)
{
+ const char *arch = qtest_get_arch();
+
g_test_init(&argc, &argv, NULL);
qtest_add_func("/drive_del/without-dev", test_drive_without_dev);
@@ -363,6 +463,17 @@ int main(int argc, char **argv)
test_empty_device_del);
qtest_add_func("/device_del/blockdev",
test_blockdev_add_device_add_and_del);
+
+ if (!strcmp(arch, "x86_64")) {
Please use qtest_has_machine("q35") instead again.
+ qtest_add_func("/device_del/drive/cli_device_q35",
+ test_cli_device_del_q35);
+ qtest_add_func("/device_del/drive/device_add_q35",
+ test_device_add_and_del_q35);
+ qtest_add_func("/device_del/drive/drive_add_device_add_q35",
+ test_drive_add_device_add_and_del_q35);
+ qtest_add_func("/device_del/blockdev_q35",
+ test_blockdev_add_device_add_and_del_q35);
+ }
}
return g_test_run();
Thomas