From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4DUr-000315-Lt for qemu-devel@nongnu.org; Mon, 07 Jul 2014 14:18:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4DUh-0004Bv-Gh for qemu-devel@nongnu.org; Mon, 07 Jul 2014 14:18:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4DUh-0004Ap-8Q for qemu-devel@nongnu.org; Mon, 07 Jul 2014 14:18:27 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s67IIPY9020081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 7 Jul 2014 14:18:25 -0400 From: John Snow Date: Mon, 7 Jul 2014 14:17:43 -0400 Message-Id: <1404757089-4836-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1404757089-4836-1-git-send-email-jsnow@redhat.com> References: <1404757089-4836-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 02/28] libqtest: add QTEST_LOG for debugging qtest testcases List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, John Snow , stefanha@redhat.com, mst@redhat.com From: Paolo Bonzini Signed-off-by: Paolo Bonzini Signed-off-by: John Snow --- tests/libqtest.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 98e8f4b..4a75cd3 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -167,11 +167,12 @@ QTestState *qtest_init(const char *extra_args) if (s->qemu_pid == 0) { command = g_strdup_printf("exec %s " "-qtest unix:%s,nowait " - "-qtest-log /dev/null " + "-qtest-log %s " "-qmp unix:%s,nowait " "-machine accel=qtest " "-display none " "%s", qemu_binary, socket_path, + getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", qmp_socket_path, extra_args ?: ""); execlp("/bin/sh", "sh", "-c", command, NULL); @@ -358,6 +359,7 @@ static void qmp_response(JSONMessageParser *parser, QList *tokens) QDict *qtest_qmp_receive(QTestState *s) { QMPResponseParser qmp; + bool log = getenv("QTEST_LOG") != NULL; qmp.response = NULL; json_message_parser_init(&qmp.parser, qmp_response); @@ -375,6 +377,9 @@ QDict *qtest_qmp_receive(QTestState *s) exit(1); } + if (log) { + len = write(2, &c, 1); + } json_message_parser_feed(&qmp.parser, &c, 1); } json_message_parser_destroy(&qmp.parser); -- 1.9.3