aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/libqtest.c
diff options
context:
space:
mode:
authorDaniel P. Berrangé <berrange@redhat.com>2022-03-10 17:18:06 +0000
committerDr. David Alan Gilbert <dgilbert@redhat.com>2022-04-21 19:36:46 +0100
commitdcd23e9cae61f3156155db93ae699d30340158d9 (patch)
tree3679110c4d8bfa13469f2d0c8dbf93e17af4dcae /tests/qtest/libqtest.c
parenta17ec44dba741de97e63efcda28852e73fca06dc (diff)
tests: support QTEST_TRACE env variable
When debugging failing qtests it is useful to be able to turn on trace output to stderr. The QTEST_TRACE env variable contents get injected as a '-trace <str>' command line arg Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20220310171821.3724080-4-berrange@redhat.com> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'tests/qtest/libqtest.c')
-rw-r--r--tests/qtest/libqtest.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 2b9bdb947d..7db7ef3a68 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -259,6 +259,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
gchar *qmp_socket_path;
gchar *command;
const char *qemu_binary = qtest_qemu_binary();
+ const char *trace = g_getenv("QTEST_TRACE");
+ g_autofree char *tracearg = trace ?
+ g_strdup_printf("-trace %s ", trace) : g_strdup("");
s = g_new(QTestState, 1);
@@ -281,14 +284,15 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
qtest_add_abrt_handler(kill_qemu_hook_func, s);
- command = g_strdup_printf("exec %s "
+ command = g_strdup_printf("exec %s %s"
"-qtest unix:%s "
"-qtest-log %s "
"-chardev socket,path=%s,id=char0 "
"-mon chardev=char0,mode=control "
"-display none "
"%s"
- " -accel qtest", qemu_binary, socket_path,
+ " -accel qtest",
+ qemu_binary, tracearg, socket_path,
getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
qmp_socket_path,
extra_args ?: "");