]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ovsdb-data.at
ovs-ctl: Log messages about database upgrade process.
[mirror_ovs.git] / tests / ovsdb-data.at
CommitLineData
958ac03a
BP
1AT_BANNER([OVSDB -- default values])
2
99155935 3OVSDB_CHECK_POSITIVE_CPY([default atoms],
958ac03a
BP
4 [default-atoms],
5 [[integer: OK
6real: OK
7boolean: OK
8string: OK
9uuid: OK]])
10
99155935 11OVSDB_CHECK_POSITIVE_CPY([default data],
958ac03a
BP
12 [default-data],
13 [[key integer, value void, n_min 0: OK
14key integer, value integer, n_min 0: OK
15key integer, value real, n_min 0: OK
16key integer, value boolean, n_min 0: OK
17key integer, value string, n_min 0: OK
18key integer, value uuid, n_min 0: OK
19key real, value void, n_min 0: OK
20key real, value integer, n_min 0: OK
21key real, value real, n_min 0: OK
22key real, value boolean, n_min 0: OK
23key real, value string, n_min 0: OK
24key real, value uuid, n_min 0: OK
25key boolean, value void, n_min 0: OK
26key boolean, value integer, n_min 0: OK
27key boolean, value real, n_min 0: OK
28key boolean, value boolean, n_min 0: OK
29key boolean, value string, n_min 0: OK
30key boolean, value uuid, n_min 0: OK
31key string, value void, n_min 0: OK
32key string, value integer, n_min 0: OK
33key string, value real, n_min 0: OK
34key string, value boolean, n_min 0: OK
35key string, value string, n_min 0: OK
36key string, value uuid, n_min 0: OK
37key uuid, value void, n_min 0: OK
38key uuid, value integer, n_min 0: OK
39key uuid, value real, n_min 0: OK
40key uuid, value boolean, n_min 0: OK
41key uuid, value string, n_min 0: OK
42key uuid, value uuid, n_min 0: OK
43key integer, value void, n_min 1: OK
44key integer, value integer, n_min 1: OK
45key integer, value real, n_min 1: OK
46key integer, value boolean, n_min 1: OK
47key integer, value string, n_min 1: OK
48key integer, value uuid, n_min 1: OK
49key real, value void, n_min 1: OK
50key real, value integer, n_min 1: OK
51key real, value real, n_min 1: OK
52key real, value boolean, n_min 1: OK
53key real, value string, n_min 1: OK
54key real, value uuid, n_min 1: OK
55key boolean, value void, n_min 1: OK
56key boolean, value integer, n_min 1: OK
57key boolean, value real, n_min 1: OK
58key boolean, value boolean, n_min 1: OK
59key boolean, value string, n_min 1: OK
60key boolean, value uuid, n_min 1: OK
61key string, value void, n_min 1: OK
62key string, value integer, n_min 1: OK
63key string, value real, n_min 1: OK
64key string, value boolean, n_min 1: OK
65key string, value string, n_min 1: OK
66key string, value uuid, n_min 1: OK
67key uuid, value void, n_min 1: OK
68key uuid, value integer, n_min 1: OK
69key uuid, value real, n_min 1: OK
70key uuid, value boolean, n_min 1: OK
71key uuid, value string, n_min 1: OK
72key uuid, value uuid, n_min 1: OK]])
73
bd76d25d 74AT_BANNER([OVSDB -- atoms without constraints])
f85f8ebb 75
99155935 76OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON],
f85f8ebb
BP
77 [[parse-atoms '["integer"]' \
78 '[0]' \
79 '[-1]' \
80 '[1e3]' \
81 '[9223372036854775807]' \
82 '[-9223372036854775808]' ]],
83 [0
84-1
851000
869223372036854775807
87-9223372036854775808])
88
5c414a2e
BP
89OVSDB_CHECK_POSITIVE([integer atom from string],
90 [[parse-atom-strings -- '["integer"]' \
91 '0' \
92 '-1' \
93 '+1000' \
94 '9223372036854775807' \
95 '-9223372036854775808' ]],
96 [0
97-1
981000
999223372036854775807
100-9223372036854775808])
101
99155935 102OVSDB_CHECK_POSITIVE_CPY([real atom from JSON],
f85f8ebb
BP
103 [[parse-atoms '["real"]' \
104 '[0]' \
105 '[0.0]' \
106 '[-0.0]' \
107 '[-1.25]' \
108 '[1e3]' \
109 '[1e37]' \
110 '[0.00390625]' ]],
111 [0
1120
1130
114-1.25
1151000
1161e+37
1170.00390625])
118
5c414a2e
BP
119OVSDB_CHECK_POSITIVE([real atom from string],
120 [[parse-atom-strings -- '["real"]' \
121 '0' \
122 '0.0' \
123 '-0.0' \
124 '-1.25' \
125 '1e3' \
126 '1e37' \
127 '0.00390625' ]],
128 [0
1290
1300
131-1.25
1321000
1331e+37
1340.00390625])
135
99155935 136OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
f85f8ebb
BP
137 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
138 [true
139false])
140
5c414a2e
BP
141OVSDB_CHECK_POSITIVE([boolean atom from string],
142 [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
143 [true
144false])
145
99155935 146OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
f85f8ebb
BP
147 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
148 [""
149"true"
150"\"\\/\b\f\n\r\t"])
151
5c414a2e
BP
152OVSDB_CHECK_POSITIVE([string atom from string],
153 [[parse-atom-strings '["string"]' \
154 'unquoted' \
155 '"quoted-string"' \
156 '"needs quotes"' \
157 '""' \
158 '"true"' \
159 '"\"\\\/\b\f\n\r\t"']],
160 [unquoted
161quoted-string
162"needs quotes"
163""
164"true"
165"\"\\/\b\f\n\r\t"])
166
99155935 167OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON],
f85f8ebb
BP
168 [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
169 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
170
5c414a2e
BP
171OVSDB_CHECK_POSITIVE([uuid atom from string],
172 [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
173 [550e8400-e29b-41d4-a716-446655440000])
174
99155935 175OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
f85f8ebb
BP
176 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
177 [[[-1,0,1,2,55]]])
178
99155935 179OVSDB_CHECK_POSITIVE_CPY([real atom sorting],
f85f8ebb
BP
180 [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
181 [[[-1e+99,0,0,1.23,1.25]]])
182
99155935 183OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
f85f8ebb
BP
184 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
185 [[[false,false,false,true,true]]])
186
99155935 187OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
f85f8ebb
BP
188 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
189 [[["\b","abc","abd","xxx"]]])
190
99155935 191OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting],
f85f8ebb
BP
192 [[sort-atoms '["uuid"]' '[
193 ["uuid", "00000000-0000-0000-0000-000000000001"],
194 ["uuid", "00000000-1000-0000-0000-000000000000"],
195 ["uuid", "00000000-0000-1000-0000-000000000000"],
196 ["uuid", "00010000-0000-0000-0000-000000000000"],
197 ["uuid", "00000000-0000-0000-0000-000000000100"],
198 ["uuid", "00000000-0000-0000-0000-000100000000"],
199 ["uuid", "00000000-0000-0010-0000-000000000000"],
200 ["uuid", "00000100-0000-0000-0000-000000000000"],
201 ["uuid", "00000000-0000-0001-0000-000000000000"],
202 ["uuid", "00000000-0000-0000-0000-000001000000"],
203 ["uuid", "01000000-0000-0000-0000-000000000000"],
204 ["uuid", "00000000-0000-0000-0000-000000001000"],
205 ["uuid", "00000000-0000-0000-0000-000010000000"],
206 ["uuid", "00000000-0000-0000-0000-010000000000"],
207 ["uuid", "00000000-0000-0100-0000-000000000000"],
208 ["uuid", "10000000-0000-0000-0000-000000000000"],
209 ["uuid", "00000000-0000-0000-0000-000000000010"],
210 ["uuid", "00000000-0100-0000-0000-000000000000"],
211 ["uuid", "00000000-0000-0000-0100-000000000000"],
212 ["uuid", "00000000-0000-0000-0001-000000000000"],
213 ["uuid", "00000010-0000-0000-0000-000000000000"],
214 ["uuid", "00000000-0000-0000-0010-000000000000"],
215 ["uuid", "00000000-0000-0000-0000-000000010000"],
216 ["uuid", "00000000-0000-0000-1000-000000000000"],
217 ["uuid", "00000000-0000-0000-0000-100000000000"],
218 ["uuid", "00000000-0000-0000-0000-001000000000"],
219 ["uuid", "00000000-0000-0000-0000-000000100000"],
220 ["uuid", "00000000-0000-0000-0000-000000000000"],
221 ["uuid", "00000000-0010-0000-0000-000000000000"],
222 ["uuid", "00100000-0000-0000-0000-000000000000"],
223 ["uuid", "00000000-0001-0000-0000-000000000000"],
224 ["uuid", "00000001-0000-0000-0000-000000000000"],
225 ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
226 [[[["uuid","00000000-0000-0000-0000-000000000000"],["uuid","00000000-0000-0000-0000-000000000001"],["uuid","00000000-0000-0000-0000-000000000010"],["uuid","00000000-0000-0000-0000-000000000100"],["uuid","00000000-0000-0000-0000-000000001000"],["uuid","00000000-0000-0000-0000-000000010000"],["uuid","00000000-0000-0000-0000-000000100000"],["uuid","00000000-0000-0000-0000-000001000000"],["uuid","00000000-0000-0000-0000-000010000000"],["uuid","00000000-0000-0000-0000-000100000000"],["uuid","00000000-0000-0000-0000-001000000000"],["uuid","00000000-0000-0000-0000-010000000000"],["uuid","00000000-0000-0000-0000-100000000000"],["uuid","00000000-0000-0000-0001-000000000000"],["uuid","00000000-0000-0000-0010-000000000000"],["uuid","00000000-0000-0000-0100-000000000000"],["uuid","00000000-0000-0000-1000-000000000000"],["uuid","00000000-0000-0001-0000-000000000000"],["uuid","00000000-0000-0010-0000-000000000000"],["uuid","00000000-0000-0100-0000-000000000000"],["uuid","00000000-0000-1000-0000-000000000000"],["uuid","00000000-0001-0000-0000-000000000000"],["uuid","00000000-0010-0000-0000-000000000000"],["uuid","00000000-0100-0000-0000-000000000000"],["uuid","00000000-1000-0000-0000-000000000000"],["uuid","00000001-0000-0000-0000-000000000000"],["uuid","00000010-0000-0000-0000-000000000000"],["uuid","00000100-0000-0000-0000-000000000000"],["uuid","00001000-0000-0000-0000-000000000000"],["uuid","00010000-0000-0000-0000-000000000000"],["uuid","00100000-0000-0000-0000-000000000000"],["uuid","01000000-0000-0000-0000-000000000000"],["uuid","10000000-0000-0000-0000-000000000000"]]]])
227
99155935 228OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom],
f85f8ebb 229 [[parse-atoms '["integer"]' '[0.5]' ]],
bd76d25d
BP
230 [syntax "0.5": syntax error: expected integer])
231
232dnl <C0> is not allowed anywhere in a UTF-8 string.
233dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
be44585c 234OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings],
bd76d25d 235 [parse-atoms '[["string"]]' \
a238d75e
BP
236 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
237 '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \
bd76d25d 238],
be44585c
BP
239 [constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
240constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])
241
242dnl Python won't let invalid UTF-8 (its idea of invalid UTF-8, anyway) into it
243dnl at all, so this test never gets as far as a constraint violation. It's
244dnl just a JSON parse error.
245dnl
246dnl <C0> is not allowed anywhere in a UTF-8 string.
247dnl (<ED A0 80> is not allowed in UTF-8 but Python doesn't care.)
248dnl <ED 80 7F> is not allowed in UTF-8.
249OVSDB_CHECK_POSITIVE_PY([no invalid UTF-8 sequences in strings - Python],
250 [parse-atoms '[["string"]]' \
251 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
252 '@<:@"m4_esyscmd([printf "\355\200\177"])"@:>@' \
253],
254 ["not a valid UTF-8 string: invalid UTF-8 sequence 0xc0"
255"not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0x80"])
f85f8ebb 256
5c414a2e
BP
257OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
258 [[parse-atom-strings '["integer"]' '0.5' ]],
259 ["0.5" is not a valid integer])
260
99155935 261OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
f85f8ebb 262 [[parse-atoms '["boolean"]' '["true"]' ]],
bd76d25d 263 [syntax ""true"": syntax error: expected boolean])
f85f8ebb 264
5c414a2e
BP
265OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean string atom],
266 [[parse-atom-strings '["boolean"]' '"true"' ]],
267 [""true"" is not a valid boolean (use "true" or "false")])
268
99155935 269OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
f85f8ebb 270 [[parse-atoms '["string"]' '[1]']],
bd76d25d 271 [syntax "1": syntax error: expected string])
f85f8ebb 272
99155935 273OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
f85f8ebb 274 [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
bd76d25d 275 [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
fdba6728
BP
276
277OVSDB_CHECK_POSITIVE_CPY([named-uuid requires symbol table],
278 [parse-atoms '[["uuid"]]' '[["named-uuid", "x"]]'],
279 [[syntax "["named-uuid","x"]": syntax error: expected ["uuid", <string>]]])
f85f8ebb 280
5c414a2e
BP
281OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
282 [[parse-atom-strings '["string"]' '']],
283 [An empty string is not valid as input; use "" to represent the empty string])
284
285OVSDB_CHECK_NEGATIVE([quotes must be balanced],
286 [parse-atom-strings '[["string"]]' '"asdf'],
287 ["asdf: missing quote at end of quoted string])
288
289OVSDB_CHECK_NEGATIVE([uuids must be valid],
290 [parse-atom-strings '[["uuid"]]' '1234-5678'],
291 ["1234-5678" is not a valid UUID])
bd76d25d 292\f
bfc96d9b
BP
293AT_BANNER([OVSDB -- atoms with enum constraints])
294
99155935 295OVSDB_CHECK_POSITIVE_CPY([integer atom enum],
bfc96d9b
BP
296 [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
297 '[0]' \
298 '[1]' \
299 '[2]' \
300 '[3]' \
301 '[6]' \
302 '[7]' \
303 '[8]' \
304 '[9]' \
305 '[10]' \
306 '[11]']],
307 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
3081
309constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
310constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
3116
312constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
3138
314constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
31510
316constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
317
99155935 318OVSDB_CHECK_POSITIVE_CPY([real atom enum],
bfc96d9b
BP
319 [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
320 '[-2]' \
321 '[-1]' \
322 '[-1.5]' \
323 '[0]' \
324 '[1]' \
325 '[1.5]' \
326 '[2]']],
327 [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
328constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
329-1.5
330constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
331constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
3321.5
333constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
334
99155935 335OVSDB_CHECK_POSITIVE_CPY([boolean atom enum],
bfc96d9b
BP
336 [[parse-atoms '[{"type": "boolean", "enum": false}]' \
337 '[false]' \
338 '[true]']],
339 [[false
340constraint violation: true is not one of the allowed values ([false])]])
341
99155935 342OVSDB_CHECK_POSITIVE_CPY([string atom enum],
bfc96d9b
BP
343 [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
344 '[""]' \
345 '["ab"]' \
346 '["abc"]' \
347 '["def"]' \
348 '["defg"]' \
349 '["DEF"]']],
350 [[constraint violation: "" is not one of the allowed values ([abc, def])
351constraint violation: ab is not one of the allowed values ([abc, def])
352"abc"
353"def"
354constraint violation: defg is not one of the allowed values ([abc, def])
355constraint violation: DEF is not one of the allowed values ([abc, def])]])
356
99155935 357OVSDB_CHECK_POSITIVE_CPY([uuid atom enum],
bfc96d9b
BP
358 [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
359 '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
360 '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
361 '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']],
362 [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
363["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
364constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])
365\f
366AT_BANNER([OVSDB -- atoms with other constraints])
bd76d25d 367
99155935 368OVSDB_CHECK_POSITIVE_CPY([integers >= 5],
bd76d25d
BP
369 [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
370 '[0]' \
371 '[4]' \
372 '[5]' \
373 '[6]' \
374 '[12345]']],
375 [constraint violation: 0 is less than minimum allowed value 5
376constraint violation: 4 is less than minimum allowed value 5
3775
3786
37912345])
380
99155935 381OVSDB_CHECK_POSITIVE_CPY([integers <= -1],
bd76d25d
BP
382 [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
383 '[0]' \
384 '[-1]' \
385 '[-2]' \
386 '[-123]']],
387 [constraint violation: 0 is greater than maximum allowed value -1
388-1
389-2
390-123])
391
99155935 392OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10],
bd76d25d
BP
393 [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
394 '[-20]' \
395 '[-11]' \
396 '[-10]' \
397 '[-9]' \
398 '[1]' \
399 '[9]' \
400 '[10]' \
401 '[11]' \
402 '[123576]']],
403 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
404constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
405-10
406-9
4071
4089
40910
410constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
411constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
412
99155935 413OVSDB_CHECK_POSITIVE_CPY([reals >= 5],
bd76d25d
BP
414 [[parse-atoms '[{"type": "real", "minReal": 5}]' \
415 '[0]' \
416 '[4]' \
417 '[5]' \
418 '[6]' \
419 '[12345]']],
420 [constraint violation: 0 is less than minimum allowed value 5
421constraint violation: 4 is less than minimum allowed value 5
4225
4236
42412345])
425
99155935 426OVSDB_CHECK_POSITIVE_CPY([reals <= -1],
bd76d25d
BP
427 [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
428 '[0]' \
429 '[-1]' \
430 '[-2]' \
431 '[-123]']],
432 [constraint violation: 0 is greater than maximum allowed value -1
433-1
434-2
435-123])
436
99155935 437OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10],
bd76d25d
BP
438 [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
439 '[-20]' \
440 '[-11]' \
441 '[-10]' \
442 '[-9]' \
443 '[1]' \
444 '[9]' \
445 '[10]' \
446 '[11]' \
447 '[123576]']],
448 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
449constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
450-10
451-9
4521
4539
45410
455constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
456constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
457
99155935 458OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
bd76d25d
BP
459 [[parse-atoms '{"type": "string", "minLength": 2}' \
460 '[""]' \
461 '["a"]' \
462 '["ab"]' \
463 '["abc"]' \
464 '["\ud834\udd1e"]']],
465 [[constraint violation: "" length 0 is less than minimum allowed length 2
466constraint violation: "a" length 1 is less than minimum allowed length 2
467"ab"
468"abc"
be44585c 469constraint violation: "𝄞" length 1 is less than minimum allowed length 2]])
bd76d25d 470
99155935 471OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
bd76d25d
BP
472 [[parse-atoms '{"type": "string", "maxLength": 2}' \
473 '[""]' \
474 '["a"]' \
475 '["ab"]' \
476 '["abc"]' \
65683353 477 '["de"]']],
bd76d25d
BP
478 [[""
479"a"
480"ab"
481constraint violation: "abc" length 3 is greater than maximum allowed length 2
65683353 482"de"]])
5c414a2e 483
f85f8ebb
BP
484AT_BANNER([OSVDB -- simple data])
485
99155935 486OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
ae8f13e2 487 [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
f85f8ebb
BP
488 [0
4891
490-1])
491
5c414a2e
BP
492OVSDB_CHECK_POSITIVE([integer string datum],
493 [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
494 [0
4951
496-1
4971])
498
99155935 499OVSDB_CHECK_POSITIVE_CPY([real JSON datum],
ae8f13e2 500 [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
f85f8ebb
BP
501 [0
5021
503-1.25])
504
5c414a2e
BP
505OVSDB_CHECK_POSITIVE([real string datum],
506 [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
507 [0
5081
509-1.25])
510
99155935 511OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
ae8f13e2 512 [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
f85f8ebb
BP
513 [true
514false])
515
5c414a2e
BP
516OVSDB_CHECK_POSITIVE([boolean string datum],
517 [[parse-data-strings '["boolean"]' 'true' 'false' ]],
518 [true
519false])
520
99155935 521OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
ae8f13e2 522 [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
f85f8ebb
BP
523 [""
524"true"
525"\"\\/\b\f\n\r\t"])
526
5c414a2e
BP
527OVSDB_CHECK_POSITIVE([string string datum],
528 [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
529 [x
530""
531"true"
532"\"\\/\b\f\n\r\t"])
bd76d25d 533\f
f85f8ebb
BP
534AT_BANNER([OVSDB -- set data])
535
99155935 536OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
f85f8ebb 537 [[parse-data '{"key": "boolean", "min": 0}' \
ae8f13e2 538 '[true]' \
f85f8ebb
BP
539 '["set", [false]]' \
540 '["set", []]']],
ae8f13e2
BP
541 [[true
542false
f85f8ebb
BP
543["set",[]]]],
544 [set])
545
5c414a2e
BP
546OVSDB_CHECK_POSITIVE([string optional boolean],
547 [[parse-data-strings '{"key": "boolean", "min": 0}' \
548 'true' \
549 'false' \
550 '[]']],
551 [[true
552false
553[]]],
554 [set])
555
99155935 556OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
f85f8ebb
BP
557 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
558 '["set", [0]]' \
ae8f13e2 559 '[1]' \
f85f8ebb
BP
560 '["set", [0, 1]]' \
561 '["set", [0, 1, 2]]' \
562 '["set", [0, 1, 2, 3, 4, 5]]' \
563 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
564 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
ae8f13e2
BP
565 [[0
5661
f85f8ebb
BP
567["set",[0,1]]
568["set",[0,1,2]]
569["set",[0,1,2,3,4,5]]
570["set",[0,1,2,3,4,5,6,7,8]]
571["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
572
5c414a2e
BP
573OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
574 [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
575 '0' \
576 '0,1' \
577 '0, 1, 2' \
578 '[0, 1,2, 3, 4, 5]' \
579 '0, 1,2, 3,4, 5, 6, 7, 8' \
580 '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']],
581 [[[0]
582[0, 1]
583[0, 1, 2]
584[0, 1, 2, 3, 4, 5]
585[0, 1, 2, 3, 4, 5, 6, 7, 8]
586[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
587
99155935 588OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
f85f8ebb
BP
589 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
590 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
ae8f13e2 591 '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
f85f8ebb
BP
592 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
593 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
594 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
ae8f13e2
BP
595 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
596["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
f85f8ebb
BP
597["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
598
5c414a2e
BP
599OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
600 [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
601 '[550e8400-e29b-41d4-a716-446655440000]' \
602 '[c5051240-30ff-43ed-b4b9-93cf3f050813,
603 90558331-09af-4d2f-a572-509cad2e9088,
604 550e8400-e29b-41d4-a716-446655440000]']],
605 [[[550e8400-e29b-41d4-a716-446655440000]
606[550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
607
99155935 608OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
f85f8ebb
BP
609 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
610 '["set", []]' \
ae8f13e2 611 '["a longer string"]' \
f85f8ebb
BP
612 '["set", ["a relatively long string"]]' \
613 '["set", ["short string", "a relatively long string"]]' \
614 '["set", ["zzz", "short string", "a relatively long string"]]']],
615 [[["set",[]]
ae8f13e2
BP
616"a longer string"
617"a relatively long string"
f85f8ebb
BP
618["set",["a relatively long string","short string"]]
619["set",["a relatively long string","short string","zzz"]]]])
620
5c414a2e
BP
621OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
622 [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
623 '[]' \
624 '"a relatively long string"' \
625 '["short string", "a relatively long string"]' \
626 '"zzz","short string","a relatively long string"']],
627 [[[]
628["a relatively long string"]
629["a relatively long string", "short string"]
630["a relatively long string", "short string", zzz]]])
631
99155935 632OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
f85f8ebb
BP
633 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
634 [ovsdb error: set contains duplicate])
635
5c414a2e
BP
636OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
637 [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
638 [set contains duplicate value])
639
99155935 640OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
f85f8ebb
BP
641 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
642 [ovsdb error: set contains duplicate])
643
5c414a2e
BP
644OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
645 [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
646 [set contains duplicate value])
647
99155935 648OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
f85f8ebb
BP
649 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
650 [ovsdb error: set contains duplicate])
651
5c414a2e
BP
652OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
653 [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
654 [set contains duplicate value])
655
99155935 656OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
f85f8ebb
BP
657 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
658 [ovsdb error: set contains duplicate])
659
5c414a2e
BP
660OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
661 [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
662 [set contains duplicate value])
663
99155935 664OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
f85f8ebb
BP
665 [[parse-data '{"key": "uuid", "max": 5}' \
666 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
667 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
668 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
669 [ovsdb error: set contains duplicate])
670
5c414a2e
BP
671OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
672 [[parse-data-strings '{"key": "uuid", "max": 5}' \
673 '7ef21525-0088-4a28-a418-5518413e43ea,
674 355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
675 7ef21525-0088-4a28-a418-5518413e43ea']],
676 [set contains duplicate value])
bd76d25d 677\f
f85f8ebb
BP
678AT_BANNER([OVSDB -- map data])
679
99155935 680OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
f85f8ebb
BP
681 [[parse-data '{"key": "integer", "value": "boolean"}' \
682 '["map", [[1, true]]]']],
683 [[["map",[[1,true]]]]])
684
5c414a2e
BP
685OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
686 [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
687 '1=true']],
688 [[1=true]])
689
99155935 690OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
f85f8ebb
BP
691 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
692 '["map", [[1, true]]]' \
693 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
694 '["map", [[3, false], [0, true], [4, false]]]']],
695 [[["map",[[1,true]]]
696["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
697["map",[[0,true],[3,false],[4,false]]]]])
698
5c414a2e
BP
699OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
700 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
701 '1=true' \
702 '0=true 1=false 2=true, 3=true 4=true,' \
703 '3=false,0=true ,4=false']],
704 [[{1=true}
705{0=true, 1=false, 2=true, 3=true, 4=true}
706{0=true, 3=false, 4=false}]])
707
99155935 708OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
f85f8ebb
BP
709 [[parse-data '{"key": "boolean", "value": "integer"}' \
710 '["map", [[true, 1]]]']],
711 [[["map",[[true,1]]]]])
712
5c414a2e
BP
713OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
714 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
715 'true=1']],
716 [[true=1]])
717
99155935 718OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
31a763d7 719 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
f85f8ebb
BP
720 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
721 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
722 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
723 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
724 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
725 [[["map",[[["uuid","1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"],5],[["uuid","25bfa475-d072-4f60-8be1-00f48643e9cb"],4],[["uuid","6b94b968-2702-4f64-9457-314a34d69b8c"],2],[["uuid","cad8542b-6ee1-486b-971b-7dcbf6e14979"],1],[["uuid","d2c4a168-24de-47eb-a8a3-c1abfc814979"],3]]]]])
726
5c414a2e
BP
727OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
728 [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
729 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
730 6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
731 d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
732 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
733 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
734 [[{1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5, 25bfa475-d072-4f60-8be1-00f48643e9cb=4, 6b94b968-2702-4f64-9457-314a34d69b8c=2, cad8542b-6ee1-486b-971b-7dcbf6e14979=1, d2c4a168-24de-47eb-a8a3-c1abfc814979=3}]])
735
99155935 736OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
31a763d7 737 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
f85f8ebb
BP
738 '["map", [["2 gills", "1 chopin"],
739 ["2 chopins", "1 pint"],
740 ["2 pints", "1 quart"],
741 ["2 quarts", "1 pottle"],
742 ["2 pottles", "1 gallon"],
743 ["2 gallons", "1 peck"],
744 ["2 pecks", "1 demibushel"],
745 ["2 demibushel", "1 firkin"],
746 ["2 firkins", "1 kilderkin"],
747 ["2 kilderkins", "1 barrel"]]]']],
748 [[["map",[["2 chopins","1 pint"],["2 demibushel","1 firkin"],["2 firkins","1 kilderkin"],["2 gallons","1 peck"],["2 gills","1 chopin"],["2 kilderkins","1 barrel"],["2 pecks","1 demibushel"],["2 pints","1 quart"],["2 pottles","1 gallon"],["2 quarts","1 pottle"]]]]])
749
5c414a2e
BP
750OVSDB_CHECK_POSITIVE([string map of 10 string to string],
751 [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
752 '{"2 gills"="1 chopin",
753 "2 chopins"= "1 pint",
754 "2 pints"= "1 quart",
755 "2 quarts"= "1 pottle",
756 "2 pottles"= "1 gallon",
757 "2 gallons"= "1 peck",
758 "2 pecks"= "1 demibushel",
759 "2 demibushel"= "1 firkin",
760 "2 firkins"= "1 kilderkin",
761 "2 kilderkins"= "1 barrel"}']],
762 [[{"2 chopins"="1 pint", "2 demibushel"="1 firkin", "2 firkins"="1 kilderkin", "2 gallons"="1 peck", "2 gills"="1 chopin", "2 kilderkins"="1 barrel", "2 pecks"="1 demibushel", "2 pints"="1 quart", "2 pottles"="1 gallon", "2 quarts"="1 pottle"}]])
763
99155935 764OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
f85f8ebb
BP
765 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
766 '["map", [[1, true], [2, false], [1, false]]]']],
767 [ovsdb error: map contains duplicate key])
5c414a2e
BP
768
769OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
770 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
771 '1=true 2=false 1=false']],
772 [map contains duplicate key])