From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, jsnow@redhat.com,
stefanha@redhat.com, "Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
david@gibson.dropbear.id.au
Subject: [Qemu-devel] [RFC PATCH 1/4] tests: Introduce Docker based tests
Date: Wed, 3 Feb 2016 22:36:01 +0800 [thread overview]
Message-ID: <1454510164-6278-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1454510164-6278-1-git-send-email-famz@redhat.com>
A new group of targets to spawn docker instances for testing is added:
- "make docker" will spawn each available docker image and run all
available tests under tests/docker.
- "make docker-foo" will spawn image foo and run all available tests.
- "make docker X=bar" or "make docker-foo X=bar" will limit the tests to
only matching pattern "bar".
If the docker images (tagged like qemu:foo) don't exist, the make
command will automatically build them with foo.docker.
MAKEFLAGS is passed into the container.
Breaking down the tests/docker directory:
- *.docker in Dockerfile format define the environment in which tests
are run.
- *.sh are testing scripts to be executed by "run".
- "run" is the entry script to run inside the container.
- Anything else are indirectly used or documents.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
Makefile | 33 ++++++++++++++++++++++++++++++++-
tests/docker/basic.sh | 11 +++++++++++
tests/docker/centos6.docker | 5 +++++
tests/docker/fedora22.docker | 6 ++++++
tests/docker/run | 20 ++++++++++++++++++++
tests/docker/ubuntu.docker | 9 +++++++++
6 files changed, 83 insertions(+), 1 deletion(-)
create mode 100755 tests/docker/basic.sh
create mode 100644 tests/docker/centos6.docker
create mode 100644 tests/docker/fedora22.docker
create mode 100755 tests/docker/run
create mode 100644 tests/docker/ubuntu.docker
diff --git a/Makefile b/Makefile
index d0de2d4..91be64f 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR)
# Before including a proper config-host.mak, assume we are in the source tree
SRC_PATH=.
-UNCHECKED_GOALS := %clean TAGS cscope ctags
+UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-%
# All following code might depend on configuration variables
ifneq ($(wildcard config-host.mak),)
@@ -651,3 +651,34 @@ endif
# Include automatically generated dependency files
# Dependencies in Makefile.objs files come from our recursive subdir rules
-include $(wildcard *.d tests/*.d)
+
+# Detect the working docker command
+DOCKER = $(shell for cmd in "docker" "sudo -n docker"; do \
+ if $$cmd images &>/dev/null; then \
+ echo $$cmd; \
+ fi; done)
+
+docker: $(addprefix docker-,\
+ centos6 \
+ fedora22 \
+ ubuntu \
+ )
+docker-%: T=$(@:docker-%=%)
+docker-%:
+ @if test -z "$(DOCKER)"; then \
+ echo 'Docker not found.' \
+ 'Tried "docker" and "sudo -n docker"'; \
+ fi
+ @if ! $(DOCKER) inspect qemu:$T &>/dev/null; then \
+ $(DOCKER) build -t qemu:$T -f $(SRC_PATH)/tests/docker/$T.docker \
+ $(SRC_PATH)/tests/docker; \
+ fi
+ $(DOCKER) run --privileged -t -i --rm --net=none \
+ -e IMAGE_TAG=$T \
+ -e MAKEFLAGS="$(MAKEFLAGS)" \
+ -e X="$X" \
+ -v $$(realpath $(SRC_PATH)):/var/tmp/qemu \
+ -e QEMU_SRC=/var/tmp/qemu \
+ -v /var/tmp/qemu-docker-ccache:/var/tmp/ccache \
+ -e CCACHE_DIR=/var/tmp/ccache \
+ qemu:$T sh - /var/tmp/qemu/tests/docker/run
diff --git a/tests/docker/basic.sh b/tests/docker/basic.sh
new file mode 100755
index 0000000..e51b718
--- /dev/null
+++ b/tests/docker/basic.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+cd $(mktemp -d)
+mkdir build
+mkdir install
+cd build
+$QEMU_SRC/configure --target-list=x86_64-softmmu
+ --prefix="${pwd}/install"
+make $MAKEFLAGS
+make check $MAKEFLAGS
+make install
diff --git a/tests/docker/centos6.docker b/tests/docker/centos6.docker
new file mode 100644
index 0000000..802ca79
--- /dev/null
+++ b/tests/docker/centos6.docker
@@ -0,0 +1,5 @@
+FROM centos:6
+RUN yum install -y \
+ git make gcc \
+ zlib-devel glib2-devel SDL-devel pixman-devel
+
diff --git a/tests/docker/fedora22.docker b/tests/docker/fedora22.docker
new file mode 100644
index 0000000..5fd48d6
--- /dev/null
+++ b/tests/docker/fedora22.docker
@@ -0,0 +1,6 @@
+FROM fedora:22
+RUN dnf install -y \
+ ccache git mingw{32,64}-{pixman,glib2,gmp,SDL,pkg-config} \
+ glib2-devel pixman-devel zlib-devel SDL-devel \
+ gcc g++ clang make perl which bc findutils
+
diff --git a/tests/docker/run b/tests/docker/run
new file mode 100755
index 0000000..8267766
--- /dev/null
+++ b/tests/docker/run
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+# Prepare the environment
+. /etc/profile || true
+export PATH=/usr/lib/ccache:$PATH
+
+save=$QEMU_SRC
+QEMU_SRC=/var/tmp/qemu.tmp
+cp -r $save $QEMU_SRC
+
+filter_test()
+{
+ grep $(for p in ${X:-.}; do echo " -e $p"; done)
+}
+
+for t in $(cd $QEMU_SRC/tests/docker/; ls *.sh | filter_test); do
+ echo "Running $t ..."
+ $QEMU_SRC/tests/docker/$t || break
+done
diff --git a/tests/docker/ubuntu.docker b/tests/docker/ubuntu.docker
new file mode 100644
index 0000000..004201d
--- /dev/null
+++ b/tests/docker/ubuntu.docker
@@ -0,0 +1,9 @@
+FROM ubuntu:14.04
+RUN apt-get update
+RUN apt-get -y install \
+ libusb-1.0-0-dev libiscsi-dev librados-dev libncurses5-dev \
+ libseccomp-dev libgnutls-dev libssh2-1-dev libspice-server-dev \
+ libspice-protocol-dev libnss3-dev \
+ libgtk-3-dev libvte-2.90-dev libsdl1.2-dev libpng12-dev libpixman-1-dev \
+ git make ccache python-yaml gcc clang
+
--
2.4.3
next prev parent reply other threads:[~2016-02-03 14:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 14:36 [Qemu-devel] [RFC PATCH 0/4] tests: Introducing docker tests Fam Zheng
2016-02-03 14:36 ` Fam Zheng [this message]
2016-02-04 11:58 ` [Qemu-devel] [RFC PATCH 1/4] tests: Introduce Docker based tests Daniel P. Berrange
2016-02-05 6:17 ` Fam Zheng
2016-02-03 14:36 ` [Qemu-devel] [RFC PATCH 2/4] tests: Add clang docker test Fam Zheng
2016-02-03 14:36 ` [Qemu-devel] [RFC PATCH 3/4] tests: Add mingw 32/64 cross compiling Fam Zheng
2016-02-03 15:08 ` Stefan Weil
2016-02-04 2:29 ` Fam Zheng
2016-02-04 11:24 ` Paolo Bonzini
2016-02-03 16:14 ` Eric Blake
2016-02-04 2:28 ` Fam Zheng
2016-02-04 12:00 ` Daniel P. Berrange
2016-02-03 14:36 ` [Qemu-devel] [RFC PATCH 4/4] tests: Add travis container test case Fam Zheng
2016-02-03 15:24 ` [Qemu-devel] [RFC PATCH 0/4] tests: Introducing docker tests Stefan Hajnoczi
2016-02-04 2:43 ` Fam Zheng
2016-02-04 11:26 ` Paolo Bonzini
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=1454510164-6278-2-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=david@gibson.dropbear.id.au \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).