summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-06-29 17:57:00 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-07-07 11:23:31 +0100
commitd157bd3f6bca580d919c2f7942f9357c792454bf (patch)
tree71ff9dc0119ad8121ae86ca37601a0d63319625e
parentbbbd267dd111832af7ebba1e7f566702e5fe37d2 (diff)
downloadlibguestfs-d157bd3f6bca580d919c2f7942f9357c792454bf.tar.gz
libguestfs-d157bd3f6bca580d919c2f7942f9357c792454bf.tar.xz
libguestfs-d157bd3f6bca580d919c2f7942f9357c792454bf.zip
tests: Use qemu-img to create an overlay for testing, instead of copying.
Replace: cp tests/guests/fedora.img test.img with the longer but possibly more space-efficient equivalent: qemu-img create -F raw -b tests/guests/fedora.img -f qcow2 test.qcow2 (cherry picked from commit 339f3647f889424af2a2256c4fcad0b44982c275)
-rwxr-xr-xedit/test-virt-edit.sh16
-rwxr-xr-xtests/md/test-inspect-fstab.sh18
2 files changed, 18 insertions, 16 deletions
diff --git a/edit/test-virt-edit.sh b/edit/test-virt-edit.sh
index ae5dcf5a..865e35b0 100755
--- a/edit/test-virt-edit.sh
+++ b/edit/test-virt-edit.sh
@@ -3,15 +3,17 @@
export LANG=C
set -e
+rm -f test.qcow2
+
# Make a copy of the Fedora image so we can write to it then
# discard it.
-cp ../tests/guests/fedora.img test.img
+qemu-img create -F raw -b ../tests/guests/fedora.img -f qcow2 test.qcow2
# Edit interactively. We have to simulate this by setting $EDITOR.
# The command will be: echo newline >> /tmp/file
export EDITOR='echo newline >>'
-./virt-edit -a test.img /etc/test3
-if [ "$(../cat/virt-cat -a test.img /etc/test3)" != "a
+./virt-edit -a test.qcow2 /etc/test3
+if [ "$(../cat/virt-cat -a test.qcow2 /etc/test3)" != "a
b
c
d
@@ -25,8 +27,8 @@ unset EDITOR
# Edit non-interactively, only if we have 'perl' binary.
if perl --version >/dev/null 2>&1; then
- ./virt-edit -a test.img /etc/test3 -e 's/^[a-f]/$lineno/'
- if [ "$(../cat/virt-cat -a test.img /etc/test3)" != "1
+ ./virt-edit -a test.qcow2 /etc/test3 -e 's/^[a-f]/$lineno/'
+ if [ "$(../cat/virt-cat -a test.qcow2 /etc/test3)" != "1
2
3
4
@@ -40,7 +42,7 @@ fi
# Verify the mode of /etc/test3 is still 0600 and the UID:GID is 10:11.
# See tests/guests/guest-aux/make-fedora-img.pl and RHBZ#788641.
-if [ "$(../fish/guestfish -i -a test.img --ro lstat /etc/test3 | grep -E '^(mode|uid|gid):' | sort)" != "gid: 11
+if [ "$(../fish/guestfish -i -a test.qcow2 --ro lstat /etc/test3 | grep -E '^(mode|uid|gid):' | sort)" != "gid: 11
mode: 33152
uid: 10" ]; then
echo "$0: error: editing /etc/test3 did not preserve permissions or ownership"
@@ -48,4 +50,4 @@ uid: 10" ]; then
fi
# Discard test image.
-rm test.img
+rm test.qcow2
diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh
index 62e2e948..abb20f4a 100755
--- a/tests/md/test-inspect-fstab.sh
+++ b/tests/md/test-inspect-fstab.sh
@@ -25,11 +25,11 @@ export LANG=C
guestfish=../../fish/guestfish
canonical="sed s,/dev/vd,/dev/sd,g"
-rm -f test1.img test.fstab test.output
+rm -f test1.qcow2 test.fstab test.output
# Start with the regular (good) fedora image, modify /etc/fstab
# and then inspect it.
-cp ../guests/fedora.img test1.img
+qemu-img create -F raw -b ../guests/fedora.img -f qcow2 test1.qcow2
cat <<'EOF' > test.fstab
/dev/VG/Root / ext2 default 0 0
@@ -44,14 +44,14 @@ cat <<'EOF' > test.fstab
/dev/VG/LV1 /nosuchfile ext2 default 0 0
EOF
-$guestfish -a test1.img <<'EOF'
+$guestfish -a test1.qcow2 <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
# This will give a warning, but should not fail.
-$guestfish -a test1.img -i <<'EOF' | sort | $canonical > test.output
+$guestfish -a test1.qcow2 -i <<'EOF' | sort | $canonical > test.output
inspect-get-mountpoints /dev/VG/Root
EOF
@@ -73,14 +73,14 @@ cat <<'EOF' > test.fstab
/dev/xvdg1 /boot ext2 default 0 0
EOF
-$guestfish -a test1.img <<'EOF'
+$guestfish -a test1.qcow2 <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
$guestfish <<'EOF' | $canonical > test.output
- add-drive-opts test1.img readonly:true name:xvdg
+ add-drive-opts test1.qcow2 readonly:true name:xvdg
run
inspect-os
inspect-get-mountpoints /dev/VG/Root
@@ -104,14 +104,14 @@ cat <<'EOF' > test.fstab
/dev/cciss/c1d3 /var ext2 default 0 0
EOF
-$guestfish -a test1.img <<'EOF'
+$guestfish -a test1.qcow2 <<'EOF'
run
mount-options "" /dev/VG/Root /
upload test.fstab /etc/fstab
EOF
$guestfish <<'EOF' | $canonical > test.output
- add-drive-opts test1.img readonly:true name:cciss/c1d3
+ add-drive-opts test1.qcow2 readonly:true name:cciss/c1d3
run
inspect-os
inspect-get-mountpoints /dev/VG/Root
@@ -127,5 +127,5 @@ if [ "$(cat test.output)" != "/dev/VG/Root
fi
rm test.fstab
-rm test1.img
+rm test1.qcow2
rm test.output