Fix up "make check"

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>
This commit is contained in:
Chris Lalancette 2009-09-23 09:32:10 +02:00
parent d285084b12
commit db68d6b164
15 changed files with 122 additions and 86 deletions

View 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

View File

@ -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

View File

@ -1,16 +1,20 @@
#!/bin/sh
# Get coverage of libvirtd's config-parsing code.
if test "$VERBOSE" = yes; then
set -x
libvirtd --version
fi
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
. $srcdir/test-lib.sh
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..
grep '^#define WITH_QEMU 1' $CONFIG_HEADER > /dev/null ||
if test "$VERBOSE" = yes; then
set -x
$abs_top_builddir/daemon/libvirtd --version
fi
. "$srcdir/test-lib.sh"
test -z "$CONFIG_HEADER" && CONFIG_HEADER="$abs_top_builddir/config.h"
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

View File

@ -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.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
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"
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

View File

@ -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 \

View File

@ -1,18 +1,20 @@
#!/bin/sh
# Ensure that libvirt fails when given nonexistent --config=FILE
if test "$VERBOSE" = yes; then
set -x
libvirtd --version
fi
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/daemon/libvirtd --version
fi
. "$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

View File

@ -1,20 +1,22 @@
#!/bin/sh
# Get coverage of virsh pool-define-as XML formatting
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
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"
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

View File

@ -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/>.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
test -z "$srcdir" && srcdir=`pwd`
test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
test -z "$abs_top_builddir" && abs_top_builddir=`pwd`/..
. $srcdir/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.
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

View File

@ -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

View File

@ -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/>.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
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"
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

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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/>.
if test "$VERBOSE" = yes; then
set -x
virsh --version
fi
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"
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

View File

@ -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