libvirt/tests/libvirtd-pool
Jim Meyering d15549aee0 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.
2009-03-02 20:01:05 +00:00

64 lines
1.2 KiB
Bash
Executable File

#!/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