diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2016-10-11 17:16:24 +0100 |
---|---|---|
committer | Fam Zheng <famz@redhat.com> | 2016-10-17 10:05:48 +0800 |
commit | e86c9a64f455018fb04d631e14c5f926e36c69fb (patch) | |
tree | cddfd44c7d4c08b7957499e9e6cf0d487987f007 /tests/docker | |
parent | 86a17cb3f43f987d0b2a65dd41284b4d6e2006cb (diff) | |
download | qemu-e86c9a64f455018fb04d631e14c5f926e36c69fb.zip qemu-e86c9a64f455018fb04d631e14c5f926e36c69fb.tar.gz qemu-e86c9a64f455018fb04d631e14c5f926e36c69fb.tar.bz2 |
tests/docker/Makefile.include: add a generic docker-run target
This re-factors the docker makefile to include a docker-run target which
can be controlled entirely from environment variables specified on the
make command line. This allows us to run against any given docker image
we may have in our repository, for example:
make docker-run TEST="test-quick" IMAGE="debian:arm64" \
EXECUTABLE=./aarch64-linux-user/qemu-aarch64
The existing docker-foo@bar targets still work but the inline
verification has been dropped because we already don't hit that due to
other pattern rules in rules.mak.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20161011161625.9070-5-alex.bennee@linaro.org>
Message-Id: <20161011161625.9070-6-alex.bennee@linaro.org>
[Squash in the verification removal patch. - Fam]
Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'tests/docker')
-rw-r--r-- | tests/docker/Makefile.include | 61 |
1 files changed, 38 insertions, 23 deletions
diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index b44daab..3f15d5a 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -78,6 +78,7 @@ docker: @echo ' "IMAGE" is one of the listed container name."' @echo ' docker-image: Build all images.' @echo ' docker-image-IMAGE: Build image "IMAGE".' + @echo ' docker-run: For manually running a "TEST" with "IMAGE"' @echo @echo 'Available container images:' @echo ' $(DOCKER_IMAGES)' @@ -101,31 +102,45 @@ docker: @echo ' NOCACHE=1 Ignore cache when build images.' @echo ' EXECUTABLE=<path> Include executable in image.' -docker-run-%: CMD = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\1/') -docker-run-%: IMAGE = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\2/') -docker-run-%: docker-qemu-src +# This rule if for directly running against an arbitrary docker target. +# It is called by the expanded docker targets (e.g. make +# docker-test-foo@bar) which will do additional verification. +# +# For example: make docker-run TEST="test-quick" IMAGE="debian:arm64" EXECUTABLE=./aarch64-linux-user/qemu-aarch64 +# +docker-run: docker-qemu-src @mkdir -p "$(DOCKER_CCACHE_DIR)" - @if test -z "$(IMAGE)" || test -z "$(CMD)"; \ - then echo "Invalid target"; exit 1; \ + @if test -z "$(IMAGE)" || test -z "$(TEST)"; \ + then echo "Invalid target $(IMAGE)/$(TEST)"; exit 1; \ fi - $(if $(filter $(TESTS),$(CMD)),$(if $(filter $(IMAGES),$(IMAGE)), \ - $(call quiet-command,\ - if $(SRC_PATH)/tests/docker/docker.py images | \ - awk '$$1=="qemu" && $$2=="$(IMAGE)"{found=1} END{exit(!found)}'; then \ - $(SRC_PATH)/tests/docker/docker.py run $(if $V,,--rm) \ - -t \ - $(if $(DEBUG),-i,--net=none) \ - -e TARGET_LIST=$(TARGET_LIST) \ - -e EXTRA_CONFIGURE_OPTS=$(EXTRA_CONFIGURE_OPTS) \ - -e V=$V -e J=$J -e DEBUG=$(DEBUG) -e SHOW_ENV=$(SHOW_ENV)\ - -e CCACHE_DIR=/var/tmp/ccache \ - -v $$(readlink -e $(DOCKER_SRC_COPY)):/var/tmp/qemu:z$(COMMA)ro \ - -v $(DOCKER_CCACHE_DIR):/var/tmp/ccache:z \ - qemu:$(IMAGE) \ - /var/tmp/qemu/run \ - $(CMD); \ - fi \ - ,"RUN","$(CMD) in $(IMAGE)"))) + $(if $(EXECUTABLE), \ + $(call quiet-command, \ + $(SRC_PATH)/tests/docker/docker.py update \ + $(IMAGE) $(EXECUTABLE), \ + " COPYING $(EXECUTABLE) to $(IMAGE)")) + $(call quiet-command, \ + $(SRC_PATH)/tests/docker/docker.py run \ + -t \ + $(if $V,,--rm) \ + $(if $(DEBUG),-i,--net=none) \ + -e TARGET_LIST=$(TARGET_LIST) \ + -e EXTRA_CONFIGURE_OPTS="$(EXTRA_CONFIGURE_OPTS)" \ + -e V=$V -e J=$J -e DEBUG=$(DEBUG) \ + -e SHOW_ENV=$(SHOW_ENV) \ + -e CCACHE_DIR=/var/tmp/ccache \ + -v $$(readlink -e $(DOCKER_SRC_COPY)):/var/tmp/qemu:z$(COMMA)ro \ + -v $(DOCKER_CCACHE_DIR):/var/tmp/ccache:z \ + $(IMAGE) \ + /var/tmp/qemu/run \ + $(TEST), " RUN $(TEST) in ${IMAGE}") + +# Run targets: +# +# Of the form docker-TEST-FOO@IMAGE-BAR which will then be expanded into a call to "make docker-run" +docker-run-%: CMD = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\1/') +docker-run-%: IMAGE = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\2/') +docker-run-%: + @$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE) docker-clean: $(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean) |