From 855436dbf756014a024f3e415001ead37301ef95 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrangé" Date: Fri, 21 Apr 2023 18:14:06 +0100 Subject: tests/qtest: replace qmp_discard_response with qtest_qmp_assert_success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The qmp_discard_response method simply ignores the result of the QMP command, merely unref'ing the object. This is a bad idea for tests as it leaves no trace if the QMP command unexpectedly failed. The qtest_qmp_assert_success method will validate that the QMP command returned without error, and if errors occur, it will print a message on the console aiding debugging. Signed-off-by: Daniel P. Berrangé Message-Id: <20230421171411.566300-2-berrange@redhat.com> Reviewed-by: Juan Quintela Reviewed-by: Zhang Chen Signed-off-by: Thomas Huth --- tests/qtest/test-filter-mirror.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tests/qtest/test-filter-mirror.c') diff --git a/tests/qtest/test-filter-mirror.c b/tests/qtest/test-filter-mirror.c index 248fc88699..adeada3eb8 100644 --- a/tests/qtest/test-filter-mirror.c +++ b/tests/qtest/test-filter-mirror.c @@ -16,9 +16,6 @@ #include "qemu/error-report.h" #include "qemu/main-loop.h" -/* TODO actually test the results and get rid of this */ -#define qmp_discard_response(qs, ...) qobject_unref(qtest_qmp(qs, __VA_ARGS__)) - static void test_mirror(void) { int send_sock[2], recv_sock[2]; @@ -52,7 +49,7 @@ static void test_mirror(void) }; /* send a qmp command to guarantee that 'connected' is setting to true. */ - qmp_discard_response(qts, "{ 'execute' : 'query-status'}"); + qtest_qmp_assert_success(qts, "{ 'execute' : 'query-status'}"); ret = iov_send(send_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf)); g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size)); close(send_sock[0]); -- cgit 1.4.1