Commit 7844cb2a6a for qemu.org
commit 7844cb2a6a4249916f94225dda908ce8db401e8e
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Wed Sep 2 17:50:26 2026 +0400
tests/drive_del-test: compile out HMP-dependent tests when !CONFIG_HMP
The compiled-out functions are actually testing HMP-specific commands
and behaviour which operate on the old "drive" concept. The QMP
equivalent for block-driver nodes are already tested.
If HMP goes away, those tests should go away too. Compile them out.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index cc52c2d879..cbf94d5b9f 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -87,6 +87,7 @@ static void blockdev_add_with_media(QTestState *qts)
g_assert(has_blockdev(qts));
}
+#ifdef CONFIG_HMP
static void drive_add(QTestState *qts)
{
char *resp = qtest_hmp(qts, "drive_add 0 if=none,id=drive0");
@@ -117,6 +118,7 @@ static void drive_del(QTestState *qts)
g_assert(!has_drive(qts));
g_free(resp);
}
+#endif
/*
* qvirtio_get_dev_type:
@@ -165,13 +167,9 @@ static void device_del(QTestState *qts, bool and_reset)
static void test_drive_without_dev(void)
{
+#ifdef CONFIG_HMP
QTestState *qts;
-#ifndef CONFIG_HMP
- g_test_skip("HMP not enabled");
- return;
-#endif
-
/* Start with an empty drive */
qts = qtest_init("-drive if=none,id=drive0 -M none");
@@ -184,19 +182,18 @@ static void test_drive_without_dev(void)
drive_add(qts);
qtest_quit(qts);
+#else
+ g_test_skip("HMP not enabled");
+#endif
}
static void test_after_failed_device_add(void)
{
+#ifdef CONFIG_HMP
char driver[32];
QDict *response;
QTestState *qts;
-#ifndef CONFIG_HMP
- g_test_skip("HMP not enabled");
- return;
-#endif
-
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
@@ -227,17 +224,16 @@ static void test_after_failed_device_add(void)
drive_add(qts);
qtest_quit(qts);
+#else
+ g_test_skip("HMP not enabled");
+#endif
}
static void test_drive_del_device_del(void)
{
+#ifdef CONFIG_HMP
QTestState *qts;
-#ifndef CONFIG_HMP
- g_test_skip("HMP not enabled");
- return;
-#endif
-
if (!has_device_builtin("virtio-scsi")) {
g_test_skip("Device virtio-scsi is not available");
return;
@@ -259,6 +255,9 @@ static void test_drive_del_device_del(void)
g_assert(!has_drive(qts));
qtest_quit(qts);
+#else
+ g_test_skip("HMP not enabled");
+#endif
}
static void test_cli_device_del(void)
@@ -416,15 +415,11 @@ static void test_device_add_and_del_q35(void)
static void test_drive_add_device_add_and_del(void)
{
+#ifdef CONFIG_HMP
QTestState *qts;
const char *arch = qtest_get_arch();
const char *machine_addition = "";
-#ifndef CONFIG_HMP
- g_test_skip("HMP not enabled");
- return;
-#endif
-
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
@@ -450,17 +445,16 @@ static void test_drive_add_device_add_and_del(void)
g_assert(!has_drive(qts));
qtest_quit(qts);
+#else
+ g_test_skip("HMP not enabled");
+#endif
}
static void test_drive_add_device_add_and_del_q35(void)
{
+#ifdef CONFIG_HMP
QTestState *qts;
-#ifndef CONFIG_HMP
- g_test_skip("HMP not enabled");
- return;
-#endif
-
if (!has_device_builtin("virtio-blk")) {
g_test_skip("Device virtio-blk is not available");
return;
@@ -479,6 +473,9 @@ static void test_drive_add_device_add_and_del_q35(void)
g_assert(!has_drive(qts));
qtest_quit(qts);
+#else
+ g_test_skip("HMP not enabled");
+#endif
}
static void test_blockdev_add_device_add_and_del(void)