]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovsdb-data.at
468e3b0f7d33a87f9428f1f66c70ee2464f60249
[mirror_ovs.git] / tests / ovsdb-data.at
1 AT_BANNER([OVSDB -- default values])
2
3 OVSDB_CHECK_POSITIVE_CPY([default atoms],
4 [default-atoms],
5 [[integer: OK
6 real: OK
7 boolean: OK
8 string: OK
9 uuid: OK]])
10
11 OVSDB_CHECK_POSITIVE_CPY([default data],
12 [default-data],
13 [[key integer, value void, n_min 0: OK
14 key integer, value integer, n_min 0: OK
15 key integer, value real, n_min 0: OK
16 key integer, value boolean, n_min 0: OK
17 key integer, value string, n_min 0: OK
18 key integer, value uuid, n_min 0: OK
19 key real, value void, n_min 0: OK
20 key real, value integer, n_min 0: OK
21 key real, value real, n_min 0: OK
22 key real, value boolean, n_min 0: OK
23 key real, value string, n_min 0: OK
24 key real, value uuid, n_min 0: OK
25 key boolean, value void, n_min 0: OK
26 key boolean, value integer, n_min 0: OK
27 key boolean, value real, n_min 0: OK
28 key boolean, value boolean, n_min 0: OK
29 key boolean, value string, n_min 0: OK
30 key boolean, value uuid, n_min 0: OK
31 key string, value void, n_min 0: OK
32 key string, value integer, n_min 0: OK
33 key string, value real, n_min 0: OK
34 key string, value boolean, n_min 0: OK
35 key string, value string, n_min 0: OK
36 key string, value uuid, n_min 0: OK
37 key uuid, value void, n_min 0: OK
38 key uuid, value integer, n_min 0: OK
39 key uuid, value real, n_min 0: OK
40 key uuid, value boolean, n_min 0: OK
41 key uuid, value string, n_min 0: OK
42 key uuid, value uuid, n_min 0: OK
43 key integer, value void, n_min 1: OK
44 key integer, value integer, n_min 1: OK
45 key integer, value real, n_min 1: OK
46 key integer, value boolean, n_min 1: OK
47 key integer, value string, n_min 1: OK
48 key integer, value uuid, n_min 1: OK
49 key real, value void, n_min 1: OK
50 key real, value integer, n_min 1: OK
51 key real, value real, n_min 1: OK
52 key real, value boolean, n_min 1: OK
53 key real, value string, n_min 1: OK
54 key real, value uuid, n_min 1: OK
55 key boolean, value void, n_min 1: OK
56 key boolean, value integer, n_min 1: OK
57 key boolean, value real, n_min 1: OK
58 key boolean, value boolean, n_min 1: OK
59 key boolean, value string, n_min 1: OK
60 key boolean, value uuid, n_min 1: OK
61 key string, value void, n_min 1: OK
62 key string, value integer, n_min 1: OK
63 key string, value real, n_min 1: OK
64 key string, value boolean, n_min 1: OK
65 key string, value string, n_min 1: OK
66 key string, value uuid, n_min 1: OK
67 key uuid, value void, n_min 1: OK
68 key uuid, value integer, n_min 1: OK
69 key uuid, value real, n_min 1: OK
70 key uuid, value boolean, n_min 1: OK
71 key uuid, value string, n_min 1: OK
72 key uuid, value uuid, n_min 1: OK]])
73
74 AT_BANNER([OVSDB -- atoms without constraints])
75
76 OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON],
77 [[parse-atoms '["integer"]' \
78 '[0]' \
79 '[-1]' \
80 '[1e3]' \
81 '[9223372036854775807]' \
82 '[-9223372036854775808]' ]],
83 [0
84 -1
85 1000
86 9223372036854775807
87 -9223372036854775808])
88
89 OVSDB_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
98 1000
99 9223372036854775807
100 -9223372036854775808])
101
102 OVSDB_CHECK_POSITIVE_CPY([real atom from JSON],
103 [[parse-atoms '["real"]' \
104 '[0]' \
105 '[0.0]' \
106 '[-0.0]' \
107 '[-1.25]' \
108 '[1e3]' \
109 '[1e37]' \
110 '[0.00390625]' ]],
111 [0
112 0
113 0
114 -1.25
115 1000
116 1e+37
117 0.00390625])
118
119 OVSDB_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
129 0
130 0
131 -1.25
132 1000
133 1e+37
134 0.00390625])
135
136 OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
137 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
138 [true
139 false])
140
141 OVSDB_CHECK_POSITIVE([boolean atom from string],
142 [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
143 [true
144 false])
145
146 OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
147 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
148 [""
149 "true"
150 "\"\\/\b\f\n\r\t"])
151
152 OVSDB_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
161 quoted-string
162 "needs quotes"
163 ""
164 "true"
165 "\"\\/\b\f\n\r\t"])
166
167 OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON],
168 [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
169 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
170
171 OVSDB_CHECK_POSITIVE([uuid atom from string],
172 [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
173 [550e8400-e29b-41d4-a716-446655440000])
174
175 OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
176 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
177 [[[-1,0,1,2,55]]])
178
179 OVSDB_CHECK_POSITIVE_CPY([real atom sorting],
180 [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
181 [[[-1e+99,0,0,1.23,1.25]]])
182
183 OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
184 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
185 [[[false,false,false,true,true]]])
186
187 OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
188 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
189 [[["\b","abc","abd","xxx"]]])
190
191 OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting],
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
228 OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom],
229 [[parse-atoms '["integer"]' '[0.5]' ]],
230 [syntax "0.5": syntax error: expected integer])
231
232 dnl <C0> is not allowed anywhere in a UTF-8 string.
233 dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
234 OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings],
235 [parse-atoms '[["string"]]' \
236 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
237 '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \
238 ],
239 [constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
240 constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])
241
242 dnl Python won't let invalid UTF-8 (its idea of invalid UTF-8, anyway) into it
243 dnl at all, so this test never gets as far as a constraint violation. It's
244 dnl just a JSON parse error.
245 dnl
246 dnl <C0> is not allowed anywhere in a UTF-8 string.
247 dnl (<ED A0 80> is not allowed in UTF-8 but Python doesn't care.)
248 dnl <ED 80 7F> is not allowed in UTF-8.
249 OVSDB_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"])
256
257 OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
258 [[parse-atom-strings '["integer"]' '0.5' ]],
259 ["0.5" is not a valid integer])
260
261 OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
262 [[parse-atoms '["boolean"]' '["true"]' ]],
263 [syntax ""true"": syntax error: expected boolean])
264
265 OVSDB_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
269 OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
270 [[parse-atoms '["string"]' '[1]']],
271 [syntax "1": syntax error: expected string])
272
273 OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
274 [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
275 [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
276
277 OVSDB_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>]]])
280
281 OVSDB_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
285 OVSDB_CHECK_NEGATIVE([quotes must be balanced],
286 [parse-atom-strings '[["string"]]' '"asdf'],
287 ["asdf: missing quote at end of quoted string])
288
289 OVSDB_CHECK_NEGATIVE([quoted string must not contain unescaped quote],
290 [parse-atom-strings '[["string"]]' '"as"df"'],
291 ["as"df": quoted string may not include unescaped "])
292
293 OVSDB_CHECK_NEGATIVE([quoted string must not end with backslash],
294 [parse-atom-strings '[["string"]]' '"asdf\"'],
295 ["asdf\": quoted string may not end with backslash])
296
297 OVSDB_CHECK_NEGATIVE([uuids must be valid],
298 [parse-atom-strings '[["uuid"]]' '1234-5678'],
299 ["1234-5678" is not a valid UUID])
300 \f
301 AT_BANNER([OVSDB -- atoms with enum constraints])
302
303 OVSDB_CHECK_POSITIVE_CPY([integer atom enum],
304 [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
305 '[0]' \
306 '[1]' \
307 '[2]' \
308 '[3]' \
309 '[6]' \
310 '[7]' \
311 '[8]' \
312 '[9]' \
313 '[10]' \
314 '[11]']],
315 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
316 1
317 constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
318 constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
319 6
320 constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
321 8
322 constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
323 10
324 constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
325
326 OVSDB_CHECK_POSITIVE_CPY([real atom enum],
327 [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
328 '[-2]' \
329 '[-1]' \
330 '[-1.5]' \
331 '[0]' \
332 '[1]' \
333 '[1.5]' \
334 '[2]']],
335 [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
336 constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
337 -1.5
338 constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
339 constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
340 1.5
341 constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
342
343 OVSDB_CHECK_POSITIVE_CPY([boolean atom enum],
344 [[parse-atoms '[{"type": "boolean", "enum": false}]' \
345 '[false]' \
346 '[true]']],
347 [[false
348 constraint violation: true is not one of the allowed values ([false])]])
349
350 OVSDB_CHECK_POSITIVE_CPY([string atom enum],
351 [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
352 '[""]' \
353 '["ab"]' \
354 '["abc"]' \
355 '["def"]' \
356 '["defg"]' \
357 '["DEF"]']],
358 [[constraint violation: "" is not one of the allowed values ([abc, def])
359 constraint violation: ab is not one of the allowed values ([abc, def])
360 "abc"
361 "def"
362 constraint violation: defg is not one of the allowed values ([abc, def])
363 constraint violation: DEF is not one of the allowed values ([abc, def])]])
364
365 OVSDB_CHECK_POSITIVE_CPY([uuid atom enum],
366 [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
367 '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
368 '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
369 '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']],
370 [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
371 ["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
372 constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])
373 \f
374 AT_BANNER([OVSDB -- atoms with other constraints])
375
376 OVSDB_CHECK_POSITIVE_CPY([integers >= 5],
377 [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
378 '[0]' \
379 '[4]' \
380 '[5]' \
381 '[6]' \
382 '[12345]']],
383 [constraint violation: 0 is less than minimum allowed value 5
384 constraint violation: 4 is less than minimum allowed value 5
385 5
386 6
387 12345])
388
389 OVSDB_CHECK_POSITIVE_CPY([integers <= -1],
390 [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
391 '[0]' \
392 '[-1]' \
393 '[-2]' \
394 '[-123]']],
395 [constraint violation: 0 is greater than maximum allowed value -1
396 -1
397 -2
398 -123])
399
400 OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10],
401 [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
402 '[-20]' \
403 '[-11]' \
404 '[-10]' \
405 '[-9]' \
406 '[1]' \
407 '[9]' \
408 '[10]' \
409 '[11]' \
410 '[123576]']],
411 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
412 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
413 -10
414 -9
415 1
416 9
417 10
418 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
419 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
420
421 OVSDB_CHECK_POSITIVE_CPY([reals >= 5],
422 [[parse-atoms '[{"type": "real", "minReal": 5}]' \
423 '[0]' \
424 '[4]' \
425 '[5]' \
426 '[6]' \
427 '[12345]']],
428 [constraint violation: 0 is less than minimum allowed value 5
429 constraint violation: 4 is less than minimum allowed value 5
430 5
431 6
432 12345])
433
434 OVSDB_CHECK_POSITIVE_CPY([reals <= -1],
435 [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
436 '[0]' \
437 '[-1]' \
438 '[-2]' \
439 '[-123]']],
440 [constraint violation: 0 is greater than maximum allowed value -1
441 -1
442 -2
443 -123])
444
445 OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10],
446 [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
447 '[-20]' \
448 '[-11]' \
449 '[-10]' \
450 '[-9]' \
451 '[1]' \
452 '[9]' \
453 '[10]' \
454 '[11]' \
455 '[123576]']],
456 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
457 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
458 -10
459 -9
460 1
461 9
462 10
463 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
464 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
465
466 OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
467 [[parse-atoms '{"type": "string", "minLength": 2}' \
468 '[""]' \
469 '["a"]' \
470 '["ab"]' \
471 '["abc"]' \
472 '["\ud834\udd1e"]']],
473 [[constraint violation: "" length 0 is less than minimum allowed length 2
474 constraint violation: "a" length 1 is less than minimum allowed length 2
475 "ab"
476 "abc"
477 constraint violation: "𝄞" length 1 is less than minimum allowed length 2]],
478 [],
479 [],
480 [dnl This test requires a wide build of Python.
481 AT_CHECK([$PYTHON -c 'unichr(0x10000)' || exit 77],
482 [0], [ignore], [ignore])])
483
484 OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
485 [[parse-atoms '{"type": "string", "maxLength": 2}' \
486 '[""]' \
487 '["a"]' \
488 '["ab"]' \
489 '["abc"]' \
490 '["de"]']],
491 [[""
492 "a"
493 "ab"
494 constraint violation: "abc" length 3 is greater than maximum allowed length 2
495 "de"]])
496
497 AT_BANNER([OSVDB -- simple data])
498
499 OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
500 [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
501 [0
502 1
503 -1])
504
505 OVSDB_CHECK_POSITIVE([integer string datum],
506 [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
507 [0
508 1
509 -1
510 1])
511
512 OVSDB_CHECK_POSITIVE_CPY([real JSON datum],
513 [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
514 [0
515 1
516 -1.25])
517
518 OVSDB_CHECK_POSITIVE([real string datum],
519 [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
520 [0
521 1
522 -1.25])
523
524 OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
525 [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
526 [true
527 false])
528
529 OVSDB_CHECK_POSITIVE([boolean string datum],
530 [[parse-data-strings '["boolean"]' 'true' 'false' ]],
531 [true
532 false])
533
534 OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
535 [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
536 [""
537 "true"
538 "\"\\/\b\f\n\r\t"])
539
540 OVSDB_CHECK_POSITIVE([string string datum],
541 [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
542 [x
543 ""
544 "true"
545 "\"\\/\b\f\n\r\t"])
546 \f
547 AT_BANNER([OVSDB -- set data])
548
549 OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
550 [[parse-data '{"key": "boolean", "min": 0}' \
551 '[true]' \
552 '["set", [false]]' \
553 '["set", []]']],
554 [[true
555 false
556 ["set",[]]]],
557 [set])
558
559 OVSDB_CHECK_POSITIVE([string optional boolean],
560 [[parse-data-strings '{"key": "boolean", "min": 0}' \
561 'true' \
562 'false' \
563 '[]']],
564 [[true
565 false
566 []]],
567 [set])
568
569 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
570 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
571 '["set", [0]]' \
572 '[1]' \
573 '["set", [0, 1]]' \
574 '["set", [0, 1, 2]]' \
575 '["set", [0, 1, 2, 3, 4, 5]]' \
576 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
577 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
578 [[0
579 1
580 ["set",[0,1]]
581 ["set",[0,1,2]]
582 ["set",[0,1,2,3,4,5]]
583 ["set",[0,1,2,3,4,5,6,7,8]]
584 ["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
585
586 OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
587 [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
588 '0' \
589 '0,1' \
590 '0, 1, 2' \
591 '[0, 1,2, 3, 4, 5]' \
592 '0, 1,2, 3,4, 5, 6, 7, 8' \
593 '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']],
594 [[[0]
595 [0, 1]
596 [0, 1, 2]
597 [0, 1, 2, 3, 4, 5]
598 [0, 1, 2, 3, 4, 5, 6, 7, 8]
599 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
600
601 OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
602 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
603 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
604 '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
605 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
606 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
607 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
608 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
609 ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
610 ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
611
612 OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
613 [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
614 '[550e8400-e29b-41d4-a716-446655440000]' \
615 '[c5051240-30ff-43ed-b4b9-93cf3f050813,
616 90558331-09af-4d2f-a572-509cad2e9088,
617 550e8400-e29b-41d4-a716-446655440000]']],
618 [[[550e8400-e29b-41d4-a716-446655440000]
619 [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
620
621 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
622 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
623 '["set", []]' \
624 '["a longer string"]' \
625 '["set", ["a relatively long string"]]' \
626 '["set", ["short string", "a relatively long string"]]' \
627 '["set", ["zzz", "short string", "a relatively long string"]]']],
628 [[["set",[]]
629 "a longer string"
630 "a relatively long string"
631 ["set",["a relatively long string","short string"]]
632 ["set",["a relatively long string","short string","zzz"]]]])
633
634 OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
635 [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
636 '[]' \
637 '"a relatively long string"' \
638 '["short string", "a relatively long string"]' \
639 '"zzz","short string","a relatively long string"']],
640 [[[]
641 ["a relatively long string"]
642 ["a relatively long string", "short string"]
643 ["a relatively long string", "short string", zzz]]])
644
645 OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
646 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
647 [ovsdb error: set contains duplicate])
648
649 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
650 [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
651 [set contains duplicate value])
652
653 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
654 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
655 [ovsdb error: set contains duplicate])
656
657 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
658 [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
659 [set contains duplicate value])
660
661 OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
662 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
663 [ovsdb error: set contains duplicate])
664
665 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
666 [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
667 [set contains duplicate value])
668
669 OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
670 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
671 [ovsdb error: set contains duplicate])
672
673 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
674 [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
675 [set contains duplicate value])
676
677 OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
678 [[parse-data '{"key": "uuid", "max": 5}' \
679 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
680 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
681 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
682 [ovsdb error: set contains duplicate])
683
684 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
685 [[parse-data-strings '{"key": "uuid", "max": 5}' \
686 '7ef21525-0088-4a28-a418-5518413e43ea,
687 355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
688 7ef21525-0088-4a28-a418-5518413e43ea']],
689 [set contains duplicate value])
690 \f
691 AT_BANNER([OVSDB -- map data])
692
693 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
694 [[parse-data '{"key": "integer", "value": "boolean"}' \
695 '["map", [[1, true]]]']],
696 [[["map",[[1,true]]]]])
697
698 OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
699 [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
700 '1=true']],
701 [[1=true]])
702
703 OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
704 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
705 '["map", [[1, true]]]' \
706 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
707 '["map", [[3, false], [0, true], [4, false]]]']],
708 [[["map",[[1,true]]]
709 ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
710 ["map",[[0,true],[3,false],[4,false]]]]])
711
712 OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
713 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
714 '1=true' \
715 '0=true 1=false 2=true, 3=true 4=true,' \
716 '3=false,0=true ,4=false']],
717 [[{1=true}
718 {0=true, 1=false, 2=true, 3=true, 4=true}
719 {0=true, 3=false, 4=false}]])
720
721 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
722 [[parse-data '{"key": "boolean", "value": "integer"}' \
723 '["map", [[true, 1]]]']],
724 [[["map",[[true,1]]]]])
725
726 OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
727 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
728 'true=1']],
729 [[true=1]])
730
731 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
732 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
733 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
734 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
735 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
736 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
737 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
738 [[["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]]]]])
739
740 OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
741 [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
742 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
743 6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
744 d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
745 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
746 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
747 [[{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}]])
748
749 OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
750 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
751 '["map", [["2 gills", "1 chopin"],
752 ["2 chopins", "1 pint"],
753 ["2 pints", "1 quart"],
754 ["2 quarts", "1 pottle"],
755 ["2 pottles", "1 gallon"],
756 ["2 gallons", "1 peck"],
757 ["2 pecks", "1 demibushel"],
758 ["2 demibushel", "1 firkin"],
759 ["2 firkins", "1 kilderkin"],
760 ["2 kilderkins", "1 barrel"]]]']],
761 [[["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"]]]]])
762
763 OVSDB_CHECK_POSITIVE([string map of 10 string to string],
764 [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
765 '{"2 gills"="1 chopin",
766 "2 chopins"= "1 pint",
767 "2 pints"= "1 quart",
768 "2 quarts"= "1 pottle",
769 "2 pottles"= "1 gallon",
770 "2 gallons"= "1 peck",
771 "2 pecks"= "1 demibushel",
772 "2 demibushel"= "1 firkin",
773 "2 firkins"= "1 kilderkin",
774 "2 kilderkins"= "1 barrel"}']],
775 [[{"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"}]])
776
777 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
778 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
779 '["map", [[1, true], [2, false], [1, false]]]']],
780 [ovsdb error: map contains duplicate key])
781
782 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
783 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
784 '1=true 2=false 1=false']],
785 [map contains duplicate key])
786
787 OVSDB_CHECK_POSITIVE([generate and apply diff -- integer],
788 [[diff-data '["integer"]' '[0]' '[2]']],
789 [[diff: 2
790 apply diff: 2
791 OK]])
792
793 OVSDB_CHECK_POSITIVE([generate and apply diff -- boolean],
794 [[diff-data '["boolean"]' '[true]' '[false]']],
795 [[diff: false
796 apply diff: false
797 OK]])
798
799 OVSDB_CHECK_POSITIVE([generate and apply diff -- string],
800 [[diff-data '["string"]' '["AAA"]' '["BBB"]']],
801 [[diff: "BBB"
802 apply diff: "BBB"
803 OK]])
804
805 dnl Test set modifications.
806 OVSDB_CHECK_POSITIVE([generate and apply diff -- set],
807 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
808 '["set", [0, 1]]' '["set", [1,2]]' \
809 '["set", [0, 1]]' '["set", [1]]' \
810 '["set", []]' '["set", [0, 1]]' \
811 '["set", [0, 1]]' '["set", []]'
812 ]],
813 [[diff: ["set",[0,2]]
814 apply diff: ["set",[1,2]]
815 OK
816 diff: 0
817 apply diff: 1
818 OK
819 diff: ["set",[0,1]]
820 apply diff: ["set",[0,1]]
821 OK
822 diff: ["set",[0,1]]
823 apply diff: ["set",[]]
824 OK]])
825
826 dnl Test set modifications causes data to violate set size constrain.
827 OVSDB_CHECK_NEGATIVE([generate and apply diff -- set -- size error],
828 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
829 '["set", [0, 1]]' '["set", [1, 2, 3, 4]]']],
830 [[ovsdb error: Datum crated by diff has size error]])
831
832 dnl Test set modifications.
833 OVSDB_CHECK_POSITIVE([generate and apply diff -- map],
834 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
835 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 pints", "1 quart"]]]' \
836 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 chopin"]]]' \
837 '["map", [["2 gills", "1 chopin"]]]' '["map", []]' \
838 '["map", []]' '["map", [["2 pints", "1 quart"]]]' \
839 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 gallon"]]]' \
840 ]],
841 [[diff: ["map",[["2 gills","1 chopin"],["2 pints","1 quart"]]]
842 apply diff: ["map",[["2 pints","1 quart"]]]
843 OK
844 diff: ["map",[]]
845 apply diff: ["map",[["2 gills","1 chopin"]]]
846 OK
847 diff: ["map",[["2 gills","1 chopin"]]]
848 apply diff: ["map",[]]
849 OK
850 diff: ["map",[["2 pints","1 quart"]]]
851 apply diff: ["map",[["2 pints","1 quart"]]]
852 OK
853 diff: ["map",[["2 gills","1 gallon"]]]
854 apply diff: ["map",[["2 gills","1 gallon"]]]
855 OK]])
856
857 OVSDB_CHECK_NEGATIVE([generate and apply diff with map -- size error],
858 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
859 '["map", [["2 gills", "1 chopin"]]]' \
860 '["map", [["2 gills", "1 gallon"],
861 ["2 pints", "1 quart"],
862 ["2 quarts", "1 pottle"],
863 ["2 gallons", "1 peck"]]]' \
864 ]],
865 [[ovsdb error: Datum crated by diff has size error]])