From 856e84a51675a0dccf0bde3e5e7bcf83eb708c02 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 21 Apr 2016 13:50:18 -0400 Subject: [PATCH] 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 --- tests/capabilityschematest | 3 +-- tests/domaincapsschematest | 3 +-- tests/domainschematest | 3 +-- tests/domainsnapshotschematest | 3 +-- tests/interfaceschematest | 3 +-- tests/libvirtd-fail | 6 +----- tests/libvirtd-pool | 6 +----- tests/networkschematest | 3 +-- tests/nodedevschematest | 3 +-- tests/nwfilterschematest | 3 +-- tests/secretschematest | 3 +-- tests/storagepoolschematest | 3 +-- tests/storagevolschematest | 3 +-- tests/virconftest.sh | 4 +--- tests/virsh-all | 4 +--- tests/virsh-cpuset | 6 +----- tests/virsh-define-dev-segfault | 6 +----- tests/virsh-int-overflow | 6 +----- tests/virsh-optparse | 6 +----- tests/virsh-read-bufsiz | 6 +----- tests/virsh-read-non-seekable | 6 +----- tests/virsh-schedinfo | 6 +----- tests/virsh-start | 6 +----- tests/virsh-synopsis | 6 +----- tests/virsh-undefine | 6 +----- tests/virsh-uriprecedence | 3 +-- tests/virsh-vcpupin | 6 +----- 27 files changed, 27 insertions(+), 95 deletions(-) diff --git a/tests/capabilityschematest b/tests/capabilityschematest index 78fbc8ee0c..458212e1e6 100755 --- a/tests/capabilityschematest +++ b/tests/capabilityschematest @@ -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" diff --git a/tests/domaincapsschematest b/tests/domaincapsschematest index 2c19ac4004..3b2021f75b 100755 --- a/tests/domaincapsschematest +++ b/tests/domaincapsschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="" diff --git a/tests/domainschematest b/tests/domainschematest index 3271a28c29..c059c98658 100755 --- a/tests/domainschematest +++ b/tests/domainschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="" diff --git a/tests/domainsnapshotschematest b/tests/domainsnapshotschematest index ba28e051f1..33b539adc5 100755 --- a/tests/domainsnapshotschematest +++ b/tests/domainsnapshotschematest @@ -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" diff --git a/tests/interfaceschematest b/tests/interfaceschematest index 47745eaf65..239b74974c 100755 --- a/tests/interfaceschematest +++ b/tests/interfaceschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="interfaceschemadata" diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail index c6b6876bfe..6c61b892cb 100755 --- a/tests/libvirtd-fail +++ b/tests/libvirtd-fail @@ -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 diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool index ca1db94ad6..4be65c68fe 100755 --- a/tests/libvirtd-pool +++ b/tests/libvirtd-pool @@ -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 diff --git a/tests/networkschematest b/tests/networkschematest index fe46893ead..adbc7f4714 100755 --- a/tests/networkschematest +++ b/tests/networkschematest @@ -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" diff --git a/tests/nodedevschematest b/tests/nodedevschematest index 07b1f7b4a0..1d85371809 100755 --- a/tests/nodedevschematest +++ b/tests/nodedevschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="nodedevschemadata" diff --git a/tests/nwfilterschematest b/tests/nwfilterschematest index 8703e21b4c..408034cdd4 100755 --- a/tests/nwfilterschematest +++ b/tests/nwfilterschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="nwfilterxml2xmlout" diff --git a/tests/secretschematest b/tests/secretschematest index 23b0e2f444..9c29021255 100755 --- a/tests/secretschematest +++ b/tests/secretschematest @@ -1,7 +1,6 @@ #!/bin/sh -: ${srcdir=$(dirname $0)} -. $srcdir/test-lib.sh +. "$(dirname $0)/test-lib.sh" . $abs_srcdir/schematestutils.sh DIRS="secretxml2xmlin" diff --git a/tests/storagepoolschematest b/tests/storagepoolschematest index ebea71104b..ebbf4d1a10 100755 --- a/tests/storagepoolschematest +++ b/tests/storagepoolschematest @@ -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" diff --git a/tests/storagevolschematest b/tests/storagevolschematest index 395df572f4..d3ba3a8e69 100755 --- a/tests/storagevolschematest +++ b/tests/storagevolschematest @@ -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" diff --git a/tests/virconftest.sh b/tests/virconftest.sh index 2920e28316..0fd5bbe751 100755 --- a/tests/virconftest.sh +++ b/tests/virconftest.sh @@ -1,8 +1,6 @@ #!/bin/sh -test -z "$srcdir" && srcdir=$(pwd) - -. "$srcdir/test-lib.sh" +. "$(dirname $0)/test-lib.sh" test_intro $this_test diff --git a/tests/virsh-all b/tests/virsh-all index 4e456c68eb..4a91e4e102 100755 --- a/tests/virsh-all +++ b/tests/virsh-all @@ -17,9 +17,7 @@ # along with this program. If not, see # . -test -z "$srcdir" && srcdir=$(pwd) - -. "$srcdir/test-lib.sh" +. "$(dirname $0)/test-lib.sh" test_expensive diff --git a/tests/virsh-cpuset b/tests/virsh-cpuset index 35803be02c..66163013c2 100755 --- a/tests/virsh-cpuset +++ b/tests/virsh-cpuset @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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 diff --git a/tests/virsh-define-dev-segfault b/tests/virsh-define-dev-segfault index 81a8773def..44fc6dca9a 100755 --- a/tests/virsh-define-dev-segfault +++ b/tests/virsh-define-dev-segfault @@ -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. diff --git a/tests/virsh-int-overflow b/tests/virsh-int-overflow index 36e55368ad..e9eb03bfbb 100755 --- a/tests/virsh-int-overflow +++ b/tests/virsh-int-overflow @@ -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 \ diff --git a/tests/virsh-optparse b/tests/virsh-optparse index 0fc261dffb..cbd6c30a94 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -17,9 +17,7 @@ # along with this program. If not, see # . -: ${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: trying as domain NAME diff --git a/tests/virsh-read-bufsiz b/tests/virsh-read-bufsiz index 23c3b531d9..116eff1c4c 100755 --- a/tests/virsh-read-bufsiz +++ b/tests/virsh-read-bufsiz @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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. diff --git a/tests/virsh-read-non-seekable b/tests/virsh-read-non-seekable index 46e2831eb9..0f7504c800 100755 --- a/tests/virsh-read-non-seekable +++ b/tests/virsh-read-non-seekable @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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 diff --git a/tests/virsh-schedinfo b/tests/virsh-schedinfo index 37f7bd3550..d6d9ac2d59 100755 --- a/tests/virsh-schedinfo +++ b/tests/virsh-schedinfo @@ -17,9 +17,7 @@ # along with this program. If not, see # . -: ${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 diff --git a/tests/virsh-start b/tests/virsh-start index 5d4c0a73c7..cb58c3b09c 100755 --- a/tests/virsh-start +++ b/tests/virsh-start @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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 diff --git a/tests/virsh-synopsis b/tests/virsh-synopsis index cacdee4876..d0d1197fab 100755 --- a/tests/virsh-synopsis +++ b/tests/virsh-synopsis @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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 diff --git a/tests/virsh-undefine b/tests/virsh-undefine index f7ba495933..6494b4adf0 100755 --- a/tests/virsh-undefine +++ b/tests/virsh-undefine @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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 diff --git a/tests/virsh-uriprecedence b/tests/virsh-uriprecedence index f9e3256589..1cf3d22ec7 100755 --- a/tests/virsh-uriprecedence +++ b/tests/virsh-uriprecedence @@ -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 diff --git a/tests/virsh-vcpupin b/tests/virsh-vcpupin index 9e656c0aa1..306552a8f4 100755 --- a/tests/virsh-vcpupin +++ b/tests/virsh-vcpupin @@ -17,17 +17,13 @@ # along with this program. If not, see # . -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. -- GitLab