From patchwork Tue Oct 11 16:16:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 77498 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp76748qge; Tue, 11 Oct 2016 09:22:50 -0700 (PDT) X-Received: by 10.55.35.201 with SMTP id j192mr3823237qkj.190.1476202970537; Tue, 11 Oct 2016 09:22:50 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g8si1798227qka.164.2016.10.11.09.22.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Oct 2016 09:22:50 -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; dkim=fail header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzpK-0005OA-07 for patch@linaro.org; Tue, 11 Oct 2016 12:22:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzjO-0001cJ-U7 for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btzjM-0001vN-8e for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:16:41 -0400 Received: from mail-qk0-x22d.google.com ([2607:f8b0:400d:c09::22d]:36646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btzjM-0001v2-2q for qemu-devel@nongnu.org; Tue, 11 Oct 2016 12:16:40 -0400 Received: by mail-qk0-x22d.google.com with SMTP id o68so43048672qkf.3 for ; Tue, 11 Oct 2016 09:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+vaD81iBFSv1Xrb2h6XfQVBkz97rUaCtG9xYIBDtPFY=; b=A2tCawRo7xVK18eitjBcqmWpo+3oNlr5d+YzlLglsVCtXuZBLNHBJnKoU19xaP5T+e pw03JefxM5NMFYIQRKWbghWXDwqxFEr1JIQxp6KrLcI+WUoEIHHCD25NlfLjDyBl0Gso I2JUKvUuSy7A1WrMPBNFsblCXLh8oRjG1M1lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+vaD81iBFSv1Xrb2h6XfQVBkz97rUaCtG9xYIBDtPFY=; b=a53MpRFlBtEPtl2N0NmTCo+EzZnMbQT9yzC+huohUr+Qvwh53FcU23PgQhzYhCCMY4 vJlLiB7e5bkce6WVM+9DPYZOGmH/6xs67k+7pP4ND3+1+VrHtClShQFxnWmEY8hLaeAw 0UubQOQMwC54mALd9Pf3HBiY2hKdlTpjYJanuMbTliuDeUFDrYNI98MHVOIRzTN9iRBa pebEphKnDdLCuIh+Hye57QS47Rk+80Qu9I2HKP+6l0ap9Mbd4ABDCkicQc7rLbhoWICJ Yf/Z9t6v4tK+omjYyPyvgXc1HOvezm79NObmDRWffKE318IbrjYsOhV8sNhblDdrhMBR M8cg== X-Gm-Message-State: AA6/9Rn2N5NLzKuo1xgZEP61w8s3Q97L33TIf+5kiBK1W+g7kHbv67T64Fv0lOIDkBftZjyE X-Received: by 10.194.201.227 with SMTP id kd3mr5960120wjc.74.1476202599543; Tue, 11 Oct 2016 09:16:39 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id c7sm7590341wjk.19.2016.10.11.09.16.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Oct 2016 09:16:37 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 86CB13E0562; Tue, 11 Oct 2016 17:16:36 +0100 (BST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: famz@redhat.com Date: Tue, 11 Oct 2016 17:16:24 +0100 Message-Id: <20161011161625.9070-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161011161625.9070-1-alex.bennee@linaro.org> References: <20161011161625.9070-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::22d Subject: [Qemu-devel] [PATCH v3 4/5] 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 shunted into other target prerequisites before a sub-make is invoked for the docker-run target. Signed-off-by: Alex Bennée --- NB: I dropped the awk magic that verifies the image exists before running. I couldn't get the thing to work in my shell so wasn't quite sure what it was doing. v2 - fix spelling on arbitrary - document docker-run in help - add note on docker.py update - reduce noise on verifying other images - revert back to using filter - fix merge conflict --- tests/docker/Makefile.include | 89 ++++++++++++++++++++++++++++++++----------- 1 file changed, 66 insertions(+), 23 deletions(-) -- 2.9.3 diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index b44daab..ba7c984 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,73 @@ docker: @echo ' NOCACHE=1 Ignore cache when build images.' @echo ' EXECUTABLE= 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 $(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}") + +# +# Verification targets +# +# These targets help verify the test (CMD) and docker tag (IMAGE) are +# part of the built in set of tests and images. You can still call the +# docker-run target directly for testsing against arbitary images. +# + +docker-verify-image-%: IMAGE = $(shell echo '$@' | sed -e 's/docker-verify-image-\([^@]*\)@\(.*\)/\2/') +docker-verify-image-%: + @if test -z "$(IMAGE)"; \ + then echo "Invalid image"; 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 $(filter $(IMAGE), $(DOCKER_IMAGES)), , \ + echo "$(IMAGE) is not a known image"; exit 1) \ + +docker-verify-test-%: CMD = $(shell echo '$@' | sed -e 's/docker-verify-test-\([^@]*\)@\(.*\)/\1/') +docker-verify-test-%: + @if test -z "$(CMD)"; \ + then echo "Invalid test"; exit 1; \ + fi + $(if $(filter $(CMD), $(DOCKER_TESTS)), , \ + echo "$(CMD) is not a known test"; exit 1) + +# Run targets +# +# This will take a target such as docker-test-foo@bar and verify that: +# - the test test-foo is a known test +# - the image bar is a known image +# +# It will then call the 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-verify-image-% docker-verify-test-% + @make docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE) docker-clean: $(call quiet-command, $(SRC_PATH)/tests/docker/docker.py clean)