]> xenbits.xensource.com Git - libvirt.git/commitdiff
add two tests
authorJim Meyering <meyering@redhat.com>
Mon, 2 Mar 2009 20:01:05 +0000 (20:01 +0000)
committerJim Meyering <meyering@redhat.com>
Mon, 2 Mar 2009 20:01:05 +0000 (20:01 +0000)
* tests/libvirtd-pool: New file.
Exercise the new unix_sock_dir option
* tests/libvirtd-fail: New file.
* tests/Makefile.am (test_scripts): Add libvirtd-fail and libvirtd-pool.

ChangeLog
tests/Makefile.am
tests/libvirtd-fail [new file with mode: 0755]
tests/libvirtd-pool [new file with mode: 0755]

index 6f0f7ed86023d00cd535a12731755cc3910898a4..0d6647282bef35515c1768909e658fc3263e1148 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Mar 2 21:00:00 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+       add two tests
+       * tests/libvirtd-pool: New file.
+       Exercise the new unix_sock_dir option
+       * tests/libvirtd-fail: New file.
+       * tests/Makefile.am (test_scripts): Add libvirtd-fail and libvirtd-pool.
+
 Mon Mar 2 20:01:55 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        tests: fix an error that made us skip the daemon-conf test
index b40785fee12ee556870965bd7f4ce9c9fab493c8..11ffe76369dbffccc39aa3bb0f2a956775081b39 100644 (file)
@@ -81,7 +81,9 @@ test_scripts +=                               \
        daemon-conf                     \
        define-dev-segfault             \
        int-overflow                    \
+       libvirtd-fail                   \
        libvirtd-net-persist            \
+       libvirtd-pool                   \
        read-bufsiz                     \
        read-non-seekable               \
        start                           \
diff --git a/tests/libvirtd-fail b/tests/libvirtd-fail
new file mode 100755 (executable)
index 0000000..92b82c4
--- /dev/null
@@ -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
diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool
new file mode 100755 (executable)
index 0000000..370f3b1
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Get coverage of libvirtd's config-parsing code.
+
+if test "$VERBOSE" = yes; then
+  set -x
+  libvirtd --version
+  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
+sock_dir="$pwd"
+cat > conf <<EOF || fail=1
+unix_sock_dir = "$sock_dir"
+log_outputs = "3:file:$pwd/log"
+EOF
+
+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
+
+# remove random uuid
+sed 's/<uuid>.*/-/' out > k && mv k out || fail=1
+
+kill $pid
+
+cat <<EOF > pool-list-exp
+Pool P defined
+
+<pool type='dir'>
+  <name>P</name>
+  -
+  <capacity>0</capacity>
+  <allocation>0</allocation>
+  <available>0</available>
+  <source>
+  </source>
+  <target>
+    <path>/target-path</path>
+    <permissions>
+      <mode>0700</mode>
+      <owner>500</owner>
+      <group>500</group>
+    </permissions>
+  </target>
+</pool>
+
+EOF
+
+compare pool-list-exp out || fail=1
+compare /dev/null libvirtd-log || fail=1
+
+exit $fail