libqtest: fail if child coredumps
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 24 May 2018 14:24:35 +0000 (17:24 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 25 May 2018 14:08:39 +0000 (17:08 +0300)
Right now tests report OK status if QEMU crashes during cleanup.
Let's catch that case and fail the test.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Thomas Huth <thuth@redhat.com>
tests/libqtest.c

index 43fb97e0353bea82d3a4aa7e398e486fc4eb511b..f8698548498ec2a8b621b61badb10b9e987a71f3 100644 (file)
@@ -103,8 +103,15 @@ static int socket_accept(int sock)
 static void kill_qemu(QTestState *s)
 {
     if (s->qemu_pid != -1) {
+        int wstatus = 0;
+        pid_t pid;
+
         kill(s->qemu_pid, SIGTERM);
-        waitpid(s->qemu_pid, NULL, 0);
+        pid = waitpid(s->qemu_pid, &wstatus, 0);
+
+        if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
+            assert(!WCOREDUMP(wstatus));
+        }
     }
 }