summaryrefslogtreecommitdiff
path: root/tests/libvirtd-net-persist
blob: 50a1ef42995973ac07b4cb6adf9502ac2f7861e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# ensure that net-destroy doesn't make network disappear (persistence-related)

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

cat > net.xml <<EOF || fail=1
<network>
  <name>N</name>
  <ip address="192.168.199.1" netmask="255.255.255.0"></ip>
</network>
EOF

cat > exp <<EOF || fail=1
Network N defined from net.xml

Network N destroyed

Name                 State      Autostart
-----------------------------------------
N                    inactive no

EOF

libvirtd --config=conf > libvirtd-log 2>&1 & pid=$!
sleep 1

url="qemu:///session?socket=@$sock_dir/libvirt-sock"
virsh -c "$url" \
    'net-define net.xml; net-destroy N; net-list --all' > out 2>&1 \
  || fail=1

# if libvird's log is empty, sleep for a second before killing it
test -s libvirtd-log || sleep 1
kill $pid

compare exp out || fail=1

printf "Shutting down network 'N'\n" > log-exp
compare log-exp libvirtd-log || fail=1

exit $fail