qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 4/4] tests/docker/Makefile.include: add a generic docker-run target
Date: Tue, 11 Oct 2016 18:12:20 +0800	[thread overview]
Message-ID: <20161011101220.GF5814@lemon> (raw)
In-Reply-To: <20161003163212.8101-5-alex.bennee@linaro.org>

On Mon, 10/03 17:32, Alex Bennée wrote:
> 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 <alex.bennee@linaro.org>

Actually I now realize we never use the verification for invalid tests and
images because of other implicit/pattern rules in rules.mak:

    $ make docker-test-quick@bar
      LD -r docker-test-quick@bar.mo
    /usr/bin/ld: no input files
    collect2: error: ld returned 1 exit status
    rules.mak:99: recipe for target 'docker-test-quick@bar.mo' failed
    make: *** [docker-test-quick@bar.mo] Error 1
    $ make docker-test-quick@bar^C
    $ make docker-test-foo@fedora
      LD -r docker-test-foo@fedora.mo
    /usr/bin/ld: no input files
    collect2: error: ld returned 1 exit status
    rules.mak:99: recipe for target 'docker-test-foo@fedora.mo' failed
    make: *** [docker-test-foo@fedora.mo] Error 1

Maybe we can simply get rid of that altogether? What do you think?

Fam

> 
> ---
> 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(-)
> 
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index 2fcc3c6..87735d8 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=<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 $(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)
> -- 
> 2.9.3
> 

  reply	other threads:[~2016-10-11 10:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-03 16:32 [Qemu-devel] [PATCH v2 0/4] generic docker run patches Alex Bennée
2016-10-03 16:32 ` [Qemu-devel] [PATCH v2 1/4] tests/docker: add travis dockerfile Alex Bennée
2016-10-03 16:32 ` [Qemu-devel] [PATCH v2 2/4] tests/docker: test-build script Alex Bennée
2016-10-11  8:31   ` Fam Zheng
2016-10-11  8:49     ` Alex Bennée
2016-10-11  9:55       ` Fam Zheng
2016-10-03 16:32 ` [Qemu-devel] [PATCH v2 3/4] tests/docker: make test-mingw honour TARGET_LIST Alex Bennée
2016-10-03 16:32 ` [Qemu-devel] [PATCH v2 4/4] tests/docker/Makefile.include: add a generic docker-run target Alex Bennée
2016-10-11 10:12   ` Fam Zheng [this message]
2016-10-11 15:44     ` Alex Bennée
2016-10-11  6:48 ` [Qemu-devel] [PATCH v2 0/4] generic docker run patches Alex Bennée
2016-10-11  8:03   ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161011101220.GF5814@lemon \
    --to=famz@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).