From patchwork Wed Feb 3 14:36:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8203821 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 85A939F3CD for ; Wed, 3 Feb 2016 14:36:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B66F62027D for ; Wed, 3 Feb 2016 14:36:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D44E820279 for ; Wed, 3 Feb 2016 14:36:30 +0000 (UTC) Received: from localhost ([::1]:35355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQyXm-00019R-5s for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Feb 2016 09:36:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQyXZ-00017G-V6 for qemu-devel@nongnu.org; Wed, 03 Feb 2016 09:36:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQyXW-0000Cg-6r for qemu-devel@nongnu.org; Wed, 03 Feb 2016 09:36:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQyXV-0000CX-VJ for qemu-devel@nongnu.org; Wed, 03 Feb 2016 09:36:14 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 975503824ED; Wed, 3 Feb 2016 14:36:13 +0000 (UTC) Received: from fam-t430.nay.redhat.com (dhcp-15-42.nay.redhat.com [10.66.15.42]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u13Ea603002913; Wed, 3 Feb 2016 09:36:10 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 3 Feb 2016 22:36:01 +0800 Message-Id: <1454510164-6278-2-git-send-email-famz@redhat.com> In-Reply-To: <1454510164-6278-1-git-send-email-famz@redhat.com> References: <1454510164-6278-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, peter.maydell@linaro.org, jsnow@redhat.com, stefanha@redhat.com, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , david@gibson.dropbear.id.au Subject: [Qemu-devel] [RFC PATCH 1/4] tests: Introduce Docker based tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 +