1 AT_BANNER([OVSDB -- logging])
3 AT_SETUP([create empty, reread])
4 AT_KEYWORDS([ovsdb log])
7 [test-ovsdb log-io file create], [0],
11 [test-ovsdb log-io file read-only read], [0],
12 [file: open successful
13 file: read: end of log
15 AT_CHECK([test -f .file.~lock~])
18 AT_SETUP([write one, reread])
19 AT_KEYWORDS([ovsdb log])
20 AT_CAPTURE_FILE([file])
22 [[test-ovsdb log-io file create 'write:[0]']], [0],
23 [[file: open successful
24 file: write:[0] successful
27 [test-ovsdb log-io file read-only read read], [0],
28 [[file: open successful
30 file: read: end of log
32 AT_CHECK([test -f .file.~lock~])
35 AT_SETUP([check that create fails if file exists])
36 AT_KEYWORDS([ovsdb log])
37 AT_CAPTURE_FILE([file])
39 [[test-ovsdb log-io file create 'write:[1]']], [0],
40 [[file: open successful
41 file: write:[1] successful
44 [test-ovsdb log-io file read-only read], [0],
45 [[file: open successful
49 [test-ovsdb log-io file create read], [1],
50 [], [test-ovsdb: I/O error: file: create failed (File exists)
52 AT_CHECK([test -f .file.~lock~])
55 AT_SETUP([write one, reread])
56 AT_KEYWORDS([ovsdb log])
57 AT_CAPTURE_FILE([file])
59 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
60 [[file: open successful
61 file: write:[0] successful
62 file: write:[1] successful
63 file: write:[2] successful
66 [test-ovsdb log-io file read-only read read read read], [0],
67 [[file: open successful
71 file: read: end of log
73 AT_CHECK([test -f .file.~lock~])
76 AT_SETUP([write one, reread, append])
77 AT_KEYWORDS([ovsdb log])
78 AT_CAPTURE_FILE([file])
80 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
81 [[file: open successful
82 file: write:[0] successful
83 file: write:[1] successful
84 file: write:[2] successful
87 [[test-ovsdb log-io file read/write read read read 'write:["append"]']], [0],
88 [[file: open successful
92 file: write:["append"] successful
95 [test-ovsdb log-io file read-only read read read read read], [0],
96 [[file: open successful
100 file: read: ["append"]
101 file: read: end of log
103 AT_CHECK([test -f .file.~lock~])
106 AT_SETUP([write, reread one, overwrite])
107 AT_KEYWORDS([ovsdb log])
108 AT_CAPTURE_FILE([file])
110 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
111 [[file: open successful
112 file: write:[0] successful
113 file: write:[1] successful
114 file: write:[2] successful
117 [[test-ovsdb log-io file read/write read 'write:["more data"]']], [0],
118 [[file: open successful
120 file: write:["more data"] successful
123 [test-ovsdb log-io file read-only read read read], [0],
124 [[file: open successful
126 file: read: ["more data"]
127 file: read: end of log
129 AT_CHECK([test -f .file.~lock~])
132 AT_SETUP([write, add corrupted data, read])
133 AT_KEYWORDS([ovsdb log])
134 AT_CAPTURE_FILE([file])
136 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
137 [[file: open successful
138 file: write:[0] successful
139 file: write:[1] successful
140 file: write:[2] successful
142 AT_CHECK([echo 'xxx' >> file])
144 [test-ovsdb log-io file read-only read read read read], [0],
145 [[file: open successful
149 file: read failed: syntax error: file: parse error at offset 174 in header line "xxx"
151 AT_CHECK([test -f .file.~lock~])
154 AT_SETUP([write, add corrupted data, read, overwrite])
155 AT_KEYWORDS([ovsdb log])
156 AT_CAPTURE_FILE([file])
158 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
159 [[file: open successful
160 file: write:[0] successful
161 file: write:[1] successful
162 file: write:[2] successful
164 AT_CHECK([echo 'xxx' >> file])
166 [[test-ovsdb log-io file read/write read read read read 'write:[3]']], [0],
167 [[file: open successful
171 file: read failed: syntax error: file: parse error at offset 174 in header line "xxx"
172 file: write:[3] successful
175 [test-ovsdb log-io file read-only read read read read read], [0],
176 [[file: open successful
181 file: read: end of log
183 AT_CHECK([test -f .file.~lock~])
186 AT_SETUP([write, corrupt some data, read, overwrite])
187 AT_KEYWORDS([ovsdb log])
188 AT_CAPTURE_FILE([file])
190 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
191 [[file: open successful
192 file: write:[0] successful
193 file: write:[1] successful
194 file: write:[2] successful
196 AT_CHECK([[sed 's/\[2]/[3]/' < file > file.tmp]])
197 AT_CHECK([mv file.tmp file])
198 AT_CHECK([[grep -c '\[3]' file]], [0], [1
201 [[test-ovsdb log-io file read/write read read read 'write:["longer data"]']], [0],
202 [[file: open successful
205 file: read failed: syntax error: file: 4 bytes starting at offset 170 have SHA-1 hash 5c031e5c0d3a9338cc127ebe40bb2748b6a67e78 but should have hash 98f55556e7ffd432381b56a19bd485b3e6446442
206 file: write:["longer data"] successful
209 [test-ovsdb log-io file read-only read read read read], [0],
210 [[file: open successful
213 file: read: ["longer data"]
214 file: read: end of log
216 AT_CHECK([test -f .file.~lock~])
219 AT_SETUP([write, truncate file, read, overwrite])
220 AT_KEYWORDS([ovsdb log])
221 AT_CAPTURE_FILE([file])
223 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
224 [[file: open successful
225 file: write:[0] successful
226 file: write:[1] successful
227 file: write:[2] successful
229 AT_CHECK([[sed 's/\[2]/2/' < file > file.tmp]])
230 AT_CHECK([mv file.tmp file])
231 AT_CHECK([[grep -c '^2$' file]], [0], [1
234 [[test-ovsdb log-io file read/write read read read 'write:["longer data"]']], [0],
235 [[file: open successful
238 file: read failed: I/O error: file: error reading 4 bytes starting at offset 170 (End of file)
239 file: write:["longer data"] successful
242 [test-ovsdb log-io file read-only read read read read], [0],
243 [[file: open successful
246 file: read: ["longer data"]
247 file: read: end of log
249 AT_CHECK([test -f .file.~lock~])
252 AT_SETUP([write bad JSON, read, overwrite])
253 AT_KEYWORDS([ovsdb log])
254 AT_CAPTURE_FILE([file])
256 [[test-ovsdb log-io file create 'write:[0]' 'write:[1]' 'write:[2]']], [0],
257 [[file: open successful
258 file: write:[0] successful
259 file: write:[1] successful
260 file: write:[2] successful
262 AT_CHECK([[printf '%s\n%s\n' 'OVSDB JSON 5 d910b02871075d3156ec8675dfc95b7d5d640aa6' 'null' >> file]])
264 [[test-ovsdb log-io file read/write read read read read 'write:["replacement data"]']], [0],
265 [[file: open successful
269 file: read failed: syntax error: file: 5 bytes starting at offset 228 are not valid JSON (line 0, column 4, byte 4: syntax error at beginning of input)
270 file: write:["replacement data"] successful
273 [test-ovsdb log-io file read-only read read read read read], [0],
274 [[file: open successful
278 file: read: ["replacement data"]
279 file: read: end of log
281 AT_CHECK([test -f .file.~lock~])