iotests.py: QemuIoInteractive: print output on failure
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Wed, 1 Jul 2020 10:53:28 +0000 (13:53 +0300)
committerEric Blake <eblake@redhat.com>
Mon, 13 Jul 2020 14:01:01 +0000 (09:01 -0500)
Make it simpler to debug when qemu-io fails due to wrong arguments or
environment.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200701105331.121670-3-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
tests/qemu-iotests/iotests.py

index 109fb3884a2618e8696da8f6e7ee8593566adc1f..2a08fea3c9ec851b2687c1b8f736985e161f044a 100644 (file)
@@ -217,7 +217,13 @@ class QemuIoInteractive:
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT,
                                    universal_newlines=True)
-        assert self._p.stdout.read(9) == 'qemu-io> '
+        out = self._p.stdout.read(9)
+        if out != 'qemu-io> ':
+            # Most probably qemu-io just failed to start.
+            # Let's collect the whole output and exit.
+            out += self._p.stdout.read()
+            self._p.wait(timeout=1)
+            raise ValueError(out)
 
     def close(self):
         self._p.communicate('q\n')