tests: consistently source test-lib.sh in scripts

This unifies the test scripts to all use the similar pattern added for
schematests in ace4aecd. This gives the following

- Enables running all tests from outside of tests/ dir
- Drops redundant abs_* definitions, which are set by test-lib.sh
- Drops unnecessary srcdir variable which was only used for sourcing
    test-lib.sh

Behavior changes:

- srcdir can no longer be overwritten, but I don't know why anyone would
    really need to...
- Script VERBOSE setting no longer prints commands executed by test-lib.sh.
    if anyone cares I suggest handling this in test-lib.sh which already
    has other verbose style handling
This commit is contained in:
Cole Robinson 2016-04-21 13:50:18 -04:00
parent 18644491de
commit 856e84a516
27 changed files with 27 additions and 95 deletions

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="capabilityschemadata xencapsdata"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS=""

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS=""

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="domainsnapshotxml2xmlin domainsnapshotxml2xmlout"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="interfaceschemadata"

View File

@ -1,17 +1,13 @@
#!/bin/sh
# Ensure that libvirt fails when given nonexistent --config=FILE
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/daemon/libvirtd --version
fi
. "$srcdir/test-lib.sh"
fail=0
$abs_top_builddir/daemon/libvirtd --config=no-such-conf --timeout=5 2> log

View File

@ -1,17 +1,13 @@
#!/bin/sh
# Get coverage of virsh pool-define-as XML formatting
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
pwd=$(pwd) || fail=1

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="../src/network networkxml2xmlin networkxml2xmlout"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="nodedevschemadata"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="nwfilterxml2xmlout"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="secretxml2xmlin"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="storagepoolxml2xmlin storagepoolxml2xmlout storagepoolschemadata"

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=$(dirname $0)}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
. $abs_srcdir/schematestutils.sh
DIRS="storagevolxml2xmlin storagevolxml2xmlout storagevolschemadata"

View File

@ -1,8 +1,6 @@
#!/bin/sh
test -z "$srcdir" && srcdir=$(pwd)
. "$srcdir/test-lib.sh"
. "$(dirname $0)/test-lib.sh"
test_intro $this_test

View File

@ -17,9 +17,7 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
. "$srcdir/test-lib.sh"
. "$(dirname $0)/test-lib.sh"
test_expensive

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
# generate input

View File

@ -2,17 +2,13 @@
# Exercise a bug whereby defining a valid domain could kill libvirtd.
# The bug can also be exercised with a simple define/dumpxml pair to virsh.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
# Domain definition from Cole Robinson.

View File

@ -2,17 +2,13 @@
# Ensure that an invalid domain ID isn't interpreted as a valid one.
# Before, an ID of 2^32+2 would be treated just like an ID of 2.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
echo "error: failed to get domain '4294967298'" > exp || fail=1
$abs_top_builddir/tools/virsh --quiet \
--connect test://$abs_top_srcdir/examples/xml/test/testnode.xml \

View File

@ -17,9 +17,7 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
: ${srcdir=$(pwd)}
: ${abs_top_srcdir=$(pwd)/..}
: ${abs_top_builddir=$(pwd)/..}
. "$(dirname $0)/test-lib.sh"
# If $abs_top_builddir/tools is not early in $PATH, put it there,
# so that we can safely invoke "virsh" simply with its name.
@ -34,8 +32,6 @@ if test "$VERBOSE" = yes; then
virsh --version
fi
. "$srcdir/test-lib.sh"
cat <<\EOF > exp-out || framework_failure
setvcpus: <domain> trying as domain NAME

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=`pwd`
test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
# Output a valid definition, to be used as input.

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=`pwd`
test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
cat <<\EOF > dom

View File

@ -17,9 +17,7 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
: ${srcdir=$(pwd)}
: ${abs_top_srcdir=$(pwd)/..}
: ${abs_top_builddir=$(pwd)/..}
. "$(dirname $0)/test-lib.sh"
# If $abs_top_builddir/tools is not early in $PATH, put it there,
# so that we can safely invoke "virsh" simply with its name.
@ -34,8 +32,6 @@ if test "$VERBOSE" = yes; then
virsh --version
fi
. "$srcdir/test-lib.sh"
printf 'Scheduler : fair\n\n' > exp-out || framework_failure
printf 'error: invalid scheduler option: j\n' > exp-err || framework_failure

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
test_url=test:///default

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
test_url=test:///default

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
# Attempt to undefine a running domain, by domain name. Every time a new

View File

@ -1,7 +1,6 @@
#!/bin/sh
: ${srcdir=.}
. $srcdir/test-lib.sh
. "$(dirname $0)/test-lib.sh"
# This test checks if virsh obeys the proper precedence of different
# URI settings

View File

@ -17,17 +17,13 @@
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
. "$(dirname $0)/test-lib.sh"
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/tools/virsh --version
fi
. "$srcdir/test-lib.sh"
fail=0
# Invalid syntax.