From 61793a627d10908715eac2fc4a25b724f43e8fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 29 Oct 2018 18:57:09 +0400 Subject: [PATCH 1/3] tests: add qmp/missing-any-arg test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_qmp_missing_any_arg() is about a bug in infrastructure used by the QMP core, fixed in commit c489780203. We covered the bug in infrastructure unit tests (commit bce3035a44). Let's test it at the QMP level as well. Signed-off-by: Marc-André Lureau Reviewed-by: Thomas Huth Reviewed-by: Markus Armbruster [thuth: Tweaked the commit message according to Markus' suggestion] Signed-off-by: Thomas Huth --- tests/qmp-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 6c419f6023..7517be4654 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -318,6 +318,19 @@ static void test_qmp_preconfig(void) qtest_quit(qs); } +static void test_qmp_missing_any_arg(void) +{ + QTestState *qts; + QDict *resp; + + qts = qtest_init(common_args); + resp = qtest_qmp(qts, "{'execute': 'qom-set', 'arguments':" + " { 'path': '/machine', 'property': 'rtc-time' } }"); + g_assert_nonnull(resp); + qmp_assert_error_class(resp, "GenericError"); + qtest_quit(qts); +} + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -325,6 +338,7 @@ int main(int argc, char *argv[]) qtest_add_func("qmp/protocol", test_qmp_protocol); qtest_add_func("qmp/oob", test_qmp_oob); qtest_add_func("qmp/preconfig", test_qmp_preconfig); + qtest_add_func("qmp/missing-any-arg", test_qmp_missing_any_arg); return g_test_run(); } From 3b6b0a8ae7b437256aba3b44643a7a608d54b916 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 13 Nov 2018 16:03:21 +0100 Subject: [PATCH 2/3] tests/ide: Free pcibus when finishing a test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once a test has finished, the pcibus structure should be freed, to avoid leaking memory and to make sure that the structure is properly re-initialized when the next test starts. Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: John Snow Signed-off-by: Thomas Huth --- tests/ide-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ide-test.c b/tests/ide-test.c index 33cef61e1f..f0280e636b 100644 --- a/tests/ide-test.c +++ b/tests/ide-test.c @@ -142,6 +142,10 @@ static void ide_test_start(const char *cmdline_fmt, ...) static void ide_test_quit(void) { + if (pcibus) { + qpci_free_pc(pcibus); + pcibus = NULL; + } pc_alloc_uninit(guest_malloc); guest_malloc = NULL; qtest_end(); From ced09f9b07e425690d3bfe524cf93c4dbf4b26bc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 15 Nov 2018 13:29:30 +0100 Subject: [PATCH 3/3] qtest: log QEMU command line Record the command line that was used to start QEMU. This can be useful for debugging. Signed-off-by: Paolo Bonzini Reviewed-by: Laurent Vivier [thuth: removed trailing \n from the message string] Signed-off-by: Thomas Huth --- tests/libqtest.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 44ce118cfc..75e07e16e7 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -215,24 +215,28 @@ QTestState *qtest_init_without_qmp_handshake(bool use_oob, qtest_add_abrt_handler(kill_qemu_hook_func, s); + command = g_strdup_printf("exec %s " + "-qtest unix:%s,nowait " + "-qtest-log %s " + "-chardev socket,path=%s,nowait,id=char0 " + "-mon chardev=char0,mode=control%s " + "-machine accel=qtest " + "-display none " + "%s", qemu_binary, socket_path, + getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", + qmp_socket_path, use_oob ? ",x-oob=on" : "", + extra_args ?: ""); + + g_test_message("starting QEMU: %s", command); + s->qemu_pid = fork(); if (s->qemu_pid == 0) { setenv("QEMU_AUDIO_DRV", "none", true); - command = g_strdup_printf("exec %s " - "-qtest unix:%s,nowait " - "-qtest-log %s " - "-chardev socket,path=%s,nowait,id=char0 " - "-mon chardev=char0,mode=control%s " - "-machine accel=qtest " - "-display none " - "%s", qemu_binary, socket_path, - getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", - qmp_socket_path, use_oob ? ",x-oob=on" : "", - extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); } + g_free(command); s->fd = socket_accept(sock); if (s->fd >= 0) { s->qmp_fd = socket_accept(qmpsock);