summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-11-11 16:20:25 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-11-11 16:56:11 +0000
commit4d900cdac8258daa2e99c6ceb2a4985154e94150 (patch)
tree3405a12423aaadc9f31fbd0d467ebf0ba92d32ca
parent4d59e271046f2b5f0d9b1730cd23425fd631c76c (diff)
downloadlibguestfs-4d900cdac8258daa2e99c6ceb2a4985154e94150.tar.gz
libguestfs-4d900cdac8258daa2e99c6ceb2a4985154e94150.tar.xz
libguestfs-4d900cdac8258daa2e99c6ceb2a4985154e94150.zip
Generate a dummy 'Fedora' fedora.img in images directory for use by tests.
We were generating this dummy 'Fedora' image already in the tools directory. It contains just enough Fedora-like files to fool our inspection code and thus to test the tools. This is general enough that we can use it everywhere.
-rw-r--r--.gitignore1
-rw-r--r--images/Makefile.am17
-rwxr-xr-ximages/make-dummy-fedora-img.sh (renamed from tools/make-test-img.sh)20
-rwxr-xr-xregressions/test-copy.sh28
-rw-r--r--tools/Makefile.am6
-rwxr-xr-xtools/test-virt-cat.sh4
-rwxr-xr-xtools/test-virt-df.sh12
-rwxr-xr-xtools/test-virt-list-filesystems.sh3
-rwxr-xr-xtools/test-virt-ls.sh2
-rwxr-xr-xtools/test-virt-tar.sh2
10 files changed, 53 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
index 180e17e7..e968ffd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -120,6 +120,7 @@ images/100kallzeroes
images/100krandom
images/10klines
images/abssymlink
+images/fedora.img
images/hello.b64
images/initrd
images/initrd-x86_64.img
diff --git a/images/Makefile.am b/images/Makefile.am
index 771018fc..b1b4855c 100644
--- a/images/Makefile.am
+++ b/images/Makefile.am
@@ -1,5 +1,5 @@
# libguestfs test images
-# Copyright (C) 2009 Red Hat Inc.
+# Copyright (C) 2009-2010 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,14 +36,19 @@ EXTRA_DIST = \
lib-win32.dll \
lib-win64.dll \
lib-x86_64.so \
- test-grep.txt
+ test-grep.txt \
+ make-dummy-fedora-img.sh
noinst_DATA = test.iso
+# This is 'check_DATA' because we don't need it until 'make check'
+# time and we need the tools we have built in order to make it.
+check_DATA = fedora.img
+
CLEANFILES = \
test.iso test.sqsh \
100kallzeroes 100kallnewlines 100kallspaces 100krandom 10klines \
- initrd
+ initrd fedora.img
images_files_src = \
$(srcdir)/helloworld.tar \
@@ -150,3 +155,9 @@ $(builddir)/test-grep.txt.gz: test-grep.txt
rm -f $@ $@-t
gzip --best -c $< > $@-t
mv $@-t $@
+
+# Make a (dummy) Fedora image.
+fedora.img: make-dummy-fedora-img.sh
+ LIBGUESTFS_PATH=../appliance \
+ LD_LIBRARY_PATH=../src/.libs \
+ bash $<
diff --git a/tools/make-test-img.sh b/images/make-dummy-fedora-img.sh
index fddd8a2d..635ad108 100755
--- a/tools/make-test-img.sh
+++ b/images/make-dummy-fedora-img.sh
@@ -1,5 +1,5 @@
#!/bin/bash -
-# libguestfs virt-* tools
+# libguestfs
# Copyright (C) 2010 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
@@ -16,24 +16,24 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-# Make a standard test image which is used by all the tools/test-*.sh
-# test scripts. This test image is supposed to look like a Fedora
-# installation, or at least enough of one to fool virt-inspector's
+# Make a standard test image which is used by all the tools test
+# scripts. This test image is supposed to look like a Fedora
+# installation, or at least enough of one to fool the inspection API
# heuristics.
export LANG=C
set -e
-rm -f test.img
+rm -f fedora.img
-cat > fstab <<EOF
+cat > fstab.tmp <<EOF
LABEL=BOOT /boot ext2 default 0 0
LABEL=ROOT / ext2 default 0 0
EOF
# Create a disk image.
../fish/guestfish <<'EOF'
-sparse test.img- 512M
+sparse fedora.img- 512M
run
# Format the disk.
@@ -63,7 +63,7 @@ mount-options "" /dev/sda1 /boot
mkdir /bin
mkdir /etc
mkdir /usr
-upload fstab /etc/fstab
+upload fstab.tmp /etc/fstab
mkdir /boot/grub
touch /boot/grub/grub.conf
@@ -85,5 +85,5 @@ mkfs-b ext2 1024 /dev/VG/LV2
mkfs-b ext2 2048 /dev/VG/LV3
EOF
-rm fstab
-mv test.img- test.img
+rm fstab.tmp
+mv fedora.img- fedora.img
diff --git a/regressions/test-copy.sh b/regressions/test-copy.sh
index 6cfb3f12..22e5c90f 100755
--- a/regressions/test-copy.sh
+++ b/regressions/test-copy.sh
@@ -29,17 +29,21 @@ test -d /dev/fd || {
set -e
rm -f test1.img
-rm -rf copy
+rm -rf original copy
+
+mkdir original
+cp $srcdir/../images/known* original
+cp -P $srcdir/../images/abssymlink* original
output=$(
../fish/guestfish -N fs -m /dev/sda1 <<EOF
mkdir /data
# This creates a directory /data/images/
-copy-in ../images /data
-is-file /data/images/known-1
-is-file /data/images/known-3
-is-file /data/images/known-5
-is-symlink /data/images/abssymlink
+copy-in original /data
+is-file /data/original/known-1
+is-file /data/original/known-3
+is-file /data/original/known-5
+is-symlink /data/original/abssymlink
is-file /data/known-1
is-file /known-1
EOF
@@ -60,13 +64,13 @@ fi
mkdir copy
../fish/guestfish --ro -a test1.img -m /dev/sda1 <<EOF
-copy-out /data/images copy
+copy-out /data/original copy
EOF
-if test ! -f copy/images/known-1 || \
- test ! -f copy/images/known-3 || \
- test ! -f copy/images/known-5 || \
- test ! -L copy/images/abssymlink || \
+if test ! -f copy/original/known-1 || \
+ test ! -f copy/original/known-3 || \
+ test ! -f copy/original/known-5 || \
+ test ! -L copy/original/abssymlink || \
test -f copy/known-1 || \
test -f known-1
then
@@ -75,4 +79,4 @@ then
fi
rm -f test1.img
-rm -rf copy \ No newline at end of file
+rm -rf original copy
diff --git a/tools/Makefile.am b/tools/Makefile.am
index b92243c0..5b415c0e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -33,7 +33,6 @@ tools = \
EXTRA_DIST = \
run-locally \
$(tools:%=virt-%) \
- make-test-img.sh \
test-virt-*.sh
CLEANFILES = test.img
@@ -76,11 +75,6 @@ TESTS_ENVIRONMENT = \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
PERL5LIB=$(top_builddir)/perl/blib/lib:$(top_builddir)/perl/blib/arch
-# Build a standard test image to be used by all these tests.
-check_DATA = test.img
-test.img: make-test-img.sh
- $(TESTS_ENVIRONMENT) $(srcdir)/make-test-img.sh
-
TESTS = test-virt-cat.sh \
test-virt-df.sh \
test-virt-list-filesystems.sh \
diff --git a/tools/test-virt-cat.sh b/tools/test-virt-cat.sh
index d87c4b8c..19b8d875 100755
--- a/tools/test-virt-cat.sh
+++ b/tools/test-virt-cat.sh
@@ -4,11 +4,11 @@ export LANG=C
set -e
# Read out the test files from the image using virt-cat.
-if [ "$(./virt-cat test.img /etc/test1)" != "abcdefg" ]; then
+if [ "$(./virt-cat ../images/fedora.img /etc/test1)" != "abcdefg" ]; then
echo "$0: error: mismatch in file test1"
exit 1
fi
-if [ "$(./virt-cat test.img /etc/test2)" != "" ]; then
+if [ "$(./virt-cat ../images/fedora.img /etc/test2)" != "" ]; then
echo "$0: error: mismatch in file test2"
exit 1
fi
diff --git a/tools/test-virt-df.sh b/tools/test-virt-df.sh
index a7b50b8f..6878327d 100755
--- a/tools/test-virt-df.sh
+++ b/tools/test-virt-df.sh
@@ -4,7 +4,7 @@ export LANG=C
set -e
# Run virt-df.
-output=$(./virt-df test.img)
+output=$(./virt-df ../images/fedora.img)
# Check title is the first line.
if [[ ! $output =~ ^Filesystem.* ]]; then
@@ -19,25 +19,25 @@ if [ $(echo "$output" | wc -l) -ne 6 ]; then
fi
# Check /dev/VG/LV[1-3] and /dev/VG/Root were found.
-if [[ ! $output =~ test.img:/dev/VG/LV1 ]]; then
+if [[ ! $output =~ fedora.img:/dev/VG/LV1 ]]; then
echo "$0: error: filesystem /dev/VG/LV1 was not found"
exit 1
fi
-if [[ ! $output =~ test.img:/dev/VG/LV2 ]]; then
+if [[ ! $output =~ fedora.img:/dev/VG/LV2 ]]; then
echo "$0: error: filesystem /dev/VG/LV2 was not found"
exit 1
fi
-if [[ ! $output =~ test.img:/dev/VG/LV3 ]]; then
+if [[ ! $output =~ fedora.img:/dev/VG/LV3 ]]; then
echo "$0: error: filesystem /dev/VG/LV3 was not found"
exit 1
fi
-if [[ ! $output =~ test.img:/dev/VG/Root ]]; then
+if [[ ! $output =~ fedora.img:/dev/VG/Root ]]; then
echo "$0: error: filesystem /dev/VG/Root was not found"
exit 1
fi
# Check /dev/sda1 was found. Might be called /dev/vda1.
-if [[ ! $output =~ test.img:/dev/[hsv]da1 ]]; then
+if [[ ! $output =~ fedora.img:/dev/[hsv]da1 ]]; then
echo "$0: error: filesystem /dev/VG/sda1 was not found"
exit 1
fi
diff --git a/tools/test-virt-list-filesystems.sh b/tools/test-virt-list-filesystems.sh
index 5fd4b08a..bd4e4e70 100755
--- a/tools/test-virt-list-filesystems.sh
+++ b/tools/test-virt-list-filesystems.sh
@@ -5,7 +5,8 @@ set -e
# Run virt-list-filesystems.
# Only columns 1 & 2 are guaranteed, we may add more in future.
-if [ "$(./virt-list-filesystems -l test.img | sort | awk '{print $1 $2}')" \
+if [ "$(./virt-list-filesystems -l ../images/fedora.img |
+ sort | awk '{print $1 $2}')" \
!= \
"/dev/VG/LV1ext2
/dev/VG/LV2ext2
diff --git a/tools/test-virt-ls.sh b/tools/test-virt-ls.sh
index d55b764d..c8330d2e 100755
--- a/tools/test-virt-ls.sh
+++ b/tools/test-virt-ls.sh
@@ -7,7 +7,7 @@ set -e
uuid=868b1447-0ec5-41bf-a2e5-6a77a4c9b66f
# Read out the test directory using virt-ls.
-if [ "$(./virt-ls test.img /bin)" != "test1
+if [ "$(./virt-ls ../images/fedora.img /bin)" != "test1
test2
test3
test4
diff --git a/tools/test-virt-tar.sh b/tools/test-virt-tar.sh
index 4ee87cbd..40cee90b 100755
--- a/tools/test-virt-tar.sh
+++ b/tools/test-virt-tar.sh
@@ -4,7 +4,7 @@ export LANG=C
set -e
# Read out the test directory using virt-tar.
-./virt-tar -x test.img /bin test.tar
+./virt-tar -x ../images/fedora.img /bin test.tar
if [ "$(tar tf test.tar)" != "./
./test1