libqtest: add QTEST_LOG for debugging qtest testcases
authorMarc Marí <marc.mari.barcelo@gmail.com>
Tue, 12 Aug 2014 11:41:48 +0000 (13:41 +0200)
committerStefan Hajnoczi <stefanha@redhat.com>
Fri, 15 Aug 2014 17:03:14 +0000 (18:03 +0100)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/libqtest.c

index 0bf17aa..ed55686 100644 (file)
@@ -402,10 +402,14 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
 
     /* No need to send anything for an empty QObject.  */
     if (qobj) {
+        int log = getenv("QTEST_LOG") != NULL;
         QString *qstr = qobject_to_json(qobj);
         const char *str = qstring_get_str(qstr);
         size_t size = qstring_get_length(qstr);
 
+        if (log) {
+            fprintf(stderr, "%s", str);
+        }
         /* Send QMP request */
         socket_send(s->qmp_fd, str, size);