tests/qtest/qmp-test: don't depend on human-monitor-command
The test was using 'human-monitor-command' (which requires HMP) to verify that an integer 'id' is echoed back on failure. Replace with 'query-name' for the success case and 'block_resize' (missing required args) for the failure case, so the test works regardless of HMP availability. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-13-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
cf73236a684f61ffc8b441b78a7da4b99ee79a27
1 file changed
+11
-2
tests/qtest/qmp-test.c
+11
-2
@@ -151,9 +151,14 @@ static void test_qmp_protocol(void)
151
g_assert_cmpstr(qdict_get_try_str(resp, "id"), ==, "cookie#1");
152
qobject_unref(resp);
153
154
- /* Test command failure with 'id' */
155
- resp = qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2 }");
154
+ /* Test integer 'id' is echoed back on success */
155
+ resp = qtest_qmp(qts, "{ 'execute': 'query-name', 'id': 2 }");
156
g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
157
+ qobject_unref(resp);
158
+
159
+ /* Test integer 'id' is echoed back on failure */
160
+ resp = qtest_qmp(qts, "{ 'execute': 'block_resize', 'id': 3 }");
161
+ g_assert_cmpint(qdict_get_int(resp, "id"), ==, 3);
162
qmp_expect_error_and_unref(resp, "GenericError");
163
164
qtest_quit(qts);
@@ -487,6 +492,7 @@ static void test_qmp_monitor_remove_cli(void)
492
qtest_quit(qts);
493
}
494
495
+#ifdef CONFIG_HMP
496
static void test_qmp_monitor_remove_hmp(void)
497
{
498
QTestState *qts;
@@ -504,6 +510,7 @@ static void test_qmp_monitor_remove_hmp(void)
510
511
qtest_quit(qts);
512
}
513
+#endif
514
515
int main(int argc, char *argv[])
516
{
@@ -521,7 +528,9 @@ int main(int argc, char *argv[])
528
qtest_add_func("qmp/monitor-chardev-in-use",
529
test_qmp_monitor_chardev_in_use);
530
qtest_add_func("qmp/monitor-remove-cli", test_qmp_monitor_remove_cli);
531
+#ifdef CONFIG_HMP
532
qtest_add_func("qmp/monitor-remove-hmp", test_qmp_monitor_remove_hmp);
533
+#endif
534
535
return g_test_run();
536
}