aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-09-04 11:25:13 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-09-04 11:25:13 +0100
commitd3714799718b78137f8a14bb1fc2ae28a163dca4 (patch)
tree69610d74cf45b032bb1971fa3bd5689237c85838 /tests
parent379d83f2c92879f4418aa9c57fd1fcbc3c82d384 (diff)
parent4112aff7cdd932f273e920911a45a5d5a2d5d299 (diff)
Merge remote-tracking branch 'remotes/stsquad/tags/pull-gdbstub-gitdm-testing-020919-1' into staging
Various maintainer updates - fixes for gdbstub regressions - bunch of gitdm/mailmap updates - module fixes for Travis - docker fixes for shippable # gpg: Signature made Mon 02 Sep 2019 11:19:04 BST # gpg: using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44 # gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full] # Primary key fingerprint: 6685 AE99 E751 67BC AFC8 DF35 FBD0 DB09 5A9E 2A44 * remotes/stsquad/tags/pull-gdbstub-gitdm-testing-020919-1: tests/docker: upgrade docker.py to python3 tests: fix modules-test with no default machine build-sys: build ui-spice-app as a module contrib/gitdm: Add RT-RK to the domain-map .mailmap/aliases: add some further commentary mailmap: Add many entries to improve 'git shortlog' statistics mailmap: Update philmd email address mailmap: Reorder by sections contrib/gitdm: Add armbru@pond.sub.org to group-map-redhat contrib/gitdm: filetype interface is not in order, fix gdbstub: Fix handler for 'F' packet gdbstub: Fix handling of '!' packet with new infra Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/docker/docker.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index ac5baab4ca..4bba29e104 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Docker controlling module
#
@@ -11,7 +11,6 @@
# or (at your option) any later version. See the COPYING file in
# the top-level directory.
-from __future__ import print_function
import os
import sys
import subprocess
@@ -25,10 +24,7 @@ import tempfile
import re
import signal
from tarfile import TarFile, TarInfo
-try:
- from StringIO import StringIO
-except ImportError:
- from io import StringIO
+from io import StringIO
from shutil import copy, rmtree
from pwd import getpwuid
from datetime import datetime, timedelta
@@ -62,11 +58,13 @@ USE_ENGINE = EngineEnum.AUTO
def _text_checksum(text):
"""Calculate a digest string unique to the text content"""
- return hashlib.sha1(text).hexdigest()
+ return hashlib.sha1(text.encode('utf-8')).hexdigest()
+def _read_dockerfile(path):
+ return open(path, 'rt', encoding='utf-8').read()
def _file_checksum(filename):
- return _text_checksum(open(filename, 'rb').read())
+ return _text_checksum(_read_dockerfile(filename))
def _guess_engine_command():
@@ -192,7 +190,7 @@ def _read_qemu_dockerfile(img_name):
df = os.path.join(os.path.dirname(__file__), "dockerfiles",
img_name + ".docker")
- return open(df, "r").read()
+ return _read_dockerfile(df)
def _dockerfile_preprocess(df):
@@ -262,6 +260,7 @@ class Docker(object):
def _output(self, cmd, **kwargs):
return subprocess.check_output(self._command + cmd,
stderr=subprocess.STDOUT,
+ encoding='utf-8',
**kwargs)
def inspect_tag(self, tag):
@@ -283,7 +282,9 @@ class Docker(object):
if argv is None:
argv = []
- tmp_df = tempfile.NamedTemporaryFile(dir=docker_dir, suffix=".docker")
+ tmp_df = tempfile.NamedTemporaryFile(mode="w+t",
+ encoding='utf-8',
+ dir=docker_dir, suffix=".docker")
tmp_df.write(dockerfile)
if user:
@@ -396,7 +397,7 @@ class BuildCommand(SubCommand):
help="Dockerfile name")
def run(self, args, argv):
- dockerfile = open(args.dockerfile, "rb").read()
+ dockerfile = _read_dockerfile(args.dockerfile)
tag = args.tag
dkr = Docker()
@@ -442,7 +443,7 @@ class BuildCommand(SubCommand):
cksum += [(filename, _file_checksum(filename))]
argv += ["--build-arg=" + k.lower() + "=" + v
- for k, v in os.environ.iteritems()
+ for k, v in os.environ.items()
if k.lower() in FILTERED_ENV_NAMES]
dkr.build_image(tag, docker_dir, dockerfile,
quiet=args.quiet, user=args.user, argv=argv,
@@ -611,7 +612,7 @@ class CheckCommand(SubCommand):
print("Need a dockerfile for tag:%s" % (tag))
return 1
- dockerfile = open(args.dockerfile, "rb").read()
+ dockerfile = _read_dockerfile(args.dockerfile)
if dkr.image_matches_dockerfile(tag, dockerfile):
if not args.quiet: