diff options
Diffstat (limited to 'debian/tests')
-rw-r--r-- | debian/tests/control | 11 | ||||
-rwxr-xr-x | debian/tests/test-qemu-img.sh | 35 | ||||
-rwxr-xr-x | debian/tests/test-qemu-system.sh | 10 | ||||
-rwxr-xr-x | debian/tests/test-qemu-user.sh | 34 |
4 files changed, 90 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 00000000..9869a5f8 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,11 @@ +Tests: test-qemu-img.sh +Depends: qemu-utils +Restrictions: superficial + +Tests: test-qemu-system.sh +Depends: qemu-system-x86 +Restrictions: superficial + +Tests: test-qemu-user.sh +Depends: qemu-user, qemu-user-static +Restrictions: superficial diff --git a/debian/tests/test-qemu-img.sh b/debian/tests/test-qemu-img.sh new file mode 100755 index 00000000..ed7475f2 --- /dev/null +++ b/debian/tests/test-qemu-img.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +cd "$AUTOPKGTEST_TMP" + +doit() { + echo "$1:" + shift + echo "$1" + if [ -n "$2" ]; then + out="$($1)" + eval "case \"\$out\" in ( $2 ) echo \"\$out\";; (*) echo \"unexpected output:\"; echo \" want $2\"; echo \" got \$out\"; return 1;; esac" + else + $1 + fi + echo ok. +} + +doit "Testing if qemu-img creates images" \ + "qemu-img create q.raw 12G" + +doit "Testing for correct image size" \ + "ls -l q.raw" '*\ 12884901888\ *' + +doit "Testing if file is sparse" \ + 'ls -s q.raw' '[04]\ *' + +doit "Testing if conversion to a qcow2 image works" \ + "qemu-img convert -f raw -O qcow2 q.raw q.qcow2" + +doit "Checking if image is qcow2" \ + 'qemu-img info q.qcow2' "*'file format: qcow2'*'size: 12 GiB (12884901888 bytes)'*" + +rm -f q.raw q.qcow2 diff --git a/debian/tests/test-qemu-system.sh b/debian/tests/test-qemu-system.sh new file mode 100755 index 00000000..eca40951 --- /dev/null +++ b/debian/tests/test-qemu-system.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +for ARCH in x86_64 i386; do + echo -n "Checking for pc in ${ARCH}..." + qemu-system-${ARCH} -M help | grep -qs "pc\s\+Standard PC" + echo "done." +done + diff --git a/debian/tests/test-qemu-user.sh b/debian/tests/test-qemu-user.sh new file mode 100755 index 00000000..da18b8af --- /dev/null +++ b/debian/tests/test-qemu-user.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +arch=$(dpkg --print-architecture) +echo "debian architecture: $arch" +case $arch in + ( amd64 | x86_64 ) arch=x86_64 ;; + ( i[3456]86 ) arch=i386 ;; + ( arm64 | aarch64 ) arch=aarch64 ;; + ( arm | armel | armhf ) arch=arm ;; + ( ppc64el | powerpc64le ) arch=ppc64le ;; + ( s390x ) ;; + ( * ) echo "Warning: unmapped architecture $arch" ;; +esac +echo "qemu architecture: $arch" + +tested= +for f in qemu-$arch qemu-$arch-static ; do + [ -x /usr/bin/$f ] || continue + echo "Checking if $f can run executables:" + echo "glob with sh: $f /bin/sh -c '$f /bin/ls -dCFl debian/*[t]*':" + ls="$($f /bin/sh -c "$f /bin/ls -dCFl debian/*[t]*")" + echo "$ls" + case "$ls" in + (*debian/control*) ;; + *) echo "Expected output not found" >&2; exit 1;; + esac + echo ok. + tested=y +done +if [ ! "$tested" ]; then + echo "Warning: qemu-$arch[-static] not found, not testing qemu-user" +fi |