aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2019-09-04 10:07:17 +0100
committerAlex Bennée <alex.bennee@linaro.org>2019-09-10 09:38:33 +0100
commit71ebbe09e97894f4c573b8fd77e627530a4cba49 (patch)
treeb261f688e6bfd3f10316b67180c7ceaf519a30d1 /tests
parent63772d5cfda6e1dc1e9f2e17abda8c223fdbdd76 (diff)
tests/docker: fix "cc" command to work with podman
Podman requires a little bit of additional magic to the uid mapping which was already done for the normal RunCommand. We simplify the logic by pushing it directly into the Docker::run method to avoid instantiating an extra Docker() object and ensure the CC command always runs as the current user. Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/docker/docker.py26
-rw-r--r--tests/tcg/Makefile.include2
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 064026c8af..1620293ac8 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -318,10 +318,18 @@ class Docker(object):
return False
return checksum == _text_checksum(_dockerfile_preprocess(dockerfile))
- def run(self, cmd, keep, quiet):
+ def run(self, cmd, keep, quiet, as_user=False):
label = uuid.uuid1().hex
if not keep:
self._instances.append(label)
+
+ if as_user:
+ uid = os.getuid()
+ cmd = [ "-u", str(uid) ] + cmd
+ # podman requires a bit more fiddling
+ if self._command[0] == "podman":
+ argv.insert(0, '--userns=keep-id')
+
ret = self._do_check(["run", "--label",
"com.qemu.instance.uuid=" + label] + cmd,
quiet=quiet)
@@ -364,13 +372,8 @@ class RunCommand(SubCommand):
help="Run container using the current user's uid")
def run(self, args, argv):
- if args.run_as_current_user:
- uid = os.getuid()
- argv = [ "-u", str(uid) ] + argv
- docker = Docker()
- if docker._command[0] == "podman":
- argv.insert(0, '--userns=keep-id')
- return Docker().run(argv, args.keep, quiet=args.quiet)
+ return Docker().run(argv, args.keep, quiet=args.quiet,
+ as_user=args.run_as_current_user)
class BuildCommand(SubCommand):
@@ -554,8 +557,6 @@ class CcCommand(SubCommand):
help="The docker image in which to run cc")
parser.add_argument("--cc", default="cc",
help="The compiler executable to call")
- parser.add_argument("--user",
- help="The user-id to run under")
parser.add_argument("--source-path", "-s", nargs="*", dest="paths",
help="""Extra paths to (ro) mount into container for
reading sources""")
@@ -569,11 +570,10 @@ class CcCommand(SubCommand):
if args.paths:
for p in args.paths:
cmd += ["-v", "%s:%s:ro,z" % (p, p)]
- if args.user:
- cmd += ["-u", args.user]
cmd += [args.image, args.cc]
cmd += argv
- return Docker().command("run", cmd, args.quiet)
+ return Docker().run(cmd, False, quiet=args.quiet,
+ as_user=True)
class CheckCommand(SubCommand):
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
index 73b5626fc5..210f842823 100644
--- a/tests/tcg/Makefile.include
+++ b/tests/tcg/Makefile.include
@@ -41,7 +41,7 @@ ifneq ($(DOCKER_IMAGE),)
# We also need the Docker make rules to depend on
include $(SRC_PATH)/tests/docker/Makefile.include
-DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc --user $(shell id -u) \
+DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
--cc $(DOCKER_CROSS_COMPILER) \
-i qemu:$(DOCKER_IMAGE) \
-s $(SRC_PATH) -- "