tests: Split regressions -> various subdirectories of tests/

This commit is contained in:
Richard W.M. Jones
2011-12-22 11:35:43 +00:00
parent 5d93d70b4d
commit 498758faee
54 changed files with 203 additions and 138 deletions

11
.gitignore vendored
View File

@@ -1,5 +1,9 @@
*~
*.a
test1.img
test2.img
test.err
test.out
ABOUT-NLS
aclocal.m4
align/stamp-virt-alignment-scan.pod
@@ -294,11 +298,6 @@ python/examples/stamp-guestfs-python.pod
python/guestfs.py
python/guestfs-py.c
python/guestfs.pyc
regressions/rhbz501893
regressions/test1.img
regressions/test2.img
regressions/test.err
regressions/test.out
rescue/stamp-virt-rescue.pod
rescue/virt-rescue
rescue/virt-rescue.1
@@ -340,7 +339,6 @@ src/libguestfs.syms
src/stamp-guestfs.pod
*.swp
stamp-h1
test1.img
test-tool/libguestfs-test-tool
test-tool/libguestfs-test-tool.1
test-tool/libguestfs-test-tool-helper
@@ -359,6 +357,7 @@ tests/c-api/test*.img
tests/c-api/tests
tests/c-api/tests.c
tests/c-api/test*.tmp
tests/regressions/rhbz501893
tools/test.img
tools/virt-*.1
tools/virt-*.pl

View File

@@ -30,7 +30,10 @@ SUBDIRS += appliance
endif
# Tests and the test-tool.
SUBDIRS += gnulib/tests tests/c-api tests/qemu regressions extratests test-tool
SUBDIRS += gnulib/tests tests/c-api tests/qemu
SUBDIRS += tests/protocol tests/lvm tests/luks tests/md
SUBDIRS += tests/regressions
SUBDIRS += extratests test-tool
# Guestfish.
SUBDIRS += fish

View File

@@ -1041,7 +1041,6 @@ AC_CONFIG_FILES([Makefile
po/Makefile.in
python/Makefile
python/examples/Makefile
regressions/Makefile
rescue/Makefile
resize/Makefile
ruby/Makefile
@@ -1051,7 +1050,12 @@ AC_CONFIG_FILES([Makefile
src/Makefile
test-tool/Makefile
tests/c-api/Makefile
tests/luks/Makefile
tests/lvm/Makefile
tests/md/Makefile
tests/protocol/Makefile
tests/qemu/Makefile
tests/regressions/Makefile
tools/Makefile])
AC_OUTPUT

View File

@@ -280,7 +280,9 @@ debug_env (const char *subcmd, int argc, char *const *const argv)
return out;
}
/* Return binaries in the appliance. See regressions/rhbz727178.sh */
/* Return binaries in the appliance.
* See tests/regressions/rhbz727178.sh
*/
static char *
debug_binaries (const char *subcmd, int argc, char *const *const argv)
{
@@ -306,7 +308,9 @@ debug_binaries (const char *subcmd, int argc, char *const *const argv)
return out;
}
/* Run 'ldd' on a file from the appliance. See regressions/rhbz727178.sh */
/* Run 'ldd' on a file from the appliance.
* See tests/regressions/rhbz727178.sh
*/
static char *
debug_ldd (const char *subcmd, int argc, char *const *const argv)
{

View File

@@ -45,6 +45,7 @@ BUILT_SOURCES = \
EXTRA_DIST = \
$(BUILT_SOURCES) \
$(TESTS) \
rc_protocol.x \
guestfish.pod \
guestfish-bash-completion.sh \
@@ -226,3 +227,28 @@ toolsconf_DATA = libguestfs-tools.conf
bashcompletiondir = $(sysconfdir)/bash_completion.d
bashcompletion_DATA = guestfish-bash-completion.sh
# Tests.
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
TMPDIR=$(top_builddir)
TESTS = \
test-add-domain.sh \
test-copy.sh \
test-find0.sh \
test-guestfish-a.sh \
test-guestfish-d.sh \
test-guestfish-escapes.sh \
test-guestfish-events.sh \
test-guestfish-tilde.sh \
test-read_file.sh \
test-remote.sh \
test-reopen.sh \
test-stringlist.sh \
test-upload-to-dir.sh

View File

@@ -2737,8 +2737,9 @@ the OCaml description.
You can supply zero or as many tests as you want per API call. The
tests can either be added as part of the API description
(C<generator/generator_actions.ml>), or in some rarer cases you may
want to drop a script into C<regressions/>. Note that adding a script
to C<regressions/> is slower, so if possible use the first method.
want to drop a script into C<tests/*/>. Note that adding
a script to C<tests/*/> is slower, so if possible use the
first method.
The following describes the test environment used when you add an API
test in C<generator_actions.ml>.
@@ -2996,10 +2997,6 @@ The build infrastructure and PO files for translations of manpages and
POD files. Eventually this will be combined with the C<po> directory,
but that is rather complicated.
=item C<regressions>
Regression tests.
=item C<rescue>
L<virt-rescue(1)> command and documentation.

View File

@@ -1,6 +1,5 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2010 Red Hat Inc.
# Copyright (C) 2009-2011 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
@@ -16,11 +15,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
echo
echo '*****'
echo
echo 'Some of these tests print error messages. You can ignore'
echo 'these error messages as long as the tests print "PASS".'
echo
echo '*****'
echo
include $(top_srcdir)/subdir-rules.mk
TESTS = \
test-luks.sh \
test-luks-list.sh
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
TMPDIR=$(top_builddir)
EXTRA_DIST = \
$(TESTS)

View File

@@ -27,7 +27,7 @@ set -e
rm -f test1.img test.output
../fish/guestfish --keys-from-stdin > test.output <<'EOF'
../../fish/guestfish --keys-from-stdin > test.output <<'EOF'
sparse test1.img 1G
run
part-init /dev/sda mbr

View File

@@ -27,7 +27,7 @@ set -e
rm -f test1.img
../fish/guestfish --keys-from-stdin <<EOF
../../fish/guestfish --keys-from-stdin <<EOF
sparse test1.img 1G
run
part-disk /dev/sda mbr

View File

@@ -1,6 +1,5 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2009 Red Hat Inc.
# Copyright (C) 2009-2011 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
@@ -16,25 +15,19 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Some versions of qemu can be flakey and can hang occasionally
# during boot (particularly KVM if the BIOS is the qemu version
# which doesn't have the required KVM patches). Test repeatedly
# booting.
include $(top_srcdir)/subdir-rules.mk
set -e
TESTS = \
test-lvm-filtering.sh \
test-lvm-mapping.pl
rm -f test1.img
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
n=10
if [ -n "$1" ]; then n=$1; fi
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
TMPDIR=$(top_builddir)
export LIBGUESTFS_DEBUG=1
for i in $(seq 1 $n); do
echo Test boot $i of $n ...
../fish/guestfish -N disk </dev/null
done
rm test1.img
echo Test boot completed after $n iterations.
EXTRA_DIST = \
$(TESTS)

View File

@@ -22,7 +22,7 @@ set -e
rm -f test1.img test2.img
actual=$(../fish/guestfish <<'EOF'
actual=$(../../fish/guestfish <<'EOF'
sparse test1.img 1G
sparse test2.img 1G

36
tests/md/Makefile.am Normal file
View File

@@ -0,0 +1,36 @@
# libguestfs
# Copyright (C) 2009-2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include $(top_srcdir)/subdir-rules.mk
TESTS = \
test-inspect-fstab.sh \
test-inspect-fstab-md.sh \
test-list-filesystems.sh \
test-list-md-devices.sh \
test-mdadm.sh
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
TMPDIR=$(top_builddir)
EXTRA_DIST = \
$(TESTS)

View File

@@ -24,19 +24,19 @@ export LANG=C
# The first test requires a new Augeas lens for parsing mdadm.conf.
# If this is not present in the appliance or on the host, skip the
# test.
f=$(grep mdadm_conf.aug ../appliance/supermin.d/hostfiles | head -1)
f=$(grep mdadm_conf.aug ../../appliance/supermin.d/hostfiles | head -1)
if [ -z "$f" -o ! -f "$f" ]; then
echo "$0: test skipped because Augeas mdadm.conf lens is not available."
exit 0
fi
guestfish=../fish/guestfish
guestfish=../../fish/guestfish
rm -f test1.img test.fstab test.output
# First, test the regular fedora image, which specifies /boot as /dev/md0
cp ../images/fedora-md1.img test1.img
cp ../images/fedora-md2.img test2.img
cp ../../images/fedora-md1.img test1.img
cp ../../images/fedora-md2.img test2.img
$guestfish -i test[12].img <<'EOF' | sort > test.output
exists /boot/grub/grub.conf

View File

@@ -22,13 +22,13 @@
set -e
export LANG=C
guestfish=../fish/guestfish
guestfish=../../fish/guestfish
rm -f test1.img test.fstab test.output
# Start with the regular (good) fedora image, modify /etc/fstab
# and then inspect it.
cp ../images/fedora.img test1.img
cp ../../images/fedora.img test1.img
cat <<'EOF' > test.fstab
/dev/VG/Root / ext2 default 0 0

View File

@@ -31,7 +31,7 @@ set -e
# vg0 : 16M LV (lv0)
# lv0 : 16M vfat
output=$(
../fish/guestfish <<EOF
../../fish/guestfish <<EOF
# Add 2 empty disks
sparse fs-test1.img 50M
sparse fs-test2.img 50M

View File

@@ -21,7 +21,7 @@
set -e
output=$(
../fish/guestfish <<EOF
../../fish/guestfish <<EOF
# Add 2 empty disks
sparse md-test1.img 100M
sparse md-test2.img 100M
@@ -44,7 +44,7 @@ fi
# Ensure list-md-devices now returns the newly created md device
output=$(
../fish/guestfish -a md-test1.img -a md-test2.img <<EOF
../../fish/guestfish -a md-test1.img -a md-test2.img <<EOF
run
list-md-devices
EOF

View File

@@ -22,7 +22,7 @@ set -e
rm -f md-test1.img md-test2.img md-test3.img md-test4.img
../fish/guestfish <<EOF
../../fish/guestfish <<EOF
# Add four empty disks
sparse md-test1.img 100M
sparse md-test2.img 100M
@@ -92,15 +92,15 @@ write /r5t3/baz "testing"
EOF
eval `../fish/guestfish --listen`
../fish/guestfish --remote add-ro md-test1.img
../fish/guestfish --remote add-ro md-test2.img
../fish/guestfish --remote add-ro md-test3.img
../fish/guestfish --remote add-ro md-test4.img
../fish/guestfish --remote run
eval `../../fish/guestfish --listen`
../../fish/guestfish --remote add-ro md-test1.img
../../fish/guestfish --remote add-ro md-test2.img
../../fish/guestfish --remote add-ro md-test3.img
../../fish/guestfish --remote add-ro md-test4.img
../../fish/guestfish --remote run
for md in `../fish/guestfish --remote list-md-devices`; do
../fish/guestfish --remote md-detail "${md}" > md-detail.out
for md in `../../fish/guestfish --remote list-md-devices`; do
../../fish/guestfish --remote md-detail "${md}" > md-detail.out
sed 's/:\s*/=/' md-detail.out > md-detail.out.sh
. md-detail.out.sh
@@ -143,24 +143,24 @@ for md in `../fish/guestfish --remote list-md-devices`; do
if [ "$error" == "1" ]; then
echo "$0: Unexpected output from md-detail for device $md"
cat md-detail.out
../fish/guestfish --remote exit
../../fish/guestfish --remote exit
exit 1
fi
done
../fish/guestfish --remote exit
../../fish/guestfish --remote exit
eval `../fish/guestfish --listen`
../fish/guestfish --remote add-ro md-test1.img
../fish/guestfish --remote add-ro md-test2.img
../fish/guestfish --remote add-ro md-test3.img
../fish/guestfish --remote add-ro md-test4.img
../fish/guestfish --remote run
eval `../../fish/guestfish --listen`
../../fish/guestfish --remote add-ro md-test1.img
../../fish/guestfish --remote add-ro md-test2.img
../../fish/guestfish --remote add-ro md-test3.img
../../fish/guestfish --remote add-ro md-test4.img
../../fish/guestfish --remote run
for md in `../fish/guestfish --remote list-md-devices`; do
../fish/guestfish --remote md-stop "${md}"
for md in `../../fish/guestfish --remote list-md-devices`; do
../../fish/guestfish --remote md-stop "${md}"
done
../fish/guestfish --remote exit
../../fish/guestfish --remote exit
rm -f md-detail.out md-test1.img md-test2.img md-test3.img md-test4.img

View File

@@ -0,0 +1,38 @@
# libguestfs
# Copyright (C) 2009-2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include $(top_srcdir)/subdir-rules.mk
TESTS = \
test-both-ends-cancel.sh \
test-cancellation-download-librarycancels.sh \
test-cancellation-upload-daemoncancels.sh \
test-launch-race.pl \
test-qemudie-killsub.sh \
test-qemudie-midcommand.sh \
test-qemudie-synch.sh
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
LD_LIBRARY_PATH=$(top_builddir)/src/.libs \
LIBGUESTFS_PATH=$(top_builddir)/appliance \
TMPDIR=$(top_builddir)
EXTRA_DIST = \
$(TESTS)

View File

@@ -24,7 +24,7 @@ set -e
rm -f test1.img
../fish/guestfish -N disk <<EOF
../../fish/guestfish -N disk <<EOF
-tar-in /tmp/nosuchfile /blah
ping-daemon
EOF

View File

@@ -31,7 +31,7 @@ rm -f test.img
size=$(awk 'BEGIN{ srand(); print int(16*1024*rand()) }')
echo "$0: test size $size (bytes)"
../fish/guestfish <<EOF
../../fish/guestfish <<EOF
# We want the file to be fully allocated.
alloc test.img 10M
run

View File

@@ -24,7 +24,7 @@ set -e
rm -f test1.img
../fish/guestfish -N fs -m /dev/sda1 <<'EOF'
../../fish/guestfish -N fs -m /dev/sda1 <<'EOF'
# Upload image, daemon should cancel because the image is too large
# to upload into itself.
-upload test.img /test

View File

@@ -22,7 +22,7 @@ set -e
rm -f test1.img
../fish/guestfish -N disk <<'EOF'
../../fish/guestfish -N disk <<'EOF'
# Kill the subprocess.
kill-subprocess

View File

@@ -22,7 +22,7 @@ set -e
rm -f test.img
../fish/guestfish <<'EOF'
../../fish/guestfish <<'EOF'
alloc test.img 10M
append "root=/dev/null"

View File

@@ -22,7 +22,7 @@ set -e
rm -f test.pid test1.img
../fish/guestfish -N disk <<'EOF'
../../fish/guestfish -N disk <<'EOF'
# Kill the subprocess after a short wait.
pid | cat > test.pid
! sleep 2 ; kill $(cat test.pid) &

View File

@@ -22,7 +22,7 @@ set -e
rm -f test.pid test1.img
../fish/guestfish -N disk <<'EOF'
../../fish/guestfish -N disk <<'EOF'
# Kill subprocess.
pid | cat > test.pid
! kill $(cat test.pid) ; sleep 2

View File

@@ -33,7 +33,7 @@ test3_md5sum="$(md5sum test3.img | awk '{print $1}')"
# The vitally important calls are 'add-drive-ro' and
# 'add-drive-opts ... readonly:true'.
../fish/guestfish <<'EOF'
../../fish/guestfish <<'EOF'
add-drive-ro test1.img
add-drive-opts test2.img format:raw readonly:true
add-drive-opts test3.img format:qcow2 readonly:true

View File

@@ -15,14 +15,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Regression tests and other important tests which are not
# specific to the C API. We can write these more easily in
# higher level languages than C.
include $(top_srcdir)/subdir-rules.mk
TESTS = \
tell-user-to-ignore-errors.sh \
rhbz501893 \
rhbz503169c13.sh \
rhbz557655.sh \
@@ -31,42 +26,7 @@ TESTS = \
rhbz580246.sh \
rhbz602997.sh \
rhbz690819.sh \
test-add-domain.sh \
test-both-ends-cancel.sh \
test-cancellation-download-librarycancels.sh \
test-cancellation-upload-daemoncancels.sh \
test-copy.sh \
test-find0.sh \
test-guestfish-a.sh \
test-guestfish-d.sh \
test-guestfish-escapes.sh \
test-guestfish-events.sh \
test-guestfish-tilde.sh \
test-inspect-fstab.sh \
test-inspect-fstab-md.sh \
test-launch-race.pl \
test-list-filesystems.sh \
test-list-md-devices.sh \
test-luks.sh \
test-luks-list.sh \
test-lvm-filtering.sh \
test-lvm-mapping.pl \
test-mdadm.sh \
test-noexec-stack.pl \
test-qemudie-killsub.sh \
test-qemudie-midcommand.sh \
test-qemudie-synch.sh \
test-read_file.sh \
test-remote.sh \
test-reopen.sh \
test-stringlist.sh \
test-upload-to-dir.sh
SKIPPED_TESTS = \
test-bootbootboot.sh
FAILING_TESTS = \
test-qemudie-launchfail.sh
test-noexec-stack.pl
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
@@ -89,8 +49,6 @@ rhbz501893_LDADD = \
$(top_builddir)/src/libguestfs.la
EXTRA_DIST = \
$(FAILING_TESTS) \
$(SKIPPED_TESTS) \
$(TESTS) \
rhbz557655-expected.stdout \
rhbz557655-expected.stderr

View File

@@ -28,7 +28,7 @@ set -e
rm -f test1.img
../fish/guestfish -N fs -m /dev/sda1 <<EOF
../../fish/guestfish -N fs -m /dev/sda1 <<EOF
mkdir /dev
-command /ignore-this-error
unmount-all

View File

@@ -24,7 +24,7 @@ set -e
rm -f test.out test.err
export LANG=C
../fish/guestfish >> test.out 2>> test.err <<EOF
../../fish/guestfish >> test.out 2>> test.err <<EOF
# set-memsize is just a convenient non-daemon function that
# takes a single integer argument.
set-memsize 0
@@ -48,7 +48,7 @@ get-memsize
-set-memsize 123L
EOF
../fish/guestfish -N fs -m /dev/sda1 >> test.out 2>> test.err <<EOF
../../fish/guestfish -N fs -m /dev/sda1 >> test.out 2>> test.err <<EOF
touch /test
# truncate-size takes an Int64 argument

View File

@@ -24,7 +24,7 @@ set -e
rm -f test1.img
../fish/guestfish -N disk <<EOF
../../fish/guestfish -N disk <<EOF
-upload $srcdir/rhbz576879.sh /test.sh
# Shouldn't lose synchronization, so next command should work:
ping-daemon

View File

@@ -23,7 +23,7 @@
set -e
guestfish=../fish/guestfish
guestfish=../../fish/guestfish
# Start remote guestfish.
eval `$guestfish --listen 2>/dev/null`

View File

@@ -29,7 +29,7 @@ dd if=/dev/zero of=test.img bs=1M count=2
tar cf test.tar test.img
output=$(
../fish/guestfish 2>&1 <<'EOF'
../../fish/guestfish 2>&1 <<'EOF'
add test.img
run
mkfs ext2 /dev/sda

View File

@@ -22,7 +22,7 @@
set -e
export LANG=C
guestfish=../fish/guestfish
guestfish=../../fish/guestfish
rm -f test.img test.output

View File

@@ -27,7 +27,7 @@ rm -f test.img
truncate -s 100M test.img
../fish/guestfish <<EOF
../../fish/guestfish <<EOF
add-drive-with-if test.img ide
run
mkfs ext3 /dev/sda

View File

@@ -23,7 +23,7 @@
set -e
export LANG=C
guestfish=../fish/guestfish
guestfish=../../fish/guestfish
output=rhbz727178.output
rm -f binaries.tmp $output