@@ -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
new file mode 100755
@@ -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
new file mode 100644
@@ -0,0 +1,5 @@
+FROM centos:6
+RUN yum install -y \
+ git make gcc \
+ zlib-devel glib2-devel SDL-devel pixman-devel
+
new file mode 100644
@@ -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
+
new file mode 100755
@@ -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
new file mode 100644
@@ -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
+
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