tests: Split images -> tests/data + tests/guests
[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' > 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_verbose
57 trace get_verbose
58 trace get_verbose = 0
59 enter get_trace
60 trace get_trace
61 trace get_trace = 1
62 enter get_autosync
63 trace get_autosync
64 trace get_autosync = 1
65 enter get_path
66 trace get_path
67 trace get_path = "../appliance"
68 enter get_pgroup
69 trace get_pgroup
70 trace get_pgroup = 0
71 trace close
72 close
73 "ev1" (0): close,subprocess_quit: echo $EVENT $@
74 "ev2" (1): close,subprocess_quit: echo $EVENT $@
75 "ev3" (2): launch_done: echo $EVENT $@
76 "ev1" (0): close,subprocess_quit: echo $EVENT $@
77 "ev2" (1): close,subprocess_quit: echo $EVENT $@
78 "ev3" (2): launch_done: echo $EVENT $@
79 "ev2" (1): close,subprocess_quit: echo $EVENT $@
80 "ev3" (2): launch_done: echo $EVENT $@
81 "ev2" (1): close,subprocess_quit: echo $EVENT $@
82 close' ]; then
83     echo "$0: unexpected output from guestfish events"
84     cat test.out
85     exit 1
86 fi
87
88 rm test.out