tests: Extend $TEST_FUNCTIONS with predefined functions for skipping tests etc.

Apply this change across all the shell scripts containing tests.

Additionally this defines the environment variables $abs_srcdir,
$abs_builddir, $top_srcdir, $top_builddir, $abs_top_srcdir and
$abs_top_builddir which can now be used throughout test scripts.
This commit is contained in:
Richard W.M. Jones
2017-02-18 15:09:13 +00:00
parent e66be44016
commit a1b3d8d04b
179 changed files with 1018 additions and 1464 deletions

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-alignment-scan.pod virt-alignment-scan
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-alignment-scan.pod virt-alignment-scan

View File

@@ -16,15 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
if [ -n "$SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH" ]; then
echo "$0: skipping test because SKIP_TEST_VIRT_ALIGNMENT_SCAN_GUESTS_SH is set."
exit 77
fi
guestsdir="$(cd ../test-data/phony-guests && pwd)"
libvirt_uri="test://$guestsdir/guests-all-good.xml"
libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests-all-good.xml"
$VG virt-alignment-scan -c "$libvirt_uri"
r=$?

View File

@@ -16,7 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
$VG virt-alignment-scan --format=raw -a ../test-data/phony-guests/fedora.img
r=$?

View File

@@ -19,13 +19,8 @@
# Test that the correct 'complete' command is included in the script.
# Mainly prevents symlinking errors and some omissions.
unset CDPATH
export LANG=C
if [ -n "$SKIP_TEST_COMPLETE_IN_SCRIPT_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
if [ -z "$commands" ]; then
echo "$0: \$commands is not defined. Use 'make check' to run this test."

View File

@@ -24,19 +24,11 @@
# The script currently assumes a Linux guest. We should test Windows,
# FreeBSD in future (XXX).
export LANG=C
set -e
if [ -z "$SLOW" ]; then
echo "$script: use 'make check-slow' to run this test"
exit 77
fi
skipenv="$(echo SKIP_$script | tr a-z.- A-Z__)"
if [ -n "${!skipenv}" ]; then
echo "$script: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
slow_test
skip_if_skipped "$script"
guestname="$1"
if [ -z "$guestname" ]; then
@@ -46,23 +38,14 @@ fi
# If the guest doesn't exist in virt-builder, skip. This is because
# we test some RHEL guests which most users won't have access to.
if ! virt-builder -l "$guestname" >/dev/null 2>&1; then
echo "$script: test skipped because \"$guestname\" not known to virt-builder."
exit 77
fi
skip_unless_virt_builder_guest "$guestname"
# We can only run the tests on x86_64.
if [ "$(uname -m)" != "x86_64" ]; then
echo "$script: test skipped because !x86_64."
exit 77
fi
skip_unless_arch x86_64
# Check qemu is installed.
qemu=qemu-system-x86_64
if ! $qemu -help >/dev/null 2>&1; then
echo "$script: test skipped because $qemu not found."
exit 77
fi
skip_unless $qemu -help
# Some guests need special virt-builder parameters.
# See virt-builder --notes "$guestname"

View File

@@ -16,10 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-builder.pod virt-builder \
--insert $srcdir/../customize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \
--insert $srcdir/../customize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-builder.pod virt-builder \
--insert $top_srcdir/customize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \
--insert $top_srcdir/customize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \
--ignore=--check-signatures,--no-check-signatures

View File

@@ -16,10 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
abs_builddir=$(pwd)
$TEST_FUNCTIONS
skip_if_skipped
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-simplestreams"

View File

@@ -18,10 +18,10 @@
# Test the virt-builder --list [--long] options.
export LANG=C
set -e
abs_builddir=$(pwd)
$TEST_FUNCTIONS
skip_if_skipped
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"

View File

@@ -16,34 +16,21 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
abs_builddir=$(pwd)
$TEST_FUNCTIONS
slow_test
skip_if_skipped
skip_if_backend uml
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
if [ -z "$SLOW" ]; then
echo "$0: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_VIRT_BUILDER_PLANNER_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
if [ ! -f fedora.xz -o ! -f fedora.qcow2 -o ! -f fedora.qcow2.xz ]; then
echo "$0: test skipped because there is no fedora.xz, fedora.qcow2 or fedora.qcow2.xz in the build directory"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because backend is UML"
exit 77
fi
rm -f planner-output
for input in phony-fedora phony-fedora-qcow2 phony-fedora-qcow2-uncompressed phony-fedora-no-format; do

View File

@@ -16,19 +16,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
abs_builddir=$(pwd)
$TEST_FUNCTIONS
skip_if_skipped
export XDG_CONFIG_HOME=
export XDG_CONFIG_DIRS="$abs_builddir/test-config"
if [ -n "$SKIP_TEST_VIRT_BUILDER_SH" ]; then
echo "$0: skipping test because environment variable is set."
exit 77
fi
if [ ! -f fedora.xz ]; then
echo "$0: test skipped because there is no fedora.xz in the build directory"
exit 77

View File

@@ -16,12 +16,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-cat.pod virt-cat
$srcdir/../podcheck.pl virt-filesystems.pod virt-filesystems
$srcdir/../podcheck.pl virt-log.pod virt-log
$srcdir/../podcheck.pl virt-ls.pod virt-ls \
--ignore=--checksums,--extra-stat,--time,--uid
$srcdir/../podcheck.pl virt-tail.pod virt-tail
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-cat.pod virt-cat
$top_srcdir/podcheck.pl virt-filesystems.pod virt-filesystems
$top_srcdir/podcheck.pl virt-log.pod virt-log
$top_srcdir/podcheck.pl virt-ls.pod virt-ls \
--ignore=--checksums,--extra-stat,--time,--uid
$top_srcdir/podcheck.pl virt-tail.pod virt-tail

View File

@@ -16,9 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Read out the test files from the image using virt-cat.
if [ "$($VG virt-cat --format=raw -a ../test-data/phony-guests/fedora.img /etc/test1)" != "abcdefg" ]; then
echo "$0: error: mismatch in file test1"

View File

@@ -16,9 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
output="$($VG virt-filesystems --format=raw -a ../test-data/phony-guests/fedora.img | sort)"
expected="/dev/VG/LV1
/dev/VG/LV2

View File

@@ -16,9 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
can_handle ()
{
fn=$(basename $1)

View File

@@ -16,9 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Read out the test directory using virt-ls.
if [ "$($VG virt-ls --format=raw -a ../test-data/phony-guests/fedora.img /bin)" != "ls
test1

View File

@@ -21,17 +21,16 @@
# in the guestfish instance we append to the file, and we check that
# the addenda are displayed by virt-tail.
export LANG=C
set -e
set -x
$TEST_FUNCTIONS
skip_if_skipped
# Libvirt screws with the SELinux labels, preventing guestfish from
# continuing to write to the original disk. Therefore only run this
# test when using direct access.
if [ "$(guestfish get-backend)" != "direct" ]; then
echo "$0: test skipped because default backend is not 'direct'"
exit 77
fi
skip_unless_backend direct
out=test-virt-tail.out
disk=test-virt-tail.disk

View File

@@ -21,18 +21,11 @@
# NB. 'test-firstboot.sh' runs the tests, but the various tests are
# run via the 'test-firstboot-GUESTNAME.sh' wrappers.
export LANG=C
set -e
if [ -z "$SLOW" ]; then
echo "$script: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_FIRSTBOOT_SH" ]; then
echo "$script: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
slow_test
skip_if_skipped "$script"
guestname="$1"
if [ -z "$guestname" ]; then
@@ -45,23 +38,14 @@ rm -f "$disk"
# If the guest doesn't exist in virt-builder, skip. This is because
# we test some RHEL guests which most users won't have access to.
if ! virt-builder -l "$guestname" >/dev/null 2>&1; then
echo "$script: test skipped because \"$guestname\" not known to virt-builder."
exit 77
fi
skip_unless_virt_builder_guest "$guestname"
# We can only run the tests on x86_64.
if [ "$(uname -m)" != "x86_64" ]; then
echo "$script: test skipped because !x86_64."
exit 77
fi
skip_unless_arch x86_64
# Check qemu is installed.
qemu=qemu-system-x86_64
if ! $qemu -help >/dev/null 2>&1; then
echo "$script: test skipped because $qemu not found."
exit 77
fi
skip_unless $qemu -help
# Some guests need special virt-builder parameters.
# See virt-builder --notes "$guestname"

View File

@@ -21,19 +21,12 @@
# NB. 'test-settings.sh' runs the tests, but the various tests are
# run via the 'test-settings-GUESTNAME.sh' wrappers.
export LANG=C
set -e
set -x
if [ -z "$SLOW" ]; then
echo "$script: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_SETTINGS_SH" ]; then
echo "$script: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
slow_test
skip_if_skipped "$script"
guestname="$1"
if [ -z "$guestname" ]; then
@@ -46,23 +39,14 @@ rm -f "$disk" "$disk.firstboot.sh" "$disk.firstboot.out"
# If the guest doesn't exist in virt-builder, skip. This is because
# we test some RHEL guests which most users won't have access to.
if ! virt-builder -l "$guestname" >/dev/null 2>&1; then
echo "$script: test skipped because \"$guestname\" not known to virt-builder."
exit 77
fi
skip_unless_virt_builder_guest "$guestname"
# We can only run the tests on x86_64.
if [ "$(uname -m)" != "x86_64" ]; then
echo "$script: test skipped because !x86_64."
exit 77
fi
skip_unless_arch x86_64
# Check qemu is installed.
qemu=qemu-system-x86_64
if ! $qemu -help >/dev/null 2>&1; then
echo "$script: test skipped because $qemu not found."
exit 77
fi
skip_unless $qemu -help
# Some guests need special virt-builder parameters.
# See virt-builder --notes "$guestname"

View File

@@ -16,10 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-customize.pod virt-customize \
--insert $srcdir/../customize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \
--insert $srcdir/../customize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \
$TEST_FUNCTIONS
$top_srcdir/podcheck.pl virt-customize.pod virt-customize \
--insert $top_srcdir/customize/customize-synopsis.pod:__CUSTOMIZE_SYNOPSIS__ \
--insert $top_srcdir/customize/customize-options.pod:__CUSTOMIZE_OPTIONS__ \
--ignore=--dryrun

View File

@@ -16,21 +16,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
set -x
if [ -n "$SKIP_TEST_VIRT_CUSTOMIZE_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
f=../test-data/phony-guests/fedora.img
if [ ! -s $f ]; then
echo "$0: test skipped because there is no fedora.img"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_phony_guest fedora.img
f=$top_builddir/test-data/phony-guests/fedora.img
fq=test-virt-customize-img.qcow
out=test-virt-customize.out
rm -f $fq $out

View File

@@ -16,7 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-df.pod virt-df
$TEST_FUNCTIONS
$top_srcdir/podcheck.pl virt-df.pod virt-df

View File

@@ -18,15 +18,11 @@
# Run virt-df on the test guests.
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_DF_GUESTS_SH" ]; then
echo "$0: skipping test because SKIP_TEST_DF_GUESTS_SH is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
guestsdir="$(cd ../test-data/phony-guests && pwd)"
libvirt_uri="test://$guestsdir/guests.xml"
libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"
$VG virt-df -c "$libvirt_uri"

View File

@@ -16,9 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
# Run virt-df.
output=$($VG virt-df --format=raw -a ../test-data/phony-guests/fedora.img)

View File

@@ -16,7 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-dib.pod virt-dib
$TEST_FUNCTIONS
$top_srcdir/podcheck.pl virt-dib.pod virt-dib

View File

@@ -16,8 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-diff.pod virt-diff \
$TEST_FUNCTIONS
$top_srcdir/podcheck.pl virt-diff.pod virt-diff \
--ignore=--checksums,--dir-link,--dir-nlink,--dir-nlinks,--dir-time,--extra-stat,--time,--uid,--xattr

View File

@@ -16,18 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
if [ ! -f ../test-data/phony-guests/fedora.img ]; then
echo "$0: test skipped because there is no phony fedora test image"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because backend is UML"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_if_backend uml
skip_unless_phony_guest fedora.img
rm -f fedora.qcow2

View File

@@ -644,7 +644,9 @@ normal test.
=item *
Modify the test so it checks if the C<SLOW=1> environment variable is
set, and if I<not> set it skips (ie. returns with exit code 77).
set, and if I<not> set it skips (ie. returns with exit code 77). If
using C<$TEST_FUNCTIONS>, you can call the function C<slow_test> for
this.
=item *

View File

@@ -16,7 +16,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-edit.pod virt-edit
$TEST_FUNCTIONS
$top_srcdir/podcheck.pl virt-edit.pod virt-edit

View File

@@ -16,13 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support qcow2"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML backend does not support qcow2.
skip_if_backend uml
rm -f test.qcow2

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-a.out
rm -f test-a.img

View File

@@ -20,11 +20,12 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-add-domain-{1,2,3,4}.img
rm -f test-add-domain.xml test-add-domain.out
cwd="$(pwd)"
$VG guestfish sparse test-add-domain-1.img 1M
$VG guestfish sparse test-add-domain-2.img 1M
$VG guestfish disk-create test-add-domain-3.img qcow2 1M
@@ -42,22 +43,22 @@ cat > test-add-domain.xml <<EOF
<memory>524288</memory>
<devices>
<disk type="file">
<source file="$cwd/test-add-domain-1.img"/>
<source file="$abs_builddir/test-add-domain-1.img"/>
<target dev="hda"/>
</disk>
<disk type="file">
<driver name="qemu" type="raw"/>
<source file="$cwd/test-add-domain-2.img"/>
<source file="$abs_builddir/test-add-domain-2.img"/>
<target dev="hdb"/>
</disk>
<disk type="file">
<driver name="qemu" type="qcow2"/>
<source file="$cwd/test-add-domain-3.img"/>
<source file="$abs_builddir/test-add-domain-3.img"/>
<target dev="hdc"/>
</disk>
<disk type="file">
<driver name="qemu" type="raw"/>
<source file="$cwd/test-add-domain-4.img"/>
<source file="$abs_builddir/test-add-domain-4.img"/>
<target dev="hdd"/>
<readonly/>
</disk>
@@ -67,7 +68,7 @@ cat > test-add-domain.xml <<EOF
EOF
$VG guestfish >test-add-domain.out <<EOF
domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true
domain guest libvirturi:test://$abs_builddir/test-add-domain.xml readonly:true
debug-drives
EOF
grep -sq "test-add-domain-1.img readonly" test-add-domain.out
@@ -77,7 +78,7 @@ grep -sq "test-add-domain-3.img readonly format=qcow2" test-add-domain.out
# Test readonlydisk = "ignore".
$VG guestfish >test-add-domain.out <<EOF
-domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true readonlydisk:ignore
-domain guest libvirturi:test://$abs_builddir/test-add-domain.xml readonly:true readonlydisk:ignore
debug-drives
EOF
grep -sq "test-add-domain-1.img" test-add-domain.out
@@ -89,7 +90,7 @@ grep -sq "test-add-domain-3.img" test-add-domain.out
rm test-add-domain-3.img
$VG guestfish >test-add-domain.out <<EOF
-domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true
-domain guest libvirturi:test://$abs_builddir/test-add-domain.xml readonly:true
debug-drives
EOF
! grep -sq "test-add-domain-1.img" test-add-domain.out

View File

@@ -21,6 +21,9 @@
set -e
set -x
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-add-uri.out
rm -f test-add-uri.img
@@ -34,7 +37,7 @@ function fail ()
}
# file:// URI should be handled exactly like a regular file.
$VG guestfish -x -a file://$(pwd)/test-add-uri.img </dev/null >test-add-uri.out 2>&1
$VG guestfish -x -a file://$abs_builddir/test-add-uri.img </dev/null >test-add-uri.out 2>&1
grep -sq 'add_drive ".*/test-add-uri.img"' test-add-uri.out || fail
# curl

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-alloc.img
$VG guestfish alloc test-alloc.img 200000

View File

@@ -18,6 +18,11 @@
# Test guestfish copy-in and copy-out commands.
set -e
$TEST_FUNCTIONS
skip_if_skipped
# This test fails on some versions of mock which lack /dev/fd
# directory. Skip this test in that case.
@@ -26,8 +31,6 @@ test -d /dev/fd || {
exit 77
}
set -e
rm -f test-copy.img
rm -rf test-copy-original test-copy-copy

View File

@@ -20,11 +20,12 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-d-{1,2,3,4}.img
rm -f test-d.xml test-d.out
cwd="$(pwd)"
$VG guestfish sparse test-d-1.img 1M
$VG guestfish sparse test-d-2.img 1M
$VG guestfish disk-create test-d-3.img qcow2 1M
@@ -42,22 +43,22 @@ cat > test-d.xml <<EOF
<memory>524288</memory>
<devices>
<disk type="file">
<source file="$cwd/test-d-1.img"/>
<source file="$abs_builddir/test-d-1.img"/>
<target dev="hda"/>
</disk>
<disk type="file">
<driver name="qemu" type="raw"/>
<source file="$cwd/test-d-2.img"/>
<source file="$abs_builddir/test-d-2.img"/>
<target dev="hdb"/>
</disk>
<disk type="file">
<driver name="qemu" type="qcow2"/>
<source file="$cwd/test-d-3.img"/>
<source file="$abs_builddir/test-d-3.img"/>
<target dev="hdc"/>
</disk>
<disk type="file">
<driver name="qemu" type="raw"/>
<source file="$cwd/test-d-4.img"/>
<source file="$abs_builddir/test-d-4.img"/>
<target dev="hdd"/>
<readonly/>
</disk>
@@ -66,7 +67,7 @@ cat > test-d.xml <<EOF
</node>
EOF
$VG guestfish -c "test://$cwd/test-d.xml" --ro -d guest \
$VG guestfish -c "test://$abs_builddir/test-d.xml" --ro -d guest \
debug-drives </dev/null >test-d.out
grep -sq "test-d-1.img readonly" test-d.out
! grep -sq "test-d-1.img.*format" test-d.out

View File

@@ -16,10 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl guestfish.pod guestfish \
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl guestfish.pod guestfish \
--insert $srcdir/guestfish-actions.pod:__ACTIONS__ \
--insert $srcdir/guestfish-commands.pod:__FISH_COMMANDS__ \
--insert $srcdir/guestfish-prepopts.pod:__PREPOPTS__ \

View File

@@ -18,6 +18,11 @@
# Test guestfish edit command.
set -e
$TEST_FUNCTIONS
skip_if_skipped
# This test fails on some versions of mock which lack /dev/fd
# directory. Skip this test in that case.
@@ -26,8 +31,6 @@ test -d /dev/fd || {
exit 77
}
set -e
rm -f test-edit.img
# The command will be 'echo ... >>/tmp/tmpfile'

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test.output test.error test.error.old
$VG guestfish <<'EOF' 2>test.error | od -b > test.output

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-events.out
$VG guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' | grep -v 'library command' | grep -v 'get_path' > test-events.out

View File

@@ -19,7 +19,9 @@
# Test guestfish file attributes commands (chmod, copy-attributes, etc).
set -e
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-file-attrs.out

View File

@@ -20,10 +20,14 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_test_iso
rm -f test-find0.out
$VG guestfish <<'EOF'
add-ro ../test-data/test.iso
$VG guestfish <<EOF
add-ro $top_builddir/test-data/test.iso
run
mount-ro /dev/sda /
find0 / test-find0.out

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-glob.img test-glob.out
$VG guestfish -N test-glob.img=disk:1G > test-glob.out <<EOF

View File

@@ -18,4 +18,11 @@
set -e
$VG guestfish --ro --format=raw -a ../test-data/phony-guests/fedora.img -i exit
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_phony_guest fedora.img
$VG guestfish \
--ro --format=raw -a $top_builddir/test-data/phony-guests/fedora.img \
-i \
exit

View File

@@ -21,6 +21,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Memory size
output=$(
$VG guestfish <<EOF

View File

@@ -18,18 +18,9 @@
# Test guestfish mount-local / mount-local-run commands.
if [ -n "$SKIP_TEST_MOUNT_LOCAL_SH" ]; then
echo "$0: skipping test because SKIP_TEST_MOUNT_LOCAL_SH is set."
exit 77
fi
# Skip if no FUSE.
test -w /dev/fuse || {
echo "$0: Skipping this test"
echo " because /dev/fuse is missing or not writable by the current user."
exit 77
}
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_fuse
set -e

View File

@@ -20,15 +20,19 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_test_iso
rm -f test-read-file.out
$VG guestfish <<'EOF' > test-read-file.out
add-ro ../test-data/test.iso
$VG guestfish <<EOF > test-read-file.out
add-ro $top_builddir/test-data/test.iso
run
mount-ro /dev/sda /
read-file /helloworld.tar
EOF
cmp $srcdir/../test-data/files/helloworld.tar test-read-file.out
cmp $top_srcdir/test-data/files/helloworld.tar test-read-file.out
rm -f test-read-file.out

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
eval "$(guestfish --listen)"
$VG guestfish --remote event close_event close "echo closed"

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-remote.img
eval `guestfish --listen`

View File

@@ -21,6 +21,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-reopen.img
$VG guestfish <<'EOF'

View File

@@ -18,4 +18,10 @@
set -e
$VG guestfish --ro --format=raw -a ../test-data/phony-guests/fedora.img run
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_phony_guest fedora.img
$VG guestfish \
--ro --format=raw -a $top_builddir/test-data/phony-guests/fedora.img \
run

View File

@@ -20,6 +20,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-stringlist.img
eval `guestfish --listen`

View File

@@ -23,6 +23,9 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Don't rely on $HOME being set when this script is called.
HOME=$(pwd)
export HOME

View File

@@ -22,9 +22,16 @@
set -e
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_test_iso
rm -f test-upload-to-dir.img test-upload-to-dir.out
if $VG guestfish -N test-upload-to-dir.img=fs -m /dev/sda1 upload ../test-data/test.iso / 2>test-upload-to-dir.out
if $VG guestfish \
-N test-upload-to-dir.img=fs \
-m /dev/sda1 \
upload $top_builddir/test-data/test.iso / 2>test-upload-to-dir.out
then
echo "$0: expecting guestfish to return an error"
exit 1

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-format.pod virt-format
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-format.pod virt-format

View File

@@ -20,10 +20,8 @@
set -e
if [ -n "$SKIP_TEST_VIRT_FORMAT_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-virt-format.img

View File

@@ -16,11 +16,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl guestmount.pod guestmount
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl guestmount.pod guestmount
# guestunmount doesn't implement bash completion, so we cannot
# test it at the moment. XXX
#$srcdir/../podcheck.pl guestunmount.pod guestunmount
#$top_srcdir/podcheck.pl guestunmount.pod guestunmount

View File

@@ -19,34 +19,15 @@
# https://bugzilla.redhat.com/show_bug.cgi?id=838592
# This tests that the --pid-file option can be used to fix the race.
unset CDPATH
set -e
#set -v
if [ -n "$SKIP_TEST_FUSE_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
if [ -n "$SKIP_TEST_FUSE_UMOUNT_RACE_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
if [ ! -w /dev/fuse ]; then
echo "$0: test skipped because there is no /dev/fuse."
exit 77
fi
if [ ! -f ../test-data/phony-guests/fedora.img ]; then
echo "$0: test skipped because fedora.img test guest does not exist."
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because uml backend does not support qcow2"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped "test-fuse.sh"
skip_if_skipped
skip_unless_phony_guest fedora.img
# UML backend does not support qcow2.
skip_if_backend uml
skip_unless_fuse
rm -f test.qcow2 test-copy.qcow2 test.pid
rm -rf mp

View File

@@ -20,27 +20,13 @@
# Test that guestunmount returns the correct error code if
# there is no mounted FUSE filesystem.
unset CDPATH
#set -e
#set -v
if [ -n "$SKIP_TEST_FUSE_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
if [ -n "$SKIP_TEST_GUESTUNMOUNT_NOT_MOUNTED_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
if [ ! -w /dev/fuse ]; then
echo "SKIPPING guestunmount test, because there is no /dev/fuse."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped "test-fuse.sh"
skip_if_skipped
skip_unless_fuse
# Not expecting cwd to be a FUSE mountpoint.
guestunmount --quiet $(pwd)
guestunmount --quiet $abs_builddir
r=$?
case $r in
0)

View File

@@ -1163,6 +1163,9 @@ and generate_fish_test_prep_sh () =
pr "\
set -e
$TEST_FUNCTIONS
skip_if_skipped
rm -f %s
$VG guestfish \\

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-get-kernel.pod virt-get-kernel
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-get-kernel.pod virt-get-kernel

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-inspector.pod virt-inspector
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-inspector.pod virt-inspector

View File

@@ -16,15 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
set -x
# Allow this test to be skipped.
if [ -n "$SKIP_TEST_VIRT_INSPECTOR_SH" ]; then
echo "$0: skipping test because SKIP_TEST_VIRT_INSPECTOR_SH is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# ntfs-3g can't set UUIDs right now, so ignore just that <uuid>.
diff_ignore="-I <uuid>[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]</uuid>"

View File

@@ -16,9 +16,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
for f in $srcdir/example-*.xml; do
@XMLLINT@ --noout --relaxng $srcdir/virt-inspector.rng $f
done

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-make-fs.pod virt-make-fs --ignore=--debug
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-make-fs.pod virt-make-fs --ignore=--debug

View File

@@ -20,9 +20,11 @@
# copied from the original Perl tool virt-make-fs, on the basis that
# the new C tool should be able to pass the same tests.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
# Check which filesystems are supported by the appliance.
eval $(
perl -MSys::Guestfs -e '

View File

@@ -22,6 +22,9 @@
set -e
set -x
$TEST_FUNCTIONS
skip_if_skipped
t=./getopt_tests
expect_fail ()

View File

@@ -18,14 +18,10 @@
# Test virt-p2v command line parsing in non-GUI mode.
unset CDPATH
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_P2V_CMDLINE_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
out=test-virt-p2v-cmdline.out
rm -f $out

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-p2v.pod virt-p2v
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-p2v.pod virt-p2v

View File

@@ -18,38 +18,19 @@
# Test virt-p2v in non-GUI mode using nbdkit instead of qemu-nbd.
unset CDPATH
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_P2V_NBDKIT_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_if_backend uml
skip_unless nbdkit file --version
skip_unless_phony_guest windows.img
skip_unless_phony_guest blank-part.img
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because UML backend does not support network"
exit 77
fi
f1="$abs_top_builddir/test-data/phony-guests/windows.img"
f2="$abs_top_builddir/test-data/phony-guests/blank-part.img"
if ! nbdkit file --version; then
echo "$0: test skipped because nbdkit file plugin is not installed or not working"
exit 77
fi
guestsdir="$(cd ../test-data/phony-guests && pwd)"
f1="$guestsdir/windows.img"
if ! test -f $f1 || ! test -s $f1; then
echo "$0: test skipped because phony Windows image was not created"
exit 77
fi
f2="$guestsdir/blank-part.img"
if ! test -f $f2 || ! test -s $f2; then
echo "$0: test skipped because blank-part.img was not created"
exit 77
fi
export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
d=test-virt-p2v-nbdkit.d
rm -rf $d

View File

@@ -24,35 +24,16 @@
# * networking
# * virt-p2v in kernel command-line mode
unset CDPATH
export LANG=C
set -e
if [ -z "$SLOW" ]; then
echo "$0: use 'make check-slow' to run this test"
exit 77
fi
if [ -n "$SKIP_TEST_VIRT_P2V_PXE_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because UML backend does not support network"
exit 77
fi
if [ "$(uname -m)" != "x86_64" ]; then
echo "$0: test skipped because !x86_64"
exit 77
fi
$TEST_FUNCTIONS
slow_test
skip_if_skipped
skip_if_backend uml
skip_unless_arch x86_64
qemu=qemu-system-x86_64
if ! $qemu -help >/dev/null 2>&1; then
echo "$0: test skipped because $qemu not found"
exit 77
fi
skip_unless $qemu -help
img="test-virt-p2v-pxe.img"
if ! test -f $img; then
@@ -60,12 +41,8 @@ if ! test -f $img; then
exit 77
fi
guestsdir="$(cd ../test-data/phony-guests && pwd)"
f="$guestsdir/windows.img"
if ! test -f $f; then
echo "$0: test skipped because phony Windows image was not created"
exit 77
fi
skip_unless_phony_guest windows.img
f="$top_builddir/test-data/phony-guests/windows.img"
virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools}
if ! test -r $virt_tools_data_dir/rhsrvany.exe; then

View File

@@ -18,33 +18,18 @@
# Test virt-p2v in non-GUI mode.
unset CDPATH
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_P2V_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_if_backend uml
skip_unless_phony_guest windows.img
skip_unless_phony_guest blank-part.img
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because UML backend does not support network"
exit 77
fi
f1="$abs_top_builddir/test-data/phony-guests/windows.img"
f2="$abs_top_builddir/test-data/phony-guests/blank-part.img"
guestsdir="$(cd ../test-data/phony-guests && pwd)"
f1="$guestsdir/windows.img"
if ! test -f $f1 || ! test -s $f1; then
echo "$0: test skipped because phony Windows image was not created"
exit 77
fi
f2="$guestsdir/blank-part.img"
if ! test -f $f2 || ! test -s $f2; then
echo "$0: test skipped because blank-part.img was not created"
exit 77
fi
export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
d=test-virt-p2v.d
rm -rf $d

View File

@@ -16,7 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-rescue.pod virt-rescue
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-rescue.pod virt-rescue

View File

@@ -16,15 +16,13 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
guest=../test-data/phony-guests/fedora.img
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_phony_guest fedora.img
if [ ! -s "$guest" ]; then
echo "$0: test skipped because $guest does not exist or is an empty file"
exit 77
fi
guest="$top_builddir/test-data/phony-guests/fedora.img"
rm -f virt-rescue-suggest.out

View File

@@ -16,8 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-resize.pod virt-resize \
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-resize.pod virt-resize \
--ignore=--LVexpand,--lv-expand,--lvexpand,--dryrun

View File

@@ -16,8 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-sparsify.pod virt-sparsify \
--ignore=--inplace
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-sparsify.pod virt-sparsify \
--ignore=--inplace

View File

@@ -29,19 +29,13 @@
#
# The reason why vfat is significant is because UEFI guests use it.
export LANG=C
set -e
set -x
if [ -n "$SKIP_TEST_VIRT_SPARSIFY_IN_PLACE_FSTRIM_UNSUPPORTED_SH" ]; then
echo "$0: skipping test (environment variable set)"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support discard"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML does not support discard.
skip_if_backend uml
img=test-virt-sparsify-in-place-fstrim-unsupported.img
log=test-virt-sparsify-in-place-fstrim-unsupported.log

View File

@@ -16,18 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_SPARSIFY_IN_PLACE_SH" ]; then
echo "$0: skipping test (environment variable set)"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support discard"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML does not support discard.
skip_if_backend uml
rm -f test-virt-sparsify-in-place.img

View File

@@ -16,13 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support qcow2"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML does not support qcow2.
skip_if_backend uml
rm -f test-virt-sparsify-1.img test-virt-sparsify-2.img

View File

@@ -91,4 +91,20 @@ endif
# Test shell scripts should use '$TEST_FUNCTIONS' to get a predefined
# set of helper functions for running tests (see
# tests/test-functions.sh).
export TEST_FUNCTIONS := source $(abs_top_srcdir)/tests/test-functions.sh
#
# Notes:
#
# (1) This is in fact a single command all on one line. The variables
# are evaluated in test-functions.sh.
#
# (2) We use absolute paths here and in test-functions.sh so that the
# test can change directory freely. But we also include the
# non-absolute values so they can be used by the test script itself.
export TEST_FUNCTIONS := \
source $(abs_top_srcdir)/tests/test-functions.sh \
abs_srcdir="$(abs_srcdir)" \
abs_builddir="$(abs_builddir)" \
top_srcdir="$(top_srcdir)" \
top_builddir="$(top_builddir)" \
abs_top_srcdir="$(abs_top_srcdir)" \
abs_top_builddir="$(abs_top_builddir)"

View File

@@ -175,9 +175,6 @@ sysprep-operations.pod: virt-sysprep
# Tests.
TESTS_ENVIRONMENT = \
abs_builddir=$(abs_builddir) \
abs_srcdir=$(abs_srcdir) \
PATH=$(abs_top_builddir)/fuse:$(PATH) \
$(top_builddir)/run --test
TESTS = \

View File

@@ -16,20 +16,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
# Test removal of editor backup files.
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support qcow2"
exit 77
fi
set -e
if [ ! -s ../test-data/phony-guests/fedora.img ]; then
echo "$0: skipping test because there is no phony Fedora test image"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML does not support qcow2.
skip_if_backend uml
skip_unless_phony_guest fedora.img
f=$top_builddir/test-data/phony-guests/fedora.img
rm -f test-backup-files.qcow2
rm -f test-backup-files-before
@@ -38,10 +35,9 @@ rm -f test-backup-files-after
# Add some backup files to the Fedora image.
guestfish -- \
disk-create test-backup-files.qcow2 qcow2 -1 \
backingfile:../test-data/phony-guests/fedora.img \
backingformat:raw
backingfile:$f backingformat:raw
guestfish --format=qcow2 -a test-backup-files.qcow2 -i <<'EOF'
# /bin and /usr are not on the whitelist, so these file shouldn't be deleted.
# /bin and /usr are not on the whitelist, so these files shouldn't be deleted.
touch /bin/test~
touch /usr/share/test~
find / | cat > test-backup-files-before

View File

@@ -16,10 +16,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
$srcdir/../podcheck.pl virt-sysprep.pod virt-sysprep \
$TEST_FUNCTIONS
skip_if_skipped
$top_srcdir/podcheck.pl virt-sysprep.pod virt-sysprep \
--insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
--insert sysprep-operations.pod:__OPERATIONS__ \
--ignore=--dryrun,--dump-pod,--dump-pod-options,--no-selinux-relabel

View File

@@ -16,20 +16,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
# Test all the combinations of password options.
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support qcow2"
exit 77
fi
set -e
if [ ! -s ../test-data/phony-guests/fedora.img ]; then
echo "$0: skipping test because there is no phony Fedora test image"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# UML backend does not support qcow2.
skip_if_backend uml
skip_unless_phony_guest fedora.img
f=$top_builddir/test-data/phony-guests/fedora.img
# For this test to work, we need a guest with several user accounts,
# so we fake that now.
@@ -37,7 +34,7 @@ fi
rm -f passwords.qcow2 password
guestfish -- \
disk-create passwords.qcow2 qcow2 -1 \
backingfile:../test-data/phony-guests/fedora.img backingformat:raw
backingfile:$f backingformat:raw
guestfish -a passwords.qcow2 -i <<'EOF'
write-append /etc/shadow "test01::15677:0:99999:7:::\n"

View File

@@ -16,23 +16,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
#set -x
if [ -n "$SKIP_TEST_VIRT_SYSPREP_SCRIPT_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_fuse
skip_unless_phony_guest fedora.img
if [ ! -w /dev/fuse ]; then
echo "$0: SKIPPING test, because there is no /dev/fuse."
exit 77
fi
f=$top_builddir/test-data/phony-guests/fedora.img
# Export it down to the test scripts.
export abs_builddir
# Check that multiple scripts can run.
rm -f stamp-script1.sh stamp-script2.sh stamp-script4.sh
if ! virt-sysprep -q -n --format raw -a ../test-data/phony-guests/fedora.img --enable script \
if ! virt-sysprep -q -n --format raw -a $f --enable script \
--script $abs_srcdir/script1.sh --script $abs_srcdir/script2.sh; then
echo "$0: virt-sysprep wasn't expected to exit with error."
exit 1
@@ -43,19 +42,19 @@ if [ ! -f stamp-script1.sh -o ! -f stamp-script2.sh ]; then
fi
# Check that if a script fails, virt-sysprep exits with an error.
if virt-sysprep -q -n --format raw -a ../test-data/phony-guests/fedora.img --enable script \
if virt-sysprep -q -n --format raw -a $f --enable script \
--script $abs_srcdir/script3.sh; then
echo "$0: virt-sysprep didn't exit with an error."
exit 1
fi
# Check that virt-sysprep uses a new temporary directory every time.
if ! virt-sysprep -q -n --format raw -a ../test-data/phony-guests/fedora.img --enable script \
if ! virt-sysprep -q -n --format raw -a $f --enable script \
--script $abs_srcdir/script4.sh; then
echo "$0: virt-sysprep (script4.sh, try #1) wasn't expected to exit with error."
exit 1
fi
if ! virt-sysprep -q -n --format raw -a ../test-data/phony-guests/fedora.img --enable script \
if ! virt-sysprep -q -n --format raw -a $f --enable script \
--script $abs_srcdir/script4.sh; then
echo "$0: virt-sysprep (script4.sh, try #2) wasn't expected to exit with error."
exit 1

View File

@@ -16,13 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
export LANG=C
set -e
if [ -n "$SKIP_TEST_VIRT_SYSPREP_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
# Get a comma-separated list of the enabled-by-default operations.
operations=$(

View File

@@ -21,5 +21,5 @@ EXTRA_DIST = $(TESTS)
TESTS = test-9p.sh
TESTS_ENVIRONMENT = abs_srcdir=$(abs_srcdir) \
TESTS_ENVIRONMENT = \
$(top_builddir)/run --test

View File

@@ -21,16 +21,9 @@
set -e
if [ -n "$SKIP_TEST_9P_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
backend="$(guestfish get-backend)"
if [[ "$backend" != "direct" ]]; then
echo "$0: test skipped because backend ($backend) is not 'direct'."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_backend direct
# The name of the virtio-9p device is different on virtio-pci and virtio-mmio.
arch="$(uname -m)"

View File

@@ -24,17 +24,9 @@
set -e
# Allow the test to be skipped since btrfs is often broken.
if [ -n "$SKIP_TEST_BTRFS_DEVICES_SH" ]; then
echo "$0: skipping test because environment variable is set."
exit 77
fi
# If btrfs is not available, bail.
if ! guestfish -a /dev/null run : available btrfs; then
echo "$0: skipping test because btrfs is not available"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_feature_available btrfs
rm -f test-btrfs-devices-{1,2,3,4}.img
@@ -55,7 +47,7 @@ mkfs-btrfs "/dev/sda1 /dev/sdb1"
mount /dev/sda1 /
mkdir /data1
tar-in $srcdir/../../test-data/files/filesanddirs-10M.tar.xz /data1 compress:xz
tar-in $top_srcdir/test-data/files/filesanddirs-10M.tar.xz /data1 compress:xz
# In btrfs-progs 0.19, a test was added which prevents us from
# deleting the mount device (/dev/sda1) although that restriction
@@ -68,7 +60,7 @@ btrfs-device-add "/dev/sdb1" /
btrfs-device-delete "/dev/sdc1 /dev/sdd1" /
mkdir /data2
tar-in $srcdir/../../test-data/files/filesanddirs-10M.tar.xz /data2 compress:xz
tar-in $top_srcdir/test-data/files/filesanddirs-10M.tar.xz /data2 compress:xz
btrfs-device-add "/dev/sdc1 /dev/sdd1" /
btrfs-device-delete "/dev/sdb1" /
@@ -76,7 +68,7 @@ btrfs-device-add "/dev/sdb1" /
btrfs-device-delete "/dev/sdc1 /dev/sdd1" /
mkdir /data3
tar-in $srcdir/../../test-data/files/filesanddirs-10M.tar.xz /data3 compress:xz
tar-in $top_srcdir/test-data/files/filesanddirs-10M.tar.xz /data3 compress:xz
btrfs-device-add "/dev/sdc1 /dev/sdd1" /
btrfs-device-delete "/dev/sdb1" /
@@ -84,7 +76,7 @@ btrfs-device-add "/dev/sdb1" /
btrfs-device-delete "/dev/sdc1 /dev/sdd1" /
mkdir /data4
tar-in $srcdir/../../test-data/files/filesanddirs-10M.tar.xz /data4 compress:xz
tar-in $top_srcdir/test-data/files/filesanddirs-10M.tar.xz /data4 compress:xz
btrfs-device-add "/dev/sdc1 /dev/sdd1" /
btrfs-device-delete "/dev/sdb1" /

View File

@@ -20,17 +20,9 @@
set -e
# Allow the test to be skipped since btrfs is often broken.
if [ -n "$SKIP_TEST_BTRFS_REPLACE_SH" ]; then
echo "$0: skipping test because environment variable is set."
exit 77
fi
# If btrfs is not available, bail.
if ! guestfish -a /dev/null run : available btrfs; then
echo "$0: skipping test because btrfs is not available"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_feature_available btrfs
rm -f test-btrfs-replace-{1,2}.img replace.output
@@ -44,7 +36,7 @@ mkfs-btrfs /dev/sda
mount /dev/sda /
mkdir /data
copy-in $srcdir/../../test-data/files/filesanddirs-10M.tar.xz /data
copy-in $top_srcdir/test-data/files/filesanddirs-10M.tar.xz /data
# now, sda is btrfs while sdb is blank.
btrfs-replace /dev/sda /dev/sdb /

View File

@@ -17,14 +17,10 @@
# Test the disk-create API.
export LANG=C
set -e
if [ -n "$SKIP_TEST_DISK_CREATE_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
rm -f disk*.img file:*.img

View File

@@ -23,8 +23,6 @@ TESTS = \
test-qemu-drive.sh
TESTS_ENVIRONMENT = \
abs_srcdir=$(abs_srcdir) \
abs_builddir=$(abs_builddir) \
$(top_builddir)/run --test
EXTRA_DIST = \

View File

@@ -17,29 +17,11 @@
# Test that disks map to the correct qemu -drive parameter.
export LANG=C
set -e
if [ -z "$abs_srcdir" ]; then
echo "$0: abs_srcdir environment variable must be set"
exit 1
fi
if [ -z "$abs_builddir" ]; then
echo "$0: abs_builddir environment variable must be set"
exit 1
fi
if [ ! -x ../../lib/libvirt-is-version ]; then
echo "$0: test skipped because libvirt-is-version is not built yet"
exit 77
fi
if ! ../../lib/libvirt-is-version 1 1 3; then
echo "$0: test skipped because libvirt is too old (< 1.1.3)"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_libvirt_minimum_version 1 1 3
guestfish="guestfish -c test://$abs_builddir/test-qemu-drive-libvirt.xml"

View File

@@ -17,13 +17,14 @@
# Test that disks map to the correct qemu -drive parameter.
export LANG=C
set -e
$TEST_FUNCTIONS
skip_if_skipped
export LIBGUESTFS_BACKEND=direct
export LIBGUESTFS_HV="${abs_srcdir}/debug-qemu.sh"
export DEBUG_QEMU_FILE="${abs_builddir}/test-qemu-drive.out"
export LIBGUESTFS_HV="$abs_srcdir/debug-qemu.sh"
export DEBUG_QEMU_FILE="$abs_builddir/test-qemu-drive.out"
function check_output ()
{

View File

@@ -20,16 +20,9 @@
set -e
[ -n "$SKIP_TEST_LUKS_SH" ] && {
echo "test-luks-list.sh skipped (environment variable set)"
exit 77
}
# If luks is not available, bail.
if ! guestfish -a /dev/null run : available luks; then
echo "$0: skipping test because luks is not available"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_feature_available luks
rm -f test-luks-list.img test-luks-list.out

View File

@@ -20,16 +20,9 @@
set -e
[ -n "$SKIP_TEST_LUKS_SH" ] && {
echo "test-luks.sh skipped (environment variable set)"
exit 77
}
# If luks is not available, bail.
if ! guestfish -a /dev/null run : available luks; then
echo "$0: skipping test because luks is not available"
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_feature_available luks
rm -f test-luks.img

View File

@@ -20,10 +20,8 @@
set -e
if [ -n "$SKIP_TEST_LVM_FILTERING_SH" ]; then
echo "$0: skipping test because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
rm -f test-lvm-filtering-1.img test-lvm-filtering-2.img

View File

@@ -19,18 +19,17 @@
# Test the handling of MD devices specified in /etc/fstab
set -e
export LANG=C
if [ -n "$SKIP_TEST_INSPECT_FSTAB_MD_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
skip_unless_phony_guest fedora-md1.img
skip_unless_phony_guest fedora-md2.img
rm -f inspect-fstab-md-{1,2}.img inspect-fstab-md.fstab inspect-fstab-md.output
# First, test the regular fedora image, which specifies /boot as /dev/md0
cp ../../test-data/phony-guests/fedora-md1.img inspect-fstab-md-1.img
cp ../../test-data/phony-guests/fedora-md2.img inspect-fstab-md-2.img
cp $top_builddir/test-data/phony-guests/fedora-md1.img inspect-fstab-md-1.img
cp $top_builddir/test-data/phony-guests/fedora-md2.img inspect-fstab-md-2.img
guestfish -i --format=raw -a inspect-fstab-md-1.img --format=raw -a inspect-fstab-md-2.img <<'EOF' | sort > inspect-fstab-md.output
exists /boot/grub/grub.conf

View File

@@ -20,22 +20,22 @@
# This also tests: https://bugzilla.redhat.com/668574
set -e
export LANG=C
$TEST_FUNCTIONS
skip_if_skipped
skip_if_backend uml
skip_unless_phony_guest fedora.img
canonical="sed -r s,/dev/[abce-ln-z]+d,/dev/sd,g"
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: skipping test because uml backend does not support qcow2"
exit 77
fi
rm -f inspect-fstab-1.qcow2 inspect-fstab.fstab inspect-fstab.output
# Start with the regular (good) fedora image, modify /etc/fstab
# and then inspect it.
guestfish -- \
disk-create inspect-fstab-1.qcow2 qcow2 -1 \
backingfile:../../test-data/phony-guests/fedora.img backingformat:raw
backingfile:$top_builddir/test-data/phony-guests/fedora.img \
backingformat:raw
cat <<'EOF' > inspect-fstab.fstab
/dev/VG/Root / ext2 default 0 0

View File

@@ -20,10 +20,8 @@
set -e
if [ -n "$SKIP_TEST_LIST_FILESYSTEMS_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 77
fi
$TEST_FUNCTIONS
skip_if_skipped
rm -f list-fs.output

View File

@@ -20,10 +20,8 @@
set -e
if [ -n "$SKIP_TEST_LIST_MD_DEVICES_SH" ]; then
echo "$0: test skipped because environment variable is set."
exit 0
fi
$TEST_FUNCTIONS
skip_if_skipped
output=$(
guestfish <<EOF

Some files were not shown because too many files have changed in this diff Show More