tests/qtest/device-introspect-test: restrict test when !CONFIG_HMP
Wrap all HMP-dependent code paths in #ifdef CONFIG_HMP. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-17-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
56f0e41d1b16eb75d78ca9e89777f5b514122206
1 file changed
+30
-16
tests/qtest/device-introspect-test.c
+30
-16
@@ -11,10 +11,10 @@
11
*/
12
13
/*
14
- * Covers QMP device-list-properties and HMP device_add help. We
15
- * currently don't check that their output makes sense, only that QEMU
16
- * survives. Useful since we've had an astounding number of crash
17
- * bugs around here.
14
+ * Covers QMP device-list-properties and HMP device_add help (if
15
+ * CONFIG_HMP). We currently don't check that the output makes sense,
16
+ * only that QEMU survives. Useful since we've had an astounding
17
+ * number of crash bugs around here.
18
*/
19
20
#include "qemu/osdep.h"
@@ -154,8 +154,6 @@ static char *qom_tree_str(QTestState *qts)
154
static void test_one_device(QTestState *qts, const char *type)
155
{
156
QDict *resp;
157
- char *help, *escaped;
158
- GRegex *comma;
157
158
g_test_message("Testing device '%s'", type);
159
@@ -164,19 +162,21 @@ static void test_one_device(QTestState *qts, const char *type)
162
type);
163
qobject_unref(resp);
164
167
- comma = g_regex_new(",", 0, 0, NULL);
168
- escaped = g_regex_replace_literal(comma, type, -1, 0, ",,", 0, NULL);
169
- g_regex_unref(comma);
165
+#ifdef CONFIG_HMP
166
+ {
167
+ g_autofree char *escaped = NULL;
168
+ g_autoptr(GRegex) comma = NULL;
169
171
- help = qtest_hmp(qts, "device_add \"%s,help\"", escaped);
172
- g_free(help);
173
- g_free(escaped);
170
+ comma = g_regex_new(",", 0, 0, NULL);
171
+ escaped = g_regex_replace_literal(comma, type, -1, 0, ",,", 0, NULL);
172
+ g_free(qtest_hmp(qts, "device_add \"%s,help\"", escaped));
173
+ }
174
+#endif
175
}
176
177
static void test_device_intro_list(void)
178
{
179
QList *types;
179
- char *help;
180
QTestState *qts;
181
182
qts = qtest_init(common_args);
@@ -184,8 +184,11 @@ static void test_device_intro_list(void)
184
types = device_type_list(qts, true);
185
qobject_unref(types);
186
187
- help = qtest_hmp(qts, "device_add help");
188
- g_free(help);
187
+#ifdef CONFIG_HMP
188
+ {
189
+ g_free(qtest_hmp(qts, "device_add help"));
190
+ }
191
+#endif
192
193
qtest_quit(qts);
194
}
@@ -251,16 +254,20 @@ static void test_device_intro_none(void)
254
QTestState *qts = qtest_init(common_args);
255
g_autofree char *qom_tree_start = qom_tree_str(qts);
256
g_autofree char *qom_tree_end = NULL;
257
+#ifdef CONFIG_HMP
258
g_autofree char *qtree_start = qtest_hmp(qts, "info qtree");
259
g_autofree char *qtree_end = NULL;
260
+#endif
261
262
test_one_device(qts, "nonexistent");
263
264
/* Make sure that really nothing changed in the trees */
265
qom_tree_end = qom_tree_str(qts);
266
g_assert_cmpstr(qom_tree_start, ==, qom_tree_end);
267
+#ifdef CONFIG_HMP
268
qtree_end = qtest_hmp(qts, "info qtree");
269
g_assert_cmpstr(qtree_start, ==, qtree_end);
270
+#endif
271
272
qtest_quit(qts);
273
}
@@ -270,16 +277,20 @@ static void test_device_intro_abstract(void)
277
QTestState *qts = qtest_init(common_args);
278
g_autofree char *qom_tree_start = qom_tree_str(qts);
279
g_autofree char *qom_tree_end = NULL;
280
+#ifdef CONFIG_HMP
281
g_autofree char *qtree_start = qtest_hmp(qts, "info qtree");
282
g_autofree char *qtree_end = NULL;
283
+#endif
284
285
test_one_device(qts, "device");
286
287
/* Make sure that really nothing changed in the trees */
288
qom_tree_end = qom_tree_str(qts);
289
g_assert_cmpstr(qom_tree_start, ==, qom_tree_end);
290
+#ifdef CONFIG_HMP
291
qtree_end = qtest_hmp(qts, "info qtree");
292
g_assert_cmpstr(qtree_start, ==, qtree_end);
293
+#endif
294
295
qtest_quit(qts);
296
}
@@ -292,8 +303,10 @@ static void test_device_intro_concrete(const void *args)
303
QTestState *qts = qtest_init(args);
304
g_autofree char *qom_tree_start = qom_tree_str(qts);
305
g_autofree char *qom_tree_end = NULL;
306
+#ifdef CONFIG_HMP
307
g_autofree char *qtree_start = qtest_hmp(qts, "info qtree");
308
g_autofree char *qtree_end = NULL;
309
+#endif
310
311
types = device_type_list(qts, false);
312
@@ -311,9 +324,10 @@ static void test_device_intro_concrete(const void *args)
324
*/
325
qom_tree_end = qom_tree_str(qts);
326
g_assert_cmpstr(qom_tree_start, ==, qom_tree_end);
314
-
327
+#ifdef CONFIG_HMP
328
qtree_end = qtest_hmp(qts, "info qtree");
329
g_assert_cmpstr(qtree_start, ==, qtree_end);
330
+#endif
331
332
qobject_unref(types);
333
qtest_quit(qts);