Skip to contentSkip to conversation

docker: Add test-block

PATCH In review Fam Zheng 2 participants 8 messages Sep 5, 2017

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

v4 cover docker: Add test-block

Based-on: [email protected]
([PATCH v6 00/12] tests: Add VM based build tests (for non-x86_64 and/or non-Linux))

A few tweaks to the docker images and running commands allow us to run qemu-iotests in the fedora container. This will be added to the patchew test cases later.

v4: Don't use 'set -e'. [Eric]
Add Kashyap's rev-by to unchanged patches.

v3: Add nbd, luks and limit to quick group.

v2: Add nettle-devel because a few iotest cases blindly assumes the support is there.

Fam Zheng (6):
docker: Fix return code of build_qemu()
docker: Add test_fail and prep_fail
docker: Use unconfined security profile
docker: Add nettle-devel to fedora image
docker: Add test-block
docker: Drop 'set -e' from run script

 tests/docker/Makefile.include          |  1 +
 tests/docker/common.rc                 | 15 +++++++++++++--
 tests/docker/dockerfiles/fedora.docker |  1 +
 tests/docker/run                       |  8 +++-----
 tests/docker/test-block                | 22 ++++++++++++++++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100755 tests/docker/test-block
Signature · 1 line
2.13.5
author
#1 lore raw

PATCH v4 1/6 docker: Fix return code of build_qemu()

Without "set -e", the "&&" makes sure that the return code reflects the result status, and that make only runs if configure succeeds.

---
 tests/docker/common.rc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/docker/common.rc +1 -2
index 6865689bb5..c22d825b16 100755
@@ -33,6 +33,5 @@ build_qemu()
                  $@"
     echo "Configure options:"
     echo $config_opts
-    $QEMU_SRC/configure $config_opts
-    make $MAKEFLAGS
+    $QEMU_SRC/configure $config_opts && make $MAKEFLAGS
 }
Signature · 1 line
2.13.5
author
#2 lore raw

PATCH v4 2/6 docker: Add test_fail and prep_fail

In reply to Fam Zheng

They both print a message and exit, but with different status code so distinguish real test errors from env preparation failures.

---
 tests/docker/common.rc | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tests/docker/common.rc +12 -0
index c22d825b16..63ce9a7af5 100755
@@ -35,3 +35,15 @@ build_qemu()
     echo $config_opts
     $QEMU_SRC/configure $config_opts && make $MAKEFLAGS
 }
+
+test_fail()
+{
+    echo "$@"
+    exit 1
+}
+
+prep_fail()
+{
+    echo "$@"
+    exit 2
+}
Signature · 1 line
2.13.5
author
#3 lore raw

PATCH v4 3/6 docker: Use unconfined security profile

In reply to Fam Zheng

Some by default blocked syscalls are required to run tests for example userfaultfd.

---
 tests/docker/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
tests/docker/Makefile.include +1 -0
index 7a027d5bd6..168198e026 100644
@@ -134,6 +134,7 @@ docker-run: docker-qemu-src
 	$(call quiet-command,						\
 		$(SRC_PATH)/tests/docker/docker.py run 			\
 			$(if $(NOUSER),,-u $(shell id -u)) -t 		\
+			--security-opt seccomp=unconfined		\
 			$(if $V,,--rm) 					\
 			$(if $(DEBUG),-i,)				\
 			$(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
Signature · 1 line
2.13.5
author
#4 lore raw

PATCH v4 4/6 docker: Add nettle-devel to fedora image

In reply to Fam Zheng

The LUKS cases in qemu-iotests requires this.

---
 tests/docker/dockerfiles/fedora.docker | 1 +
 1 file changed, 1 insertion(+)
tests/docker/dockerfiles/fedora.docker +1 -0
index 4eaa8ed2a5..27e8201c54 100644
@@ -3,6 +3,7 @@ ENV PACKAGES \
     ccache git tar PyYAML sparse flex bison python2 bzip2 hostname \
     glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel \
     gcc gcc-c++ clang make perl which bc findutils libaio-devel \
+    nettle-devel \
     mingw32-pixman mingw32-glib2 mingw32-gmp mingw32-SDL mingw32-pkg-config \
     mingw32-gtk2 mingw32-gtk3 mingw32-gnutls mingw32-nettle mingw32-libtasn1 \
     mingw32-libjpeg-turbo mingw32-libpng mingw32-curl mingw32-libssh2 \
Signature · 1 line
2.13.5
author
#5 lore raw

PATCH v4 5/6 docker: Add test-block

In reply to Fam Zheng
---
 tests/docker/test-block | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 tests/docker/test-block
tests/docker/test-block new file +22 -0
new file mode 100755
index 0000000000..64d8bbadf7
@@ -0,0 +1,22 @@
+#!/bin/bash
+#
+# Run block test cases
+#
+# Copyright 2017 Red Hat Inc.
+#
+# Authors:
+#  Fam Zheng <[email protected]>
+#
+# 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.
+
+. ./common.rc
+
+cd "$BUILD_DIR"
+
+build_qemu --target-list=x86_64-softmmu
+cd tests/qemu-iotests
+for t in raw qcow2 nbd luks; do
+    ./check -g quick -$t || test_fail "Test failed: iotests $t"
+done
Signature · 1 line
2.13.5
author
#6 lore raw

PATCH v4 6/6 docker: Drop 'set -e' from run script

In reply to Fam Zheng
---
 tests/docker/run | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
tests/docker/run +3 -5
index 9eb9165f76..aad91f6ef5 100755
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash
 #
 # Docker test runner
 #
@@ -11,8 +11,6 @@
 # or (at your option) any later version. See the COPYING file in
 # the top-level directory.
 
-set -e
-
 if test -n "$V"; then
     set -x
 fi
@@ -20,7 +18,7 @@ fi
 BASE="$(dirname $(readlink -e $0))"
 
 # Prepare the environment
-. /etc/profile || true
+. /etc/profile
 export PATH=/usr/lib/ccache:$PATH
 
 if test -n "$J"; then
@@ -32,7 +30,7 @@ export TEST_DIR=/tmp/qemu-test
 mkdir -p $TEST_DIR/{src,build,install}
 
 # Extract the source tarballs
-tar -C $TEST_DIR/src -xf $BASE/qemu.tar
+tar -C $TEST_DIR/src -xf $BASE/qemu.tar || prep_fail "Failed to untar source"
 
 if test -n "$SHOW_ENV"; then
     if test -f /packages.txt; then
Signature · 1 line
2.13.5
Reviewed-by on the v4 series
#7 lore raw
In reply to Fam Zheng
Quoted 24 lines · Fam Zheng

Based-on: [email protected]
([PATCH v6 00/12] tests: Add VM based build tests (for non-x86_64 and/or non-Linux))

A few tweaks to the docker images and running commands allow us to run qemu-iotests in the fedora container. This will be added to the patchew test cases later.

v4: Don't use 'set -e'. [Eric]
Add Kashyap's rev-by to unchanged patches.

v3: Add nbd, luks and limit to quick group.

v2: Add nettle-devel because a few iotest cases blindly assumes the support is there.

Fam Zheng (6):
docker: Fix return code of build_qemu()
docker: Add test_fail and prep_fail
docker: Use unconfined security profile
docker: Add nettle-devel to fedora image
docker: Add test-block
docker: Drop 'set -e' from run script

Quoted 12 lines
 tests/docker/Makefile.include          |  1 +
 tests/docker/common.rc                 | 15 +++++++++++++--
 tests/docker/dockerfiles/fedora.docker |  1 +
 tests/docker/run                       |  8 +++-----
 tests/docker/test-block                | 22 ++++++++++++++++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)
 create mode 100755 tests/docker/test-block
Signature · 1 line
2.13.5