]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix up "make check"
authorChris Lalancette <clalance@redhat.com>
Wed, 23 Sep 2009 07:32:10 +0000 (09:32 +0200)
committerChris Lalancette <clalance@redhat.com>
Wed, 7 Oct 2009 10:18:13 +0000 (12:18 +0200)
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@redhat.com>
15 files changed:
tests/Makefile.am
tests/cpuset
tests/daemon-conf
tests/define-dev-segfault
tests/int-overflow
tests/libvirtd-fail
tests/libvirtd-pool
tests/read-bufsiz
tests/read-non-seekable
tests/start
tests/test_conf.sh
tests/undefine
tests/vcpupin
tests/virsh-all
tests/virsh-synopsis

index 97bdf551ee0ae3cc94e32054f605c380fc072470..a837150ffa852b0647db4746889a2e1a8a8c106e 100644 (file)
@@ -158,7 +158,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
index eeb0ee269caf962658bebc8c3a2876021bc54eee..9f4326951e051eb1b8befaef80a61d065e8a54bd 100755 (executable)
 # 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
index 071497e1e4632f8a74f419922b1805ccc221bedd..722fe4e4364fe379315aba11e450b47347a5b99b 100755 (executable)
@@ -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
 
index 4ae286fe2d38e09f8b234ecd5483e4bf1e12f41c..e0b953ad8409006e20d6f5891359199b3fa5ad20 100755 (executable)
@@ -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
index ac3119b475308967d8ee608695f20f37d8c68a53..c9f5de9d5472dde37ecd410d005df2d2d1cf528f 100755 (executable)
@@ -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 \
index eeb1ee68fc5dd9fd4b8f7f43f6abcb09e4f7c93f..c6b6876bfee57f7ab838f22cf7c660ab700eb4a0 100755 (executable)
@@ -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
index 59da5a696dd41cd94d2d64fd5e6f69291e40d468..ca1db94ad6b1c184f98e2884dfcf243a83811c4e 100755 (executable)
@@ -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
index 7d53735bfa8cef9456f2470fbb0b99aeadbfbb32..5baa7c59039f5f65e308cf4cab3d613e4502cac7 100755 (executable)
 # 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
index 8a7bdcdf2209f75dd9d59d57a27db5e963f905c5..59c2389d626a427588388accb200a4d8f0b158b2 100755 (executable)
 # 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
index f457d5939e5e67fd4822a8b84a17af960dac27d8..930a6d9e46a059170830a2b2bbbb8310cd21b5b3 100755 (executable)
 # 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
index 62c23244950bec638cdd19933f3433fb9c264b05..682f1f5684843af448d793182c8347fc37d07bb0 100755 (executable)
@@ -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
index fafdae72a8b54c29158b12eea54c01b807b3a69c..48b0ad9b0a5590aa07523bcf687351e79e7e206e 100755 (executable)
 # 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
index 79b02dc23bf82f5f7781af0a6f4ff72b3725a5ee..a72ad4ceaf26650a9e75a190a0d67fc83d788ddb 100755 (executable)
 # 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.
index 03ea4668f55c3dc5c72fdff67b36c0f9f77dcd1b..81b3e57514167cc627be8df276d78299a501016c 100755 (executable)
 # 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
index 24038dd057ccb5f2bc4c136217e98ef13c9b0b55..d72e8871b4963b511062d4fbdf9618a8a931cc45 100755 (executable)
 # 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