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.
---
docs/guestfs-hacking.pod | 4 +-
subdir-rules.mk | 18 ++++-
tests/test-functions.sh | 121 ++++++++++++++++++++++++++++++-
v2v/test-v2v-bad-networks-and-bridges.sh | 10 +--
v2v/test-v2v-cdrom.sh | 34 ++-------
v2v/test-v2v-conversion-of.sh | 21 +-----
v2v/test-v2v-copy-to-local.sh | 16 +---
v2v/test-v2v-floppy.sh | 33 ++-------
v2v/test-v2v-i-disk.sh | 25 ++-----
v2v/test-v2v-i-ova-formats.sh | 28 ++-----
v2v/test-v2v-i-ova-gz.sh | 14 +---
v2v/test-v2v-i-ova-subfolders.sh | 14 +---
v2v/test-v2v-i-ova-tar.sh | 14 +---
v2v/test-v2v-i-ova-two-disks.sh | 16 +---
v2v/test-v2v-i-ova.sh | 33 ++-------
v2v/test-v2v-in-place.sh | 23 ++----
16 files changed, 198 insertions(+), 226 deletions(-)
diff --git a/docs/guestfs-hacking.pod b/docs/guestfs-hacking.pod
index 43b69e6..8f320cc 100644
--- a/docs/guestfs-hacking.pod
+++ b/docs/guestfs-hacking.pod
@@ -643,7 +643,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 *
diff --git a/subdir-rules.mk b/subdir-rules.mk
index 4926c9c..61ab0d8 100644
--- a/subdir-rules.mk
+++ b/subdir-rules.mk
@@ -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)"
diff --git a/tests/test-functions.sh b/tests/test-functions.sh
index 86a5aaf..f532a93 100755
--- a/tests/test-functions.sh
+++ b/tests/test-functions.sh
@@ -1,6 +1,6 @@
#!/bin/bash -
# libguestfs
-# Copyright (C) 2014 Red Hat Inc.
+# Copyright (C) 2014-2017 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,6 +16,119 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Most of the tests written in shell script source this file for
+# useful functions.
+#
+# To include this file, the test must do:
+#
+# $TEST_FUNCTIONS
+#
+# (this macro is defined in subdir-rules.mk).
+
+# Clean up the environment in every test script.
+unset CDPATH
+export LANG=C
+
+# When test-functions.sh is invoked, a list of variables is passed as
+# parameters, so we eval those to define the variables.
+while [ $# -ge 1 ]; do eval "$1"; shift; done
+
+# Skip if $SKIP_<script_name> environment variable is set.
+# Every test should call this function first.
+skip_if_skipped ()
+{
+ local v="SKIP_$(echo $0 | sed 's,.*/,,' | tr .- _ | tr a-z A-Z)"
+ if [ -n "${!v}" ]; then
+ echo "$(basename $0): test skipped because \$$v is set"
+ exit 77
+ fi
+}
+
+# Skip if the current libguestfs backend is $1.
+# eg. skip_if_backend uml
+skip_if_backend ()
+{
+ local b="$(guestfish get-backend)"
+ case "$1" in
+ # Some magic happens for $1 == libvirt.
+ libvirt)
+ if [ "$b" = "libvirt" ] || [[ "$b" =~ ^libvirt:
]]; then
+ echo "$(basename $0): test skipped because the current backend is
$b"
+ exit 77
+ fi
+ ;;
+ *)
+ if [ "$b" = "$1" ]; then
+ echo "$(basename $0): test skipped because the current backend is
$b"
+ exit 77
+ fi
+ ;;
+ esac
+}
+
+# Skip if the current libguestfs backend is NOT $1.
+skip_unless_backend ()
+{
+ local b="$(guestfish get-backend)"
+ case "$1" in
+ # Some magic happens for $1 == libvirt.
+ libvirt)
+ if [ "$b" != "libvirt" ] && [[ ! "$b"
=~ ^libvirt: ]]; then
+ echo "$(basename $0): this test only runs if the backend is libvirt,
but the current backend is $b"
+ exit 77
+ fi
+ ;;
+ *)
+ if [ "$b" = "$1" ]; then
+ echo "$(basename $0): this test only runs if the backend is $1, but
the current backend is $b"
+ exit 77
+ fi
+ ;;
+ esac
+}
+
+# Skip if the named ($1) disk image in test-data/phony-guests was not
+# created.
+skip_unless_phony_guest ()
+{
+ local f="$abs_top_builddir/test-data/phony-guests/$1"
+ if ! test -f $f || ! test -s $f; then
+ echo "$(basename $0): test skipped because disk image '$1' was not
created"
+ echo "$(basename $0): try running: make -C test-data check"
+ exit 77
+ fi
+}
+
+# Skip if the current arch != $1.
+skip_unless_arch ()
+{
+ local m="$(uname -m)"
+ if [ "$m" != "$1" ]; then
+ echo "$(basename $0): test skipped because the current architecture ($m) is
not $1"
+ exit 77
+ fi
+}
+
+# Run an external command and skip if the command fails. This can be
+# used to test if a command exists. Normally you should use
+# `cmd --help' or `cmd --version' or similar.
+skip_unless ()
+{
+ if ! "$@"; then
+ echo "$(basename $0): test skipped because $1 is not available"
+ exit 77
+ fi
+}
+
+# Slow tests should always call this function. (See guestfs-hacking(1)).
+slow_test ()
+{
+ if [ -z "$SLOW" ]; then
+ echo "$(basename $0): use 'make check-slow' to run this test"
+ exit 77
+ fi
+}
+
do_md5 ()
{
case "$(uname)" in
@@ -23,7 +136,7 @@ do_md5 ()
md5sum "$1" | awk '{print $1}'
;;
*)
- echo "$0: unknown method to calculate MD5 of file on $(uname)"
+ echo "$(basename $0): unknown method to calculate MD5 of file on
$(uname)"
exit 1
;;
esac
@@ -36,7 +149,7 @@ do_sha1 ()
sha1sum "$1" | awk '{print $1}'
;;
*)
- echo "$0: unknown method to calculate SHA1 of file on $(uname)"
+ echo "$(basename $0): unknown method to calculate SHA1 of file on
$(uname)"
exit 1
;;
esac
@@ -49,7 +162,7 @@ do_sha256 ()
sha256sum "$1" | awk '{print $1}'
;;
*)
- echo "$0: unknown method to calculate SHA256 of file on $(uname)"
+ echo "$(basename $0): unknown method to calculate SHA256 of file on
$(uname)"
exit 1
;;
esac
diff --git a/v2v/test-v2v-bad-networks-and-bridges.sh
b/v2v/test-v2v-bad-networks-and-bridges.sh
index f336620..28d457a 100755
--- a/v2v/test-v2v-bad-networks-and-bridges.sh
+++ b/v2v/test-v2v-bad-networks-and-bridges.sh
@@ -18,17 +18,13 @@
# Test detection of duplicate --network and --bridge parameters.
-unset CDPATH
-export LANG=C
set -e
set -x
-if [ -n "$SKIP_TEST_V2V_BAD_NETWORKS_AND_BRIDGES_SH" ]; then
- echo "$0: test skipped because environment variable is set"
- exit 77
-fi
+$TEST_FUNCTIONS
+skip_if_skipped
-# We expect all of these to print an error. NB LANG=C above.
+# We expect all of these to print an error. NB: LANG=C is set.
virt-v2v -i disk -b b1 -b b1 |& grep "duplicate -b"
virt-v2v -i disk -n n1 -n n1 |& grep "duplicate -n"
diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh
index 0679923..0c8680d 100755
--- a/v2v/test-v2v-cdrom.sh
+++ b/v2v/test-v2v-cdrom.sh
@@ -19,37 +19,17 @@
# Test cdrom dev assignment.
#
https://bugzilla.redhat.com/show_bug.cgi?id=1238053
-unset CDPATH
-export LANG=C
set -e
-if [ -n "$SKIP_TEST_V2V_CDROM_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-disk.img
-if [ "$(guestfish get-backend)" = "uml" ]; then
- echo "$0: test skipped because UML backend does not support network"
- exit 77
-fi
-
-abs_builddir="$(pwd)"
libvirt_uri="test://$abs_builddir/test-v2v-cdrom.xml"
-
-f=../test-data/phony-guests/windows.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because phony Windows image was not created"
- exit 77
-fi
-
-f=../test-data/phony-guests/blank-disk.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because blank-disk.img was not created"
- exit 77
-fi
-
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
-export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
d=test-v2v-cdrom.d
rm -rf $d
diff --git a/v2v/test-v2v-conversion-of.sh b/v2v/test-v2v-conversion-of.sh
index a590085..3c98243 100755
--- a/v2v/test-v2v-conversion-of.sh
+++ b/v2v/test-v2v-conversion-of.sh
@@ -18,19 +18,12 @@
# Test virt-v2v on real guests.
-unset CDPATH
-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_V2V_CONVERSION_OF_SH" ]; then
- echo "$script: test skipped because environment variable is set"
- exit 77
-fi
+$TEST_FUNCTIONS
+slow_test
+skip_if_skipped
+skip_unless_arch x86_64
guestname="$1"
if [ -z "$guestname" ]; then
@@ -52,12 +45,6 @@ if ! virt-builder -l "$guestname" >/dev/null 2>&1;
then
exit 77
fi
-# 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
-
# Some guests need special virt-builder parameters.
# See virt-builder --notes "$guestname"
declare -a extra
diff --git a/v2v/test-v2v-copy-to-local.sh b/v2v/test-v2v-copy-to-local.sh
index 8629083..3eb384a 100755
--- a/v2v/test-v2v-copy-to-local.sh
+++ b/v2v/test-v2v-copy-to-local.sh
@@ -18,24 +18,14 @@
# Test virt-v2v-copy-to-local command.
-unset CDPATH
-export LANG=C
set -e
-if [ -n "$SKIP_TEST_V2V_COPY_TO_LOCAL_SH" ]; then
- echo "$0: test skipped because environment variable is set"
- exit 77
-fi
+$TEST_FUNCTIONS
+skip_if_skipped
+skip_unless_phony_guest fedora.img
-abs_top_builddir="$(cd ..; pwd)"
libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"
-f=../test-data/phony-guests/fedora.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because phony Fedora image was not created"
- exit 77
-fi
-
d=test-v2v-copy-to-local.d
rm -rf $d
mkdir $d
diff --git a/v2v/test-v2v-floppy.sh b/v2v/test-v2v-floppy.sh
index 1f3f1bc..ac407b4 100755
--- a/v2v/test-v2v-floppy.sh
+++ b/v2v/test-v2v-floppy.sh
@@ -19,37 +19,18 @@
# Test converting a guest with a floppy disk.
#
https://bugzilla.redhat.com/show_bug.cgi?id=1309706
-unset CDPATH
-export LANG=C
set -e
-if [ -n "$SKIP_TEST_V2V_FLOPPY_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-disk.img
-if [ "$(guestfish get-backend)" = "uml" ]; then
- echo "$0: test skipped because UML backend does not support network"
- exit 77
-fi
-
-abs_builddir="$(pwd)"
libvirt_uri="test://$abs_builddir/test-v2v-floppy.xml"
-f=../test-data/phony-guests/windows.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because phony Windows image was not created"
- exit 77
-fi
-
-f=../test-data/phony-guests/blank-disk.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because blank-disk.img was not created"
- exit 77
-fi
-
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
-export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
d=test-v2v-floppy.d
rm -rf $d
diff --git a/v2v/test-v2v-i-disk.sh b/v2v/test-v2v-i-disk.sh
index b806a44..c4b519c 100755
--- a/v2v/test-v2v-i-disk.sh
+++ b/v2v/test-v2v-i-disk.sh
@@ -18,34 +18,21 @@
# Test -i disk option.
-unset CDPATH
-export LANG=C
set -e
-if [ -n "$SKIP_TEST_V2V_I_DISK_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
-if [ "$(guestfish get-backend)" = "uml" ]; then
- echo "$0: test skipped because UML backend does not support network"
- exit 77
-fi
-
-f=../test-data/phony-guests/windows.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because phony Windows image 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-v2v-i-disk.d
rm -rf $d
mkdir $d
$VG virt-v2v --debug-gc \
- -i disk $f \
+ -i disk $top_builddir/test-data/phony-guests/windows.img \
-o local -os $d
# Test the libvirt XML metadata and a disk was created.
diff --git a/v2v/test-v2v-i-ova-formats.sh b/v2v/test-v2v-i-ova-formats.sh
index d49b7be..d357287 100755
--- a/v2v/test-v2v-i-ova-formats.sh
+++ b/v2v/test-v2v-i-ova-formats.sh
@@ -18,35 +18,17 @@
# Test -i ova option with ova file compressed in different ways
-unset CDPATH
-export LANG=C
set -e
$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
+skip_unless zip --version
+skip_unless unzip --help
formats="zip tar-gz tar-xz"
-if [ -n "$SKIP_TEST_V2V_I_OVA_FORMATS_SH" ]; then
- echo "$0: test skipped because environment variable is set"
- exit 77
-fi
-
-if ! zip --version >/dev/null 2>&1; then
- echo "$0: test skipped because 'zip' utility is not available"
- exit 77
-fi
-
-if ! unzip --help >/dev/null 2>&1; then
- echo "$0: test skipped because 'unzip' utility is not available"
- exit 77
-fi
-
-if [ "$(guestfish get-backend)" = "uml" ]; then
- echo "$0: test skipped because UML backend does not support network"
- 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-v2v-i-ova-formats.d
rm -rf $d
diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh
index e292683..2bf2f5e 100755
--- a/v2v/test-v2v-i-ova-gz.sh
+++ b/v2v/test-v2v-i-ova-gz.sh
@@ -23,18 +23,10 @@ export LANG=C
set -e
$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
-if [ -n "$SKIP_TEST_V2V_I_OVA_GZ_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
-
-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-v2v-i-ova-gz.d
rm -rf $d
diff --git a/v2v/test-v2v-i-ova-subfolders.sh b/v2v/test-v2v-i-ova-subfolders.sh
index ea3352c..12e0e87 100755
--- a/v2v/test-v2v-i-ova-subfolders.sh
+++ b/v2v/test-v2v-i-ova-subfolders.sh
@@ -23,18 +23,10 @@ export LANG=C
set -e
$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
-if [ -n "$SKIP_TEST_V2V_I_OVA_SUBFOLDERS_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
-
-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-v2v-i-ova-subfolders.d
rm -rf $d
diff --git a/v2v/test-v2v-i-ova-tar.sh b/v2v/test-v2v-i-ova-tar.sh
index 2d1389d..003d5e6 100755
--- a/v2v/test-v2v-i-ova-tar.sh
+++ b/v2v/test-v2v-i-ova-tar.sh
@@ -23,18 +23,10 @@ export LANG=C
set -e
$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
-if [ -n "$SKIP_TEST_V2V_I_OVA_FORMATS_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
-
-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-v2v-i-ova-tar.d
rm -rf $d
diff --git a/v2v/test-v2v-i-ova-two-disks.sh b/v2v/test-v2v-i-ova-two-disks.sh
index 86584c3..9ecc380 100755
--- a/v2v/test-v2v-i-ova-two-disks.sh
+++ b/v2v/test-v2v-i-ova-two-disks.sh
@@ -23,19 +23,11 @@ export LANG=C
set -e
$TEST_FUNCTIONS
+skip_if_skipped
+skip_if_backend uml
-if [ -n "$SKIP_TEST_V2V_I_OVA_TWO_DISKS_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
-
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
-export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
d=test-v2v-i-ova-two-disks.d
rm -rf $d
diff --git a/v2v/test-v2v-i-ova.sh b/v2v/test-v2v-i-ova.sh
index 4b97a1a..7a33b6c 100755
--- a/v2v/test-v2v-i-ova.sh
+++ b/v2v/test-v2v-i-ova.sh
@@ -18,37 +18,19 @@
# Test -i ova option.
-unset CDPATH
-export LANG=C
set -e
$TEST_FUNCTIONS
-
-if [ -n "$SKIP_TEST_V2V_I_OVA_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
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
# XXX Remove when we fix this. See:
#
https://www.redhat.com/archives/libguestfs/2017-February/msg00101.html
-if [[ "$(guestfish get-backend)" =~ ^libvirt ]]; then
- echo "$0: test skipped because of bug with virt-v2v -i ova and libvirt"
- exit 77
-fi
+skip_if_backend libvirt
-f=../test-data/phony-guests/windows.img
-if ! test -f $f || ! test -s $f; then
- echo "$0: test skipped because phony Windows image was not created"
- exit 77
-fi
-
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
-export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
d=test-v2v-i-ova.d
rm -rf $d
@@ -60,7 +42,8 @@ mf=test-ova.mf
ova=test-ova.ova
raw=TestOva-sda
-qemu-img convert $f -O vmdk $d/$vmdk
+qemu-img convert $top_builddir/test-data/phony-guests/windows.img \
+ -O vmdk $d/$vmdk
cp $ovf $d/$ovf
sha1=`do_sha1 $d/$ovf`
echo "SHA1($ovf)= $sha1" > $d/$mf
diff --git a/v2v/test-v2v-in-place.sh b/v2v/test-v2v-in-place.sh
index c8b2ec4..6f7d78f 100755
--- a/v2v/test-v2v-in-place.sh
+++ b/v2v/test-v2v-in-place.sh
@@ -24,27 +24,14 @@ export LANG=C
set -e
$TEST_FUNCTIONS
-
-if [ -n "$SKIP_TEST_V2V_IN_PLACE_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
-
-abs_top_builddir="$(cd ..; pwd)"
+skip_if_skipped
+skip_if_backend uml
+skip_unless_phony_guest windows.img
img_base="$abs_top_builddir/test-data/phony-guests/windows.img"
-if ! test -f $img_base || ! test -s $img_base; then
- echo "$0: test skipped because phony Windows image was not created"
- exit 77
-fi
-export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
-export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+export VIRTIO_WIN="$top_srcdir/test-data/fake-virtio-win"
d=$PWD/test-v2v-in-place.d
rm -rf $d
--
2.10.2