summaryrefslogtreecommitdiffstats
path: root/tools
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 /tools
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.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am6
-rwxr-xr-xtools/make-test-img.sh89
-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
7 files changed, 12 insertions, 106 deletions
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/make-test-img.sh b/tools/make-test-img.sh
deleted file mode 100755
index fddd8a2d..00000000
--- a/tools/make-test-img.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/bash -
-# libguestfs virt-* tools
-# Copyright (C) 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# 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
-# heuristics.
-
-export LANG=C
-set -e
-
-rm -f test.img
-
-cat > fstab <<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
-run
-
-# Format the disk.
-part-init /dev/sda mbr
-part-add /dev/sda p 64 524287
-part-add /dev/sda p 524288 -64
-
-pvcreate /dev/sda2
-vgcreate VG /dev/sda2
-lvcreate Root VG 32
-lvcreate LV1 VG 32
-lvcreate LV2 VG 32
-lvcreate LV3 VG 64
-
-# Phony /boot filesystem.
-mkfs-b ext2 4096 /dev/sda1
-set-e2label /dev/sda1 BOOT
-
-# Phony root filesystem.
-mkfs-b ext2 4096 /dev/VG/Root
-set-e2label /dev/VG/Root ROOT
-
-# Enough to fool virt-inspector.
-mount-options "" /dev/VG/Root /
-mkdir /boot
-mount-options "" /dev/sda1 /boot
-mkdir /bin
-mkdir /etc
-mkdir /usr
-upload fstab /etc/fstab
-mkdir /boot/grub
-touch /boot/grub/grub.conf
-
-# Test files.
-write /etc/test1 "abcdefg"
-write /etc/test2 ""
-write /bin/test1 "abcdefg"
-write /bin/test2 "zxcvbnm"
-write /bin/test3 "1234567"
-write /bin/test4 ""
-ln-s /bin/test1 /bin/test5
-mkfifo 0777 /bin/test6
-mknod 0777 10 10 /bin/test7
-
-# Other filesystems.
-# Note that these should be empty, for testing virt-df.
-mkfs-b ext2 4096 /dev/VG/LV1
-mkfs-b ext2 1024 /dev/VG/LV2
-mkfs-b ext2 2048 /dev/VG/LV3
-EOF
-
-rm fstab
-mv test.img- test.img
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