images/100krandom
images/10klines
images/abssymlink
+images/fedora.img
images/hello.b64
images/initrd
images/initrd-x86_64.img
# 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
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 \
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 $<
#!/bin/bash -
-# libguestfs virt-* tools
+# libguestfs
# Copyright (C) 2010 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# 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.
mkdir /bin
mkdir /etc
mkdir /usr
-upload fstab /etc/fstab
+upload fstab.tmp /etc/fstab
mkdir /boot/grub
touch /boot/grub/grub.conf
mkfs-b ext2 2048 /dev/VG/LV3
EOF
-rm fstab
-mv test.img- test.img
+rm fstab.tmp
+mv fedora.img- fedora.img
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
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
fi
rm -f test1.img
-rm -rf copy
\ No newline at end of file
+rm -rf original copy
EXTRA_DIST = \
run-locally \
$(tools:%=virt-%) \
- make-test-img.sh \
test-virt-*.sh
CLEANFILES = test.img
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 \
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
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
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
# 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
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
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