Skip to contentSkip to conversation

libqtest: dump child invocation when QTEST_LOG set

PATCH In review Alex Bennée 2 participants 3 messages May 4, 2016 – Aug 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libqtest: dump child invocation when QTEST_LOG set

The QTEST_LOG environment is used for debugging qtest interactions with a child process. When it is defined we now also dump the invocation line to stderr to make it easier for people to see how QEMU was invoked.

---
 tests/libqtest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/libqtest.c +5 -1
index b12a9e4..dd94abf 100644
@@ -171,6 +171,7 @@ QTestState *qtest_init(const char *extra_args)
 
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
+        bool qtest_log = getenv("QTEST_LOG");
         setenv("QEMU_AUDIO_DRV", "none", true);
         command = g_strdup_printf("exec %s "
                                   "-qtest unix:%s,nowait "
@@ -179,9 +180,12 @@ QTestState *qtest_init(const char *extra_args)
                                   "-machine accel=qtest "
                                   "-display none "
                                   "%s", qemu_binary, socket_path,
-                                  getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
+                                  qtest_log ? "/dev/fd/2" : "/dev/null",
                                   qmp_socket_path,
                                   extra_args ?: "");
+        if (qtest_log) {
+            fprintf(stderr, "%s\n", command);
+        }
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 26 lines · Alex Bennée

The QTEST_LOG environment is used for debugging qtest interactions with a child process. When it is defined we now also dump the invocation line to stderr to make it easier for people to see how QEMU was invoked.

---
 tests/libqtest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/libqtest.c +1 -0
index b12a9e4..dd94abf 100644
@@ -171,6 +171,7 @@ QTestState *qtest_init(const char *extra_args)
 
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
+        bool qtest_log = getenv("QTEST_LOG");
         setenv("QEMU_AUDIO_DRV", "none", true);
         command = g_strdup_printf("exec %s "
                                   "-qtest unix:%s,nowait "
@@ -179,9 +180,12 @@ QTestState *qtest_init(const char *extra_args)
                                   "-machine accel=qtest "
                                   "-display none "
                                   "%s", qemu_binary, socket_path,

tests/libqtest.c QTestState *qtest_init(const char *extra_args) · line 191

Quoted 10 lines
tests/libqtest.c +4 -1
-                                  getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
+                                  qtest_log ? "/dev/fd/2" : "/dev/null",
                                   qmp_socket_path,
                                   extra_args ?: "");
+        if (qtest_log) {
+            fprintf(stderr, "%s\n", command);
+        }
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }

Ping?

--
Alex Bennée

Reviewed-by
#2 lore raw
Quoted 42 lines · Alex Bennée
Quoted 26 lines · Alex Bennée

The QTEST_LOG environment is used for debugging qtest interactions with a child process. When it is defined we now also dump the invocation line to stderr to make it easier for people to see how QEMU was invoked.

---
 tests/libqtest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/libqtest.c +1 -0
index b12a9e4..dd94abf 100644
@@ -171,6 +171,7 @@ QTestState *qtest_init(const char *extra_args)
 
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
+        bool qtest_log = getenv("QTEST_LOG");
         setenv("QEMU_AUDIO_DRV", "none", true);
         command = g_strdup_printf("exec %s "
                                   "-qtest unix:%s,nowait "
@@ -179,9 +180,12 @@ QTestState *qtest_init(const char *extra_args)
                                   "-machine accel=qtest "
                                   "-display none "
                                   "%s", qemu_binary, socket_path,

tests/libqtest.c QTestState *qtest_init(const char *extra_args) · line 191

Quoted 10 lines
tests/libqtest.c +4 -1
-                                  getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
+                                  qtest_log ? "/dev/fd/2" : "/dev/null",
                                   qmp_socket_path,
                                   extra_args ?: "");
+        if (qtest_log) {
+            fprintf(stderr, "%s\n", command);
+        }
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }

Ping?

Quoted 3 lines

--
Alex Bennée

I guess nobody owns qtest specifically...
Paolo? Peter?

--js