While running make check, I noticed that it was actually using the virsh binary from my system, in /usr/bin/virsh, and not the one that was just compiled. This is actually caused by a bug in Makefile.am, where we didn't update the PATH to include tools. While here, I also updated all of the scripts to properly define the srcdir, abs_top_srcdir, and abs_top_builddir environment variables. This is required if you want to be able to run the tests standalone (i.e. ./test instead of from make check). I've tested this on both RHEL-5 and Fedora-10 machines, and make check works on both, as does running the individual tests by hand. Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx> --- tests/Makefile.am | 2 +- tests/cpuset | 12 ++++++++---- tests/daemon-conf | 18 +++++++++++------- tests/define-dev-segfault | 10 ++++++---- tests/int-overflow | 20 ++++++++++---------- tests/libvirtd-fail | 10 ++++++---- tests/libvirtd-pool | 10 ++++++---- tests/read-bufsiz | 15 ++++++++------- tests/read-non-seekable | 12 ++++++++---- tests/start | 10 ++++++---- tests/test_conf.sh | 14 ++++++++------ tests/undefine | 14 +++++++++----- tests/vcpupin | 12 ++++++++---- tests/virsh-all | 12 +++++++----- tests/virsh-synopsis | 11 +++++++---- 15 files changed, 109 insertions(+), 73 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index abda4ad..4caca8f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -150,7 +150,7 @@ TESTS += nodedevxml2xmltest TESTS += interfacexml2xmltest -path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/daemon +path_add = $$abs_top_builddir/src$(PATH_SEPARATOR)$$abs_top_builddir/daemon$(PATH_SEPARATOR)$$abs_top_builddir/tools # NB, automake < 1.10 does not provide the real # abs_top_{src/build}dir variables, so don't rely diff --git a/tests/cpuset b/tests/cpuset index eeb0ee2..9f43269 100755 --- a/tests/cpuset +++ b/tests/cpuset @@ -16,17 +16,21 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" fail=0 # generate input -virsh --connect test:///default dumpxml 1 > xml || fail=1 +$abs_top_builddir/tools/virsh --connect test:///default dumpxml 1 > xml || fail=1 # require the presence of the string we'll transform grep '<vcpu>' xml > /dev/null || fail=1 @@ -34,7 +38,7 @@ grep '<vcpu>' xml > /dev/null || fail=1 sed "s/vcpu>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1 # Require failure and a diagnostic. -virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1 +$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1 cat <<\EOF > exp || fail=1 error: Failed to define domain from xml-invalid error: failed Xen syscall topology cpuset syntax error diff --git a/tests/daemon-conf b/tests/daemon-conf index 071497e..722fe4e 100755 --- a/tests/daemon-conf +++ b/tests/daemon-conf @@ -1,16 +1,20 @@ #!/bin/sh # Get coverage of libvirtd's config-parsing code. +test -z "$srcdir" && srcdir=$(pwd) +test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. +test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/.. + if test "$VERBOSE" = yes; then set -x - libvirtd --version + $abs_top_builddir/daemon/libvirtd --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" + +test -z "$CONFIG_HEADER" && CONFIG_HEADER="$abs_top_builddir/config.h" -grep '^#define WITH_QEMU 1' $CONFIG_HEADER > /dev/null || +grep '^#define WITH_QEMU 1' "$CONFIG_HEADER" > /dev/null || skip_test_ "configured without QEMU support" conf="$abs_top_srcdir/daemon/libvirtd.conf" @@ -40,7 +44,7 @@ while :; do esac # Run libvirtd, expecting it to fail. - libvirtd --config=$f 2> err && fail=1 + $abs_top_builddir/daemon/libvirtd --config=$f 2> err && fail=1 case $rhs in # '"'*) msg='should be a string';; @@ -73,7 +77,7 @@ sed 's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",' tmp.conf > k \ mv k tmp.conf || fail=1 printf "running libvirtd with a valid config file ($sleep_secs seconds)\n" 1>&2 -libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! +$abs_top_builddir/daemon/libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$! sleep $sleep_secs kill $pid diff --git a/tests/define-dev-segfault b/tests/define-dev-segfault index 4ae286f..e0b953a 100755 --- a/tests/define-dev-segfault +++ b/tests/define-dev-segfault @@ -2,13 +2,15 @@ # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. . "$srcdir/test-lib.sh" fail=0 @@ -62,7 +64,7 @@ cat <<\EOF > D.xml || fail=1 EOF url=test:///default -virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1 +$abs_top_builddir/tools/virsh --connect "$url" 'define D.xml; dumpxml D' > out 2>&1 || fail=1 cat > exp <<EOF || fail=1 Domain D defined from D.xml diff --git a/tests/int-overflow b/tests/int-overflow index ac3119b..c9f5de9 100755 --- a/tests/int-overflow +++ b/tests/int-overflow @@ -2,16 +2,16 @@ # 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. -# Boilerplate code to set up a test directory, cd into it, -# and to ensure we remove it upon completion. -this_test_() { echo "./$0" | sed 's,.*/,,'; } -t_=$(this_test_)-$$ -init_cwd_=$(pwd) -trap 'st=$?; d='"$t_"'; - cd '"$init_cwd_"' && chmod -R u+rwx "$d" && rm -rf "$d" && exit $st' 0 -trap '(exit $?); exit $?' 1 2 13 15 -mkdir "$t_" || fail=1 -cd "$t_" || fail=1 +test -z "$srcdir" && srcdir=$(pwd) +test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. +test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/.. + +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 echo domname 4294967298 | $abs_top_builddir/tools/virsh --quiet \ diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail index eeb1ee6..c6b6876 100755 --- a/tests/libvirtd-fail +++ b/tests/libvirtd-fail @@ -1,18 +1,20 @@ #!/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)/.. + if test "$VERBOSE" = yes; then set -x - libvirtd --version + $abs_top_builddir/daemon/libvirtd --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. . "$srcdir/test-lib.sh" fail=0 -libvirtd --config=no-such-conf --timeout=5 2> log +$abs_top_builddir/daemon/libvirtd --config=no-such-conf --timeout=5 2> log RET=$? test "$RET" != "0" && exit 0 || exit 1 diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool index 59da5a6..ca1db94 100755 --- a/tests/libvirtd-pool +++ b/tests/libvirtd-pool @@ -1,20 +1,22 @@ #!/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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. . "$srcdir/test-lib.sh" fail=0 pwd=$(pwd) || fail=1 -virsh --connect test:///default \ +$abs_top_builddir/tools/virsh --connect test:///default \ pool-define-as --print-xml \ P dir src-host /src/path /src/dev S /target-path \ 1>out 2>&1 diff --git a/tests/read-bufsiz b/tests/read-bufsiz index 7d53735..5baa7c5 100755 --- a/tests/read-bufsiz +++ b/tests/read-bufsiz @@ -16,20 +16,21 @@ # You should have received a copy of the GNU General Public License # 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`/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=`pwd` -test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/.. - -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" fail=0 # Output a valid definition, to be used as input. -virsh -c test:///default dumpxml 1 > xml || fail=1 +$abs_top_builddir/tools/virsh -c test:///default dumpxml 1 > xml || fail=1 for i in before after; do # The largest BUFSIZ I've seen is 128K. This is slightly larger. @@ -38,7 +39,7 @@ for i in before after; do # Append or prepend enough spaces to push the size over the limit: ( test $i = before && cat sp xml || cat xml sp ) > $in || fail=1 - virsh --connect test:///default define $in > out || fail=1 + $abs_top_builddir/tools/virsh --connect test:///default define $in > out || fail=1 printf "Domain test defined from $in\n\n" > exp || fail=1 compare exp out || fail=1 done diff --git a/tests/read-non-seekable b/tests/read-non-seekable index 8a7bdcd..59c2389 100755 --- a/tests/read-non-seekable +++ b/tests/read-non-seekable @@ -16,12 +16,16 @@ # You should have received a copy of the GNU General Public License # 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`/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" fail=0 @@ -40,11 +44,11 @@ cat <<\EOF > dom </domain> EOF -virsh -c test:///default define dom > /dev/null || fail=1 +$abs_top_builddir/tools/virsh -c test:///default define dom > /dev/null || fail=1 mkfifo_or_skip_ fifo cat dom > fifo & -virsh -c test:///default define fifo > /dev/null || fail=1 +$abs_top_builddir/tools/virsh -c test:///default define fifo > /dev/null || fail=1 (exit $fail); exit $fail diff --git a/tests/start b/tests/start index f457d59..930a6d9 100755 --- a/tests/start +++ b/tests/start @@ -16,13 +16,15 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. . "$srcdir/test-lib.sh" fail=0 @@ -30,7 +32,7 @@ fail=0 test_url=test:///default # expect this to fail -virsh -c $test_url start test > out 2> err && fail=1 +$abs_top_builddir/tools/virsh -c $test_url start test > out 2> err && fail=1 # stdout gets a newline echo > exp || fail=1 diff --git a/tests/test_conf.sh b/tests/test_conf.sh index 62c2324..682f1f5 100755 --- a/tests/test_conf.sh +++ b/tests/test_conf.sh @@ -1,17 +1,19 @@ #!/bin/sh +test -z "$srcdir" && srcdir=$(pwd) +test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. +test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/.. +test -z "$abs_srcdir" && abs_srcdir=$(pwd) +test -z "$abs_builddir" && abs_builddir=$(pwd) + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" set -e -if test "x$abs_srcdir" = x; then - abs_srcdir=`pwd` - abs_builddir=`pwd` -fi fail=0 i=1 diff --git a/tests/undefine b/tests/undefine index fafdae7..48b0ad9 100755 --- a/tests/undefine +++ b/tests/undefine @@ -16,17 +16,21 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" fail=0 # Attempt to undefine a running domain, by domain name. -virsh -q -c test:///default undefine test > out 2>&1 +$abs_top_builddir/tools/virsh -q -c test:///default undefine test > out 2>&1 test $? = 1 || fail=1 cat <<\EOF > exp || fail=1 error: Failed to undefine domain test @@ -35,7 +39,7 @@ EOF compare exp out || fail=1 # A different diagnostic when specifying a domain ID -virsh -q -c test:///default undefine 1 > out 2>&1 +$abs_top_builddir/tools/virsh -q -c test:///default undefine 1 > out 2>&1 test $? = 1 || fail=1 cat <<\EOF > exp || fail=1 error: a running domain like 1 cannot be undefined; @@ -44,7 +48,7 @@ EOF compare exp out || fail=1 # Succeed, now: first shut down, then undefine, both via name. -virsh -q -c test:///default 'shutdown test; undefine test' > out 2>&1 +$abs_top_builddir/tools/virsh -q -c test:///default 'shutdown test; undefine test' > out 2>&1 test $? = 0 || fail=1 cat <<\EOF > exp || fail=1 Domain test is being shutdown diff --git a/tests/vcpupin b/tests/vcpupin index 79b02dc..a72ad4c 100755 --- a/tests/vcpupin +++ b/tests/vcpupin @@ -16,17 +16,21 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -. $srcdir/test-lib.sh +. "$srcdir/test-lib.sh" fail=0 # Invalid syntax. -virsh --connect test:///default vcpupin test a 0,1 > out 2>&1 +$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1 test $? = 1 || fail=1 cat <<\EOF > exp || fail=1 error: vcpupin: Invalid or missing vCPU number. @@ -35,7 +39,7 @@ EOF compare exp out || fail=1 # An out-of-range vCPU number deserves a diagnostic, too. -virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1 +$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1 test $? = 1 || fail=1 cat <<\EOF > exp || fail=1 error: vcpupin: Invalid vCPU number. diff --git a/tests/virsh-all b/tests/virsh-all index 03ea466..81b3e57 100755 --- a/tests/virsh-all +++ b/tests/virsh-all @@ -16,27 +16,29 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=$(pwd) -test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/.. . "$srcdir/test-lib.sh" fail=0 test_url=test:///default -virsh -c $test_url help > cmds || framework_failure +$abs_top_builddir/tools/virsh -c $test_url help > cmds || framework_failure cmds=$(sed -n 's/^ \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure test -n "$cmds" || framework_failure for i in $cmds; do echo testing $i... 1>&2 # For now, just run the command and ignore output and exit status. - virsh -c $test_url $i < /dev/null > /dev/null 2>&1 + $abs_top_builddir/tools/virsh -c $test_url $i < /dev/null > /dev/null 2>&1 done (exit $fail); exit $fail diff --git a/tests/virsh-synopsis b/tests/virsh-synopsis index 24038dd..d72e887 100755 --- a/tests/virsh-synopsis +++ b/tests/virsh-synopsis @@ -16,24 +16,27 @@ # You should have received a copy of the GNU General Public License # 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)/.. + if test "$VERBOSE" = yes; then set -x - virsh --version + $abs_top_builddir/tools/virsh --version fi -test -z "$srcdir" && srcdir=$(pwd) . "$srcdir/test-lib.sh" fail=0 test_url=test:///default -virsh -c $test_url help > cmds || framework_failure +$abs_top_builddir/tools/virsh -c $test_url help > cmds || framework_failure cmds=$(sed -n 's/^ \([^ ][^ ]*\) .*/\1/p' cmds) || framework_failure test -n "$cmds" || framework_failure for i in $cmds; do - virsh -c $test_url help $i > help || fail=1 + $abs_top_builddir/tools/virsh -c $test_url help $i > help || fail=1 grep -A1 '^ SYNOPSIS$' help > synopsis \ || { echo 1>&2 missing or invalid help SYNOPSIS for $i; fail=1; } sed -n 2p synopsis > s2 || framework_failure -- 1.6.0.6 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list