1
0
Fork 0
qemu/debian/tests/test-qemu-img.sh
Daniel Baumann 665688c177
Adding debian version 1:10.0.2+ds-1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-22 14:27:18 +02:00

37 lines
816 B
Bash
Executable file

#!/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\ *'
fsblock=$(stat -f --format=%S q.raw)
doit "Testing if file is sparse" \
"ls -s --block-size=$fsblock q.raw" '[01]\ *'
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