From d15549aee0bfe2cd41adc067a7a394f0cab9bd7e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 2 Mar 2009 20:01:05 +0000 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++ tests/Makefile.am | 2 ++ tests/libvirtd-fail | 21 +++++++++++++++ tests/libvirtd-pool | 63 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100755 tests/libvirtd-fail create mode 100755 tests/libvirtd-pool diff --git a/ChangeLog b/ChangeLog index 6f0f7ed860..0d6647282b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 2 21:00:00 +0100 2009 Jim Meyering + + 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 tests: fix an error that made us skip the daemon-conf test diff --git a/tests/Makefile.am b/tests/Makefile.am index b40785fee1..11ffe76369 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 0000000000..92b82c4b0b --- /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 diff --git a/tests/libvirtd-pool b/tests/libvirtd-pool new file mode 100755 index 0000000000..370f3b1c70 --- /dev/null +++ b/tests/libvirtd-pool @@ -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 < 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/.*/-/' out > k && mv k out || fail=1 + +kill $pid + +cat < pool-list-exp +Pool P defined + + + P + - + 0 + 0 + 0 + + + + /target-path + + 0700 + 500 + 500 + + + + +EOF + +compare pool-list-exp out || fail=1 +compare /dev/null libvirtd-log || fail=1 + +exit $fail