ia64/xen-unstable

view tools/xenstore/testsuite/07watch.test @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children f7a7f8f2e6e4 872cf6ee0594
line source
1 # Watch something, write to it, check watch has fired.
2 write /test create contents
4 1 watch /test token
5 2 write /test create contents2
6 expect 1:/test:token
7 1 waitwatch
8 1 ackwatch token
9 1 close
11 # Check that reads don't set it off.
12 1 watch /test token
13 expect 2:contents2
14 2 read /test
15 expect 1: waitwatch failed: Connection timed out
16 1 waitwatch
17 1 close
19 # mkdir, setperm and rm should (also tests watching dirs)
20 mkdir /dir
21 1 watch /dir token
22 2 mkdir /dir/newdir
23 expect 1:/dir/newdir:token
24 1 waitwatch
25 1 ackwatch token
26 2 setperm /dir/newdir 0 READ
27 expect 1:/dir/newdir:token
28 1 waitwatch
29 1 ackwatch token
30 2 rm /dir/newdir
31 expect 1:/dir/newdir:token
32 1 waitwatch
33 1 ackwatch token
34 1 close
35 2 close
37 # Changed in b594bb976a743d509f1ffabb5bc698874ab90d8f
38 ## We don't get a watch from our own commands.
39 #watch /dir token
40 #mkdir /dir/newdir
41 #expect waitwatch failed: Connection timed out
42 #waitwatch
43 #close
45 # ignore watches while doing commands, should work.
46 watch /dir token
47 1 write /dir/test create contents
48 expect contents
49 read /dir/test
50 expect /dir/test:token
51 waitwatch
52 ackwatch token
53 close
55 # watch priority test: all simultaneous
56 1 watch /dir token1
57 3 watch /dir token3
58 2 watch /dir token2
59 write /dir/test create contents
60 expect 3:/dir/test:token3
61 3 waitwatch
62 3 ackwatch token3
63 expect 2:/dir/test:token2
64 2 waitwatch
65 2 ackwatch token2
66 expect 1:/dir/test:token1
67 1 waitwatch
68 1 ackwatch token1
69 1 close
70 2 close
71 3 close
73 # If one dies (without acking), the other should still get ack.
74 1 watch /dir token1
75 2 watch /dir token2
76 write /dir/test create contents
77 expect 2:/dir/test:token2
78 2 waitwatch
79 2 close
80 expect 1:/dir/test:token1
81 1 waitwatch
82 1 ackwatch token1
83 1 close
85 # If one dies (without reading at all), the other should still get ack.
86 1 watch /dir token1
87 2 watch /dir token2
88 write /dir/test create contents
89 2 close
90 expect 1:/dir/test:token1
91 1 waitwatch
92 1 ackwatch token1
93 1 close
94 2 close
96 # unwatch
97 1 watch /dir token1
98 1 unwatch /dir token1
99 1 watch /dir token2
100 2 write /dir/test2 create contents
101 expect 1:/dir/test2:token2
102 1 waitwatch
103 1 unwatch /dir token2
104 1 close
105 2 close
107 # unwatch while watch pending. Other watcher still gets the event.
108 1 watch /dir token1
109 2 watch /dir token2
110 write /dir/test create contents
111 2 unwatch /dir token2
112 expect 1:/dir/test:token1
113 1 waitwatch
114 1 ackwatch token1
115 1 close
116 2 close
118 # unwatch while watch pending. Should clear this so we get next event.
119 1 watch /dir token1
120 write /dir/test create contents
121 1 unwatch /dir token1
122 1 watch /dir/test token2
123 write /dir/test none contents2
124 expect 1:/dir/test:token2
125 1 waitwatch
126 1 ackwatch token2
128 # check we only get notified once.
129 1 watch /test token
130 2 write /test create contents2
131 expect 1:/test:token
132 1 waitwatch
133 1 ackwatch token
134 expect 1: waitwatch failed: Connection timed out
135 1 waitwatch
136 1 close
138 # watches are queued in order.
139 1 watch / token
140 2 write /test1 create contents
141 2 write /test2 create contents
142 2 write /test3 create contents
143 expect 1:/test1:token
144 1 waitwatch
145 1 ackwatch token
146 expect 1:/test2:token
147 1 waitwatch
148 1 ackwatch token
149 expect 1:/test3:token
150 1 waitwatch
151 1 ackwatch token
152 1 close
154 # Creation of subpaths should be covered correctly.
155 1 watch / token
156 2 write /test/subnode create contents2
157 2 write /test/subnode/subnode create contents2
158 expect 1:/test/subnode:token
159 1 waitwatch
160 1 ackwatch token
161 expect 1:/test/subnode/subnode:token
162 1 waitwatch
163 1 ackwatch token
164 expect 1: waitwatch failed: Connection timed out
165 1 waitwatch
166 1 close
168 # Watch event must have happened before we registered interest.
169 1 watch / token
170 2 write /test/subnode create contents2
171 1 watch / token2 0
172 expect 1:/test/subnode:token
173 1 waitwatch
174 1 ackwatch token
175 expect 1: waitwatch failed: Connection timed out
176 1 waitwatch
177 1 close
179 # Rm fires notification on child.
180 1 watch /test/subnode token
181 2 rm /test
182 expect 1:/test/subnode:token
183 1 waitwatch
184 1 ackwatch token
186 # Watch should not double-send after we ack, even if we did something in between.
187 1 watch /test2 token
188 2 write /test2/foo create contents2
189 expect 1:/test2/foo:token
190 1 waitwatch
191 expect 1:contents2
192 1 read /test2/foo
193 1 ackwatch token
194 expect 1: waitwatch failed: Connection timed out
195 1 waitwatch