Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-16 Thread Alex Bennée

Fam Zheng  writes:

> On Mon, 02/15 14:10, Alex Bennée wrote:
>>
>> Fam Zheng  writes:
>>
>> > On Mon, 02/15 12:45, Alex Bennée wrote:
>> >>
>> >> Alex Bennée  writes:
>> >>
>> >> > Fam Zheng  writes:
>> >> >
>> >> >> It's better to have a launcher for all tests, to make it easier to
>> >> >> initialize and manage the environment.
>> >> >>
>> >> >> Signed-off-by: Fam Zheng 
>> >> >> ---
>> >> >>  tests/docker/run | 23 +++
>> >> >>  1 file changed, 23 insertions(+)
>> >> >>  create mode 100755 tests/docker/run
>> >> >>
>> 
>> >> OK that won't work if you have alternates in your git setup. It seems to
>> >> me the creation of the pristine tree for docker should be done before we
>> >> enter the docker environment.
>> >>
>> >> There is a slight wrinkle as to what happens if the user wants to enter
>> >> an interactive session for debugging. However that doesn't seem possible
>> >> via the makefile and perhaps that is just as well. Perhaps that should
>> >> be a helper script for the user?
>> >
>> > We can use "make distclean" in the copied tree.
>>
>> I wouldn't - distclean isn't always that clean due to *mumble mumble*
>> makefile reasons. You could try this approach:
>>
>> commit f838d3bbe2f71c731dfe172f1c3286084de203c8
>> Author: Alex Bennée 
>> Date:   Mon Feb 15 12:52:21 2016 +
>>
>> tests/docker/Makefile.include: snapshot the src for docker
>>
>> Instead of providing a live version of the source tree to the docker
>> container we snapshot it with git-archive. This ensure the tree is in a
>> pristine state for whatever operations the container is going to run on
>> them.
>>
>> Uncommitted changes known to files known by the git index will be
>> included in the snapshot if there are any.
>>
>> Signed-off-by: Alex Bennée 
>>
>> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
>> index ca84c35..63a799c 100644
>> --- a/tests/docker/Makefile.include
>> +++ b/tests/docker/Makefile.include
>> @@ -2,7 +2,7 @@
>>
>>  $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak))
>>
>> -.PHONY: docker docker-build docker-run docker-clean
>> +.PHONY: docker docker-build docker-qemu-src docker-run docker-clean
>>
>>  DOCKER_SUFFIX = .docker
>>
>> @@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS))
>>  TESTS ?= %
>>  IMAGES ?= %
>>
>> +docker-qemu-src:
>> +$(if git diff-index --quiet HEAD --,
>> \
>> +git archive -1 HEAD --prefix=qemu-docker-snapshot/ 
>> --format=tar.gz | tar -xz -C /tmp,   \
>> +git archive -1 `git stash create` 
>> --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp)
>
> Does this clutter the user's git stash list? Or we can just error out if the
> working tree is not clean.

No it doesn't, it is a temporary dangling object, quoth the manual:

   create
   Create a stash (which is a regular commit object) and return its 
object name, without storing it anywhere in the ref
   namespace. This is intended to be useful for scripts. It is probably 
not the command you want to use; see "save" above.

>
> Fam


--
Alex Bennée



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Fam Zheng
On Mon, 02/15 14:10, Alex Bennée wrote:
> 
> Fam Zheng  writes:
> 
> > On Mon, 02/15 12:45, Alex Bennée wrote:
> >>
> >> Alex Bennée  writes:
> >>
> >> > Fam Zheng  writes:
> >> >
> >> >> It's better to have a launcher for all tests, to make it easier to
> >> >> initialize and manage the environment.
> >> >>
> >> >> Signed-off-by: Fam Zheng 
> >> >> ---
> >> >>  tests/docker/run | 23 +++
> >> >>  1 file changed, 23 insertions(+)
> >> >>  create mode 100755 tests/docker/run
> >> >>
> 
> >> OK that won't work if you have alternates in your git setup. It seems to
> >> me the creation of the pristine tree for docker should be done before we
> >> enter the docker environment.
> >>
> >> There is a slight wrinkle as to what happens if the user wants to enter
> >> an interactive session for debugging. However that doesn't seem possible
> >> via the makefile and perhaps that is just as well. Perhaps that should
> >> be a helper script for the user?
> >
> > We can use "make distclean" in the copied tree.
> 
> I wouldn't - distclean isn't always that clean due to *mumble mumble*
> makefile reasons. You could try this approach:
> 
> commit f838d3bbe2f71c731dfe172f1c3286084de203c8
> Author: Alex Bennée 
> Date:   Mon Feb 15 12:52:21 2016 +
> 
> tests/docker/Makefile.include: snapshot the src for docker
> 
> Instead of providing a live version of the source tree to the docker
> container we snapshot it with git-archive. This ensure the tree is in a
> pristine state for whatever operations the container is going to run on
> them.
> 
> Uncommitted changes known to files known by the git index will be
> included in the snapshot if there are any.
> 
> Signed-off-by: Alex Bennée 
> 
> diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
> index ca84c35..63a799c 100644
> --- a/tests/docker/Makefile.include
> +++ b/tests/docker/Makefile.include
> @@ -2,7 +2,7 @@
> 
>  $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak))
> 
> -.PHONY: docker docker-build docker-run docker-clean
> +.PHONY: docker docker-build docker-qemu-src docker-run docker-clean
> 
>  DOCKER_SUFFIX = .docker
> 
> @@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS))
>  TESTS ?= %
>  IMAGES ?= %
> 
> +docker-qemu-src:
> + $(if git diff-index --quiet HEAD --,
> \
> + git archive -1 HEAD --prefix=qemu-docker-snapshot/ 
> --format=tar.gz | tar -xz -C /tmp,   \
> + git archive -1 `git stash create` 
> --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp)

Does this clutter the user's git stash list? Or we can just error out if the
working tree is not clean.

Fam



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Fam Zheng
On Mon, 02/15 14:10, Alex Bennée wrote:
> >> There is a slight wrinkle as to what happens if the user wants to enter
> >> an interactive session for debugging. However that doesn't seem possible
> >> via the makefile and perhaps that is just as well. Perhaps that should
> >> be a helper script for the user?

Good idea.  The "docker run" invocation should be able to drop stdio into an
interactive shell, with Makefile. I'll take a look in v2.

Fam



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Alex Bennée

Fam Zheng  writes:

> On Mon, 02/15 12:45, Alex Bennée wrote:
>>
>> Alex Bennée  writes:
>>
>> > Fam Zheng  writes:
>> >
>> >> It's better to have a launcher for all tests, to make it easier to
>> >> initialize and manage the environment.
>> >>
>> >> Signed-off-by: Fam Zheng 
>> >> ---
>> >>  tests/docker/run | 23 +++
>> >>  1 file changed, 23 insertions(+)
>> >>  create mode 100755 tests/docker/run
>> >>

>> OK that won't work if you have alternates in your git setup. It seems to
>> me the creation of the pristine tree for docker should be done before we
>> enter the docker environment.
>>
>> There is a slight wrinkle as to what happens if the user wants to enter
>> an interactive session for debugging. However that doesn't seem possible
>> via the makefile and perhaps that is just as well. Perhaps that should
>> be a helper script for the user?
>
> We can use "make distclean" in the copied tree.

I wouldn't - distclean isn't always that clean due to *mumble mumble*
makefile reasons. You could try this approach:

commit f838d3bbe2f71c731dfe172f1c3286084de203c8
Author: Alex Bennée 
Date:   Mon Feb 15 12:52:21 2016 +

tests/docker/Makefile.include: snapshot the src for docker

Instead of providing a live version of the source tree to the docker
container we snapshot it with git-archive. This ensure the tree is in a
pristine state for whatever operations the container is going to run on
them.

Uncommitted changes known to files known by the git index will be
included in the snapshot if there are any.

Signed-off-by: Alex Bennée 

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index ca84c35..63a799c 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -2,7 +2,7 @@

 $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak))

-.PHONY: docker docker-build docker-run docker-clean
+.PHONY: docker docker-build docker-qemu-src docker-run docker-clean

 DOCKER_SUFFIX = .docker

@@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS))
 TESTS ?= %
 IMAGES ?= %

+docker-qemu-src:
+   $(if git diff-index --quiet HEAD --,
\
+   git archive -1 HEAD --prefix=qemu-docker-snapshot/ 
--format=tar.gz | tar -xz -C /tmp,   \
+   git archive -1 `git stash create` 
--prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp)
+
 $(foreach i,$(DOCKER_IMAGES), \
$(eval docker-build: docker-build-$i) \
$(foreach t,$(DOCKER_SCRIPTS), \
$(eval docker-build-$i docker-run-$t@$i: IMAGE=$i) \
$(eval docker-run-$t@$i: SCRIPT=$t) \
-   $(eval docker-run-$t@$i: docker-build-$i) \
+   $(eval docker-run-$t@$i: docker-build-$i docker-qemu-src) \
$(if $(filter test-%,$t), \
$(eval docker-run: docker-run-$t@$i) \
$(eval docker-run-$t@: docker-run-$t@$i) \
@@ -74,7 +79,7 @@ docker-run-%:
$(call quiet-command,\
$(SRC_PATH)/tests/docker/docker_run \
--privileged -t --rm --net=none \
-   -v $$(realpath $(SRC_PATH)):/var/tmp/qemu \
+   -v $$(realpath 
/tmp/qemu-docker-snapshot/):/var/tmp/qemu \
-e QEMU_SRC=/var/tmp/qemu \
-e V=$(V) \
-v /var/tmp/qemu-docker-ccache:/var/tmp/ccache \


>
> Fam


--
Alex Bennée



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Fam Zheng
On Mon, 02/15 12:45, Alex Bennée wrote:
> 
> Alex Bennée  writes:
> 
> > Fam Zheng  writes:
> >
> >> It's better to have a launcher for all tests, to make it easier to
> >> initialize and manage the environment.
> >>
> >> Signed-off-by: Fam Zheng 
> >> ---
> >>  tests/docker/run | 23 +++
> >>  1 file changed, 23 insertions(+)
> >>  create mode 100755 tests/docker/run
> >>
> >> diff --git a/tests/docker/run b/tests/docker/run
> >> new file mode 100755
> >> index 000..739ecf9
> >> --- /dev/null
> >> +++ b/tests/docker/run
> >> @@ -0,0 +1,23 @@
> >> +#!/bin/bash -e
> >> +#
> >> +# Docker test runner
> >> +#
> >> +# Copyright (c) 2016 Red Hat Inc.
> >> +#
> >> +# Authors:
> >> +#  Fam Zheng 
> >> +#
> >> +# This work is licensed under the terms of the GNU GPL, version 2
> >> +# or (at your option) any later version. See the COPYING file in
> >> +# the top-level directory.
> >> +
> >> +# Prepare the environment
> >> +. /etc/profile || true
> >> +export PATH=/usr/lib/ccache:$PATH
> >> +
> >> +tmp=$QEMU_SRC
> >> +QEMU_SRC=/var/tmp/qemu.tmp
> >> +cp -r $tmp $QEMU_SRC
> >
> > The first time I ran the fedora target it seems to hang, the second time
> > with V=1 it reported my source tree was an in-tree build.
> >
> > Could we perhaps use git-archive to grab a pristine copy of the tree?
> > Something like:
> >
> > STATUS=`git stash create`
> > git archive -1 ${STATUS} -o ${TAR}
> >
> > Would give a clean source tree with current unstaged/uncommited files.
> > Unfortunately this wouldn't include new files yet to be committed in any
> > form to the source tree but using git stash save -u might include a
> > bunch of unwanted stuff.
> 
> OK that won't work if you have alternates in your git setup. It seems to
> me the creation of the pristine tree for docker should be done before we
> enter the docker environment.
> 
> There is a slight wrinkle as to what happens if the user wants to enter
> an interactive session for debugging. However that doesn't seem possible
> via the makefile and perhaps that is just as well. Perhaps that should
> be a helper script for the user?

We can use "make distclean" in the copied tree.

Fam



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Alex Bennée

Alex Bennée  writes:

> Fam Zheng  writes:
>
>> It's better to have a launcher for all tests, to make it easier to
>> initialize and manage the environment.
>>
>> Signed-off-by: Fam Zheng 
>> ---
>>  tests/docker/run | 23 +++
>>  1 file changed, 23 insertions(+)
>>  create mode 100755 tests/docker/run
>>
>> diff --git a/tests/docker/run b/tests/docker/run
>> new file mode 100755
>> index 000..739ecf9
>> --- /dev/null
>> +++ b/tests/docker/run
>> @@ -0,0 +1,23 @@
>> +#!/bin/bash -e
>> +#
>> +# Docker test runner
>> +#
>> +# Copyright (c) 2016 Red Hat Inc.
>> +#
>> +# Authors:
>> +#  Fam Zheng 
>> +#
>> +# This work is licensed under the terms of the GNU GPL, version 2
>> +# or (at your option) any later version. See the COPYING file in
>> +# the top-level directory.
>> +
>> +# Prepare the environment
>> +. /etc/profile || true
>> +export PATH=/usr/lib/ccache:$PATH
>> +
>> +tmp=$QEMU_SRC
>> +QEMU_SRC=/var/tmp/qemu.tmp
>> +cp -r $tmp $QEMU_SRC
>
> The first time I ran the fedora target it seems to hang, the second time
> with V=1 it reported my source tree was an in-tree build.
>
> Could we perhaps use git-archive to grab a pristine copy of the tree?
> Something like:
>
> STATUS=`git stash create`
> git archive -1 ${STATUS} -o ${TAR}
>
> Would give a clean source tree with current unstaged/uncommited files.
> Unfortunately this wouldn't include new files yet to be committed in any
> form to the source tree but using git stash save -u might include a
> bunch of unwanted stuff.

OK that won't work if you have alternates in your git setup. It seems to
me the creation of the pristine tree for docker should be done before we
enter the docker environment.

There is a slight wrinkle as to what happens if the user wants to enter
an interactive session for debugging. However that doesn't seem possible
via the makefile and perhaps that is just as well. Perhaps that should
be a helper script for the user?

>
>> +
>> +cd $QEMU_SRC/tests/docker
>> +"$@"


--
Alex Bennée



Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-15 Thread Alex Bennée

Fam Zheng  writes:

> It's better to have a launcher for all tests, to make it easier to
> initialize and manage the environment.
>
> Signed-off-by: Fam Zheng 
> ---
>  tests/docker/run | 23 +++
>  1 file changed, 23 insertions(+)
>  create mode 100755 tests/docker/run
>
> diff --git a/tests/docker/run b/tests/docker/run
> new file mode 100755
> index 000..739ecf9
> --- /dev/null
> +++ b/tests/docker/run
> @@ -0,0 +1,23 @@
> +#!/bin/bash -e
> +#
> +# Docker test runner
> +#
> +# Copyright (c) 2016 Red Hat Inc.
> +#
> +# Authors:
> +#  Fam Zheng 
> +#
> +# This work is licensed under the terms of the GNU GPL, version 2
> +# or (at your option) any later version. See the COPYING file in
> +# the top-level directory.
> +
> +# Prepare the environment
> +. /etc/profile || true
> +export PATH=/usr/lib/ccache:$PATH
> +
> +tmp=$QEMU_SRC
> +QEMU_SRC=/var/tmp/qemu.tmp
> +cp -r $tmp $QEMU_SRC

The first time I ran the fedora target it seems to hang, the second time
with V=1 it reported my source tree was an in-tree build.

Could we perhaps use git-archive to grab a pristine copy of the tree?
Something like:

STATUS=`git stash create`
git archive -1 ${STATUS} -o ${TAR}

Would give a clean source tree with current unstaged/uncommited files.
Unfortunately this wouldn't include new files yet to be committed in any
form to the source tree but using git stash save -u might include a
bunch of unwanted stuff.

> +
> +cd $QEMU_SRC/tests/docker
> +"$@"


--
Alex Bennée



[Qemu-devel] [PATCH 04/12] docker: Add test runner

2016-02-05 Thread Fam Zheng
It's better to have a launcher for all tests, to make it easier to
initialize and manage the environment.

Signed-off-by: Fam Zheng 
---
 tests/docker/run | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100755 tests/docker/run

diff --git a/tests/docker/run b/tests/docker/run
new file mode 100755
index 000..739ecf9
--- /dev/null
+++ b/tests/docker/run
@@ -0,0 +1,23 @@
+#!/bin/bash -e
+#
+# Docker test runner
+#
+# Copyright (c) 2016 Red Hat Inc.
+#
+# Authors:
+#  Fam Zheng 
+#
+# This work is licensed under the terms of the GNU GPL, version 2
+# or (at your option) any later version. See the COPYING file in
+# the top-level directory.
+
+# Prepare the environment
+. /etc/profile || true
+export PATH=/usr/lib/ccache:$PATH
+
+tmp=$QEMU_SRC
+QEMU_SRC=/var/tmp/qemu.tmp
+cp -r $tmp $QEMU_SRC
+
+cd $QEMU_SRC/tests/docker
+"$@"
-- 
2.4.3