From patchwork Mon Oct 17 02:10:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 77707 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp195186qge; Sun, 16 Oct 2016 19:17:15 -0700 (PDT) X-Received: by 10.237.34.240 with SMTP id q45mr20710246qtc.136.1476670635200; Sun, 16 Oct 2016 19:17:15 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w3si16645648qkc.12.2016.10.16.19.17.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 16 Oct 2016 19:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:58527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvxUI-0000zb-PS for patch@linaro.org; Sun, 16 Oct 2016 22:17:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvxNs-0005Gk-SY for qemu-devel@nongnu.org; Sun, 16 Oct 2016 22:10:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvxNr-0005rf-NE for qemu-devel@nongnu.org; Sun, 16 Oct 2016 22:10:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bvxNr-0005rY-DQ for qemu-devel@nongnu.org; Sun, 16 Oct 2016 22:10:35 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BCFD1C0467CE; Mon, 17 Oct 2016 02:10:34 +0000 (UTC) Received: from lemon.redhat.com (vpn1-7-207.pek2.redhat.com [10.72.7.207]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9H2AMoc013336; Sun, 16 Oct 2016 22:10:33 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2016 10:10:22 +0800 Message-Id: <1476670222-31642-5-git-send-email-famz@redhat.com> In-Reply-To: <1476670222-31642-1-git-send-email-famz@redhat.com> References: <1476670222-31642-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 17 Oct 2016 02:10:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 4/4] tests/docker/Makefile.include: add a generic docker-run target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Fam Zheng Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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 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 --- tests/docker/Makefile.include | 61 +++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 23 deletions(-) -- 2.7.4 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= Include executable in image.' +# 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 "$(TEST)"; \ + then echo "Invalid target $(IMAGE)/$(TEST)"; exit 1; \ + fi + $(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-%: docker-qemu-src - @mkdir -p "$(DOCKER_CCACHE_DIR)" - @if test -z "$(IMAGE)" || test -z "$(CMD)"; \ - then echo "Invalid target"; 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)"))) +docker-run-%: + @$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE) docker-clean: $(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean)