On Mon, Mar 02, 2009 at 08:10:23PM +0100, Jim Meyering wrote:
diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail
new file mode 100755
index 0000000..92b82c4
--- /dev/null
+++ b/tests/libvirtd-fail
@@ -0,0 +1,21 @@
+#!/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)/..
+. "$srcdir/test-lib.sh"
+
+fail=0
+
+libvirtd --config=no-such-file > log 2>&1 && fail=1
+cat <<\EOF > exp
+Failed to open file 'no-such-file': No such file or directory
+EOF
+
+compare exp log || fail=1
+exit $fail
Should also pass '--timeout=5' to the libvirtd process so it
will auto-exit if there's ever a regression in the config file
handling, rather than running forever.
+libvirtd --config=conf > libvirtd-log 2>&1 & pid=$!
+sleep 1
+
+url="qemu:///session?socket=@$sock_dir/libvirt-sock"
+virsh --connect "$url" \
+ pool-define-as P dir src-host /src/path /src/dev S /target-path > out 2>&1
\
+ || fail=1
+virsh --connect "$url" pool-dumpxml P >> out 2>&1 || fail=1
Using the QEMU driver here is rather undesirable - the test:///default
driver allows for testing of this without needing to run the libvirtd
daemon, and also works with QEMU is turned off at compile time.
Even better would be to add a '--dry-run' arg to 'pool-define-as'
so it could print out the XML it was going to use, without actually
defining the pool for real.
diff --git a/tests/daemon-conf b/tests/daemon-conf
index 7a53eff..a5e86ae 100755
--- a/tests/daemon-conf
+++ b/tests/daemon-conf
@@ -67,8 +67,18 @@ done
# Run with the unmodified config file.
sleep_secs=2
+
+# Be careful to specify a non-default socket directory:
+sed 's,^unix_sock_dir.*,unix_sock_dir="'"$(pwd)"'",'
tmp.conf > k || fail=1
+mv k tmp.conf || fail=1
+
+# Also, specify a test-specific log directory:
+sed
's,^log_outputs.*,log_outputs="3:file:'"$(pwd)/log"'",'
tmp.conf > k \
+ || fail=1
+mv k tmp.conf || fail=1
+
printf "running libvirtd with a valid config file ($sleep_secs seconds)\n"
1>&2
-libvirtd --config=tmp.conf > log 2>&1 & pid=$!
+libvirtd --pid-file=pid-file --config=tmp.conf > log 2>&1 & pid=$!
ACK, to this change.
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|