[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/15] docker.py: Improve subprocess exit code handli
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PULL 14/15] docker.py: Improve subprocess exit code handling |
Date: |
Mon, 17 Jul 2017 11:48:24 +0800 |
A few error handlings are missing because we ignore the subprocess exit
code, for example "docker build" errors are currently ignored.
Introduce _do_check() aside the existing _do() method and use it in a
few places.
Signed-off-by: Fam Zheng <address@hidden>
Message-Id: <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
---
tests/docker/docker.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index f5ac86b..ee40ca0 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -117,6 +117,11 @@ class Docker(object):
kwargs["stdout"] = DEVNULL
return subprocess.call(self._command + cmd, **kwargs)
+ def _do_check(self, cmd, quiet=True, **kwargs):
+ if quiet:
+ kwargs["stdout"] = DEVNULL
+ return subprocess.check_call(self._command + cmd, **kwargs)
+
def _do_kill_instances(self, only_known, only_active=True):
cmd = ["ps", "-q"]
if not only_active:
@@ -175,14 +180,14 @@ class Docker(object):
extra_files_cksum)))
tmp_df.flush()
- self._do(["build", "-t", tag, "-f", tmp_df.name] + argv + \
- [docker_dir],
- quiet=quiet)
+ self._do_check(["build", "-t", tag, "-f", tmp_df.name] + argv + \
+ [docker_dir],
+ quiet=quiet)
def update_image(self, tag, tarball, quiet=True):
"Update a tagged image using "
- self._do(["build", "-t", tag, "-"], quiet=quiet, stdin=tarball)
+ self._do_check(["build", "-t", tag, "-"], quiet=quiet, stdin=tarball)
def image_matches_dockerfile(self, tag, dockerfile):
try:
@@ -195,9 +200,9 @@ class Docker(object):
label = uuid.uuid1().hex
if not keep:
self._instances.append(label)
- ret = self._do(["run", "--label",
- "com.qemu.instance.uuid=" + label] + cmd,
- quiet=quiet)
+ ret = self._do_check(["run", "--label",
+ "com.qemu.instance.uuid=" + label] + cmd,
+ quiet=quiet)
if not keep:
self._instances.remove(label)
return ret
--
2.9.4
- [Qemu-devel] [PULL 04/15] vpc: make it thread-safe, (continued)
- [Qemu-devel] [PULL 04/15] vpc: make it thread-safe, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 05/15] vvfat: make it thread-safe, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 06/15] qed: move tail of qed_aio_write_main to qed_aio_write_{cow, alloc}, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 08/15] qed: introduce bdrv_qed_init_state, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 07/15] block: invoke .bdrv_drain callback in coroutine context and from AioContext, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 09/15] qed: protect table cache with CoMutex, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 12/15] docker: Don't enable networking as a side-effect of DEBUG=1, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 13/15] docker.py: Drop infile parameter, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 11/15] ssh: support I/O from any AioContext, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 10/15] sheepdog: add queue_lock, Fam Zheng, 2017/07/16
- [Qemu-devel] [PULL 14/15] docker.py: Improve subprocess exit code handling,
Fam Zheng <=
- [Qemu-devel] [PULL 15/15] travis: add no-TCG build, Fam Zheng, 2017/07/16
- Re: [Qemu-devel] [PULL 00/15] Block and testing patches, Peter Maydell, 2017/07/17