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 #!/bin/sh
: ${srcdir=$(dirname $0)} . "$(dirname $0)/test-lib.sh"
. $srcdir/test-lib.sh
. $abs_srcdir/schematestutils.sh . $abs_srcdir/schematestutils.sh
DIRS="capabilityschemadata xencapsdata" DIRS="capabilityschemadata xencapsdata"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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