aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Labiuk <michael.labiuk@virtuozzo.com>2022-09-30 01:35:46 +0300
committerThomas Huth <thuth@redhat.com>2022-10-11 14:06:55 +0200
commiteb4440ef3aff1206be8e444db7962123bf85cec2 (patch)
tree8d04f6d42bc7eebc42f1a84894335cbfcc0cf287 /tests
parent5356d752ed9e1115c763b8d470812bb7dd912e54 (diff)
tests/x86: Add 'q35' machine type to drive_del-test
Configure pci bridge setting to run tests on 'q35' machine type. Signed-off-by: Michael Labiuk <michael.labiuk@virtuozzo.com> Message-Id: <20220929223547.1429580-9-michael.labiuk@virtuozzo.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/drive_del-test.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 106c613f4f..9a750395a9 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -252,6 +252,27 @@ static void test_cli_device_del(void)
qtest_quit(qts);
}
+static void test_cli_device_del_q35(void)
+{
+ QTestState *qts;
+
+ /*
+ * -drive/-device and device_del. Start with a drive used by a
+ * device that unplugs after reset.
+ */
+ qts = qtest_initf("-drive if=none,id=drive0,file=null-co://,"
+ "file.read-zeroes=on,format=raw "
+ "-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-device virtio-blk-%s,drive=drive0,bus=b1,id=dev0",
+ qvirtio_get_dev_type());
+
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_empty_device_del(void)
{
QTestState *qts;
@@ -288,6 +309,43 @@ static void test_device_add_and_del(void)
qtest_quit(qts);
}
+static void device_add_q35(QTestState *qts)
+{
+ g_autofree char *driver = g_strdup_printf("virtio-blk-%s",
+ qvirtio_get_dev_type());
+ QDict *response =
+ qtest_qmp(qts, "{'execute': 'device_add',"
+ " 'arguments': {"
+ " 'driver': %s,"
+ " 'drive': 'drive0',"
+ " 'id': 'dev0',"
+ " 'bus': 'b1'"
+ "}}", driver);
+ g_assert(response);
+ g_assert(qdict_haskey(response, "return"));
+ qobject_unref(response);
+}
+
+static void test_device_add_and_del_q35(void)
+{
+ QTestState *qts;
+
+ /*
+ * -drive/device_add and device_del. Start with a drive used by a
+ * device that unplugs after reset.
+ */
+ qts = qtest_initf("-machine q35 -device pcie-root-port,id=p1 "
+ "-device pcie-pci-bridge,bus=p1,id=b1 "
+ "-drive if=none,id=drive0,file=null-co://,"
+ "file.read-zeroes=on,format=raw");
+
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_drive_add_device_add_and_del(void)
{
QTestState *qts;
@@ -312,6 +370,25 @@ static void test_drive_add_device_add_and_del(void)
qtest_quit(qts);
}
+static void test_drive_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");
+
+ /*
+ * drive_add/device_add and device_del. The drive is used by a
+ * device that unplugs after reset.
+ */
+ drive_add_with_media(qts);
+ device_add_q35(qts);
+ device_del(qts, true);
+ g_assert(!has_drive(qts));
+
+ qtest_quit(qts);
+}
+
static void test_blockdev_add_device_add_and_del(void)
{
QTestState *qts;
@@ -336,6 +413,25 @@ 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 drive is used by a
+ * 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)
{
g_test_init(&argc, &argv, NULL);
@@ -357,6 +453,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 (qtest_has_machine("q35")) {
+ 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();