daemon: debug segv correct use of dereferencing NULL.
[libguestfs.git] / fish / test-guestfish-events.sh
1 #!/bin/bash -
2 # libguestfs
3 # Copyright (C) 2011 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 # Test guestfish events.
20
21 set -e
22
23 rm -f test.out
24
25 ../fish/guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' > test.out
26 trace true
27
28 event ev1 * "echo $EVENT $@"
29 event ev1 * "echo $EVENT $@"
30 event ev2 * "echo $EVENT $@"
31
32 list-events
33 delete-event ev1
34 list-events
35 reopen
36 list-events
37
38 event ev1 close,subprocess_quit "echo $EVENT $@"
39 event ev2 close,subprocess_quit "echo $EVENT $@"
40 event ev3 launch "echo $EVENT $@"
41
42 list-events
43 -delete-event ev4
44 list-events
45 delete-event ev1
46 list-events
47 delete-event ev3
48 list-events
49
50 EOF
51
52 if [ "$(cat test.out)" != '"ev1" (0): *: echo $EVENT $@
53 "ev1" (1): *: echo $EVENT $@
54 "ev2" (2): *: echo $EVENT $@
55 "ev2" (2): *: echo $EVENT $@
56 enter get_autosync
57 trace get_autosync
58 trace get_autosync = 1
59 enter get_path
60 trace get_path
61 trace get_path = "../appliance"
62 enter get_pgroup
63 trace get_pgroup
64 trace get_pgroup = 0
65 trace close
66 close
67 "ev1" (0): close,subprocess_quit: echo $EVENT $@
68 "ev2" (1): close,subprocess_quit: echo $EVENT $@
69 "ev3" (2): launch_done: echo $EVENT $@
70 "ev1" (0): close,subprocess_quit: echo $EVENT $@
71 "ev2" (1): close,subprocess_quit: echo $EVENT $@
72 "ev3" (2): launch_done: echo $EVENT $@
73 "ev2" (1): close,subprocess_quit: echo $EVENT $@
74 "ev3" (2): launch_done: echo $EVENT $@
75 "ev2" (1): close,subprocess_quit: echo $EVENT $@
76 close' ]; then
77     echo "$0: unexpected output from guestfish events"
78     cat test.out
79     exit 1
80 fi
81
82 rm test.out