1 AT_BANNER([OVSDB -- default values])
3 OVSDB_CHECK_POSITIVE_CPY([default atoms],
11 OVSDB_CHECK_POSITIVE_CPY([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]])
74 AT_BANNER([OVSDB -- atoms without constraints])
76 OVSDB_CHECK_POSITIVE_CPY([integer atom from JSON],
77 [[parse-atoms '["integer"]' \
81 '[9223372036854775807]' \
82 '[-9223372036854775808]' ]],
87 -9223372036854775808])
89 OVSDB_CHECK_POSITIVE([integer atom from string],
90 [[parse-atom-strings -- '["integer"]' \
94 '9223372036854775807' \
95 '-9223372036854775808' \
116 OVSDB_CHECK_POSITIVE_CPY([real atom from JSON],
117 [[parse-atoms '["real"]' \
133 OVSDB_CHECK_POSITIVE([real atom from string],
134 [[parse-atom-strings -- '["real"]' \
150 OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
151 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
155 OVSDB_CHECK_POSITIVE([boolean atom from string],
156 [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
160 OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
161 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
166 OVSDB_CHECK_POSITIVE([string atom from string],
167 [[parse-atom-strings '["string"]' \
173 '"\"\\\/\b\f\n\r\t"']],
181 OVSDB_CHECK_POSITIVE_CPY([uuid atom from JSON],
182 [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
183 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
185 OVSDB_CHECK_POSITIVE([uuid atom from string],
186 [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
187 [550e8400-e29b-41d4-a716-446655440000])
189 OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
190 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
193 OVSDB_CHECK_POSITIVE_CPY([real atom sorting],
194 [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
195 [[[-1e+99,0,0,1.23,1.25]]])
197 OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
198 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
199 [[[false,false,false,true,true]]])
201 OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
202 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
203 [[["\b","abc","abd","xxx"]]])
205 OVSDB_CHECK_POSITIVE_CPY([uuid atom sorting],
206 [[sort-atoms '["uuid"]' '[
207 ["uuid", "00000000-0000-0000-0000-000000000001"],
208 ["uuid", "00000000-1000-0000-0000-000000000000"],
209 ["uuid", "00000000-0000-1000-0000-000000000000"],
210 ["uuid", "00010000-0000-0000-0000-000000000000"],
211 ["uuid", "00000000-0000-0000-0000-000000000100"],
212 ["uuid", "00000000-0000-0000-0000-000100000000"],
213 ["uuid", "00000000-0000-0010-0000-000000000000"],
214 ["uuid", "00000100-0000-0000-0000-000000000000"],
215 ["uuid", "00000000-0000-0001-0000-000000000000"],
216 ["uuid", "00000000-0000-0000-0000-000001000000"],
217 ["uuid", "01000000-0000-0000-0000-000000000000"],
218 ["uuid", "00000000-0000-0000-0000-000000001000"],
219 ["uuid", "00000000-0000-0000-0000-000010000000"],
220 ["uuid", "00000000-0000-0000-0000-010000000000"],
221 ["uuid", "00000000-0000-0100-0000-000000000000"],
222 ["uuid", "10000000-0000-0000-0000-000000000000"],
223 ["uuid", "00000000-0000-0000-0000-000000000010"],
224 ["uuid", "00000000-0100-0000-0000-000000000000"],
225 ["uuid", "00000000-0000-0000-0100-000000000000"],
226 ["uuid", "00000000-0000-0000-0001-000000000000"],
227 ["uuid", "00000010-0000-0000-0000-000000000000"],
228 ["uuid", "00000000-0000-0000-0010-000000000000"],
229 ["uuid", "00000000-0000-0000-0000-000000010000"],
230 ["uuid", "00000000-0000-0000-1000-000000000000"],
231 ["uuid", "00000000-0000-0000-0000-100000000000"],
232 ["uuid", "00000000-0000-0000-0000-001000000000"],
233 ["uuid", "00000000-0000-0000-0000-000000100000"],
234 ["uuid", "00000000-0000-0000-0000-000000000000"],
235 ["uuid", "00000000-0010-0000-0000-000000000000"],
236 ["uuid", "00100000-0000-0000-0000-000000000000"],
237 ["uuid", "00000000-0001-0000-0000-000000000000"],
238 ["uuid", "00000001-0000-0000-0000-000000000000"],
239 ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
240 [[[["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"]]]])
242 OVSDB_CHECK_POSITIVE_CPY([real not acceptable integer JSON atom],
243 [[parse-atoms '["integer"]' '[0.5]' ]],
244 [syntax "0.5": syntax error: expected integer])
246 dnl <C0> is not allowed anywhere in a UTF-8 string.
247 dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
248 OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings],
249 [parse-atoms '[["string"]]' \
250 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
251 '@<:@"m4_esyscmd([printf "\355\240\200"])"@:>@' \
253 [constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
254 constraint violation: not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])
256 dnl Python won't let invalid UTF-8 (its idea of invalid UTF-8, anyway) into it
257 dnl at all, so this test never gets as far as a constraint violation. It's
258 dnl just a JSON parse error.
260 dnl <C0> is not allowed anywhere in a UTF-8 string.
261 dnl (<ED A0 80> is not allowed in UTF-8 but Python doesn't care.)
262 dnl <ED 80 7F> is not allowed in UTF-8.
263 OVSDB_CHECK_POSITIVE_PY([no invalid UTF-8 sequences in strings - Python],
264 [parse-atoms '[["string"]]' \
265 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
266 '@<:@"m4_esyscmd([printf "\355\200\177"])"@:>@' \
268 ["not a valid UTF-8 string: invalid UTF-8 sequence 0xc0"
269 "not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0x80"])
271 OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
272 [[parse-atom-strings '["integer"]' '0.5' ]],
273 ["0.5" is not a valid integer])
275 OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom positive and negative],
276 [[parse-atom-strings -- '["integer"]' '10--10' ]],
277 ["10--10" is not a valid range. Range end cannot be before start.])
279 OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom negative],
280 [[parse-atom-strings -- '["integer"]' '-10--100' ]],
281 ["-10--100" is not a valid range. Range end cannot be before start.])
283 OVSDB_CHECK_NEGATIVE([inverted range is not acceptable integer string atom positive],
284 [[parse-atom-strings -- '["integer"]' '100-10' ]],
285 ["100-10" is not a valid range. Range end cannot be before start.])
287 OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom positive and negative],
288 [[parse-atom-strings -- '["integer"]' '-2000-2096' ]],
289 [Range "-2000-2096" is too big.])
291 OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom negative],
292 [[parse-atom-strings -- '["integer"]' '-4097--1' ]],
293 [Range "-4097--1" is too big.])
295 OVSDB_CHECK_NEGATIVE([too big range is not acceptable integer string atom positive],
296 [[parse-atom-strings -- '["integer"]' '1-4097' ]],
297 [Range "1-4097" is too big.])
299 OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
300 [[parse-atoms '["boolean"]' '["true"]' ]],
301 [syntax ""true"": syntax error: expected boolean])
303 OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean string atom],
304 [[parse-atom-strings '["boolean"]' '"true"' ]],
305 [""true"" is not a valid boolean (use "true" or "false")])
307 OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
308 [[parse-atoms '["string"]' '[1]']],
309 [syntax "1": syntax error: expected string])
311 OVSDB_CHECK_POSITIVE_CPY([uuid atom must be expressed as JSON array],
312 [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
313 [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
315 OVSDB_CHECK_POSITIVE_CPY([named-uuid requires symbol table],
316 [parse-atoms '[["uuid"]]' '[["named-uuid", "x"]]'],
317 [[syntax "["named-uuid","x"]": syntax error: expected ["uuid", <string>]]])
319 OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
320 [[parse-atom-strings '["string"]' '']],
321 [An empty string is not valid as input; use "" to represent the empty string])
323 OVSDB_CHECK_NEGATIVE([quotes must be balanced],
324 [parse-atom-strings '[["string"]]' '"asdf'],
325 ["asdf: missing quote at end of quoted string])
327 OVSDB_CHECK_NEGATIVE([quoted string must not contain unescaped quote],
328 [parse-atom-strings '[["string"]]' '"as"df"'],
329 ["as"df": quoted string may not include unescaped "])
331 OVSDB_CHECK_NEGATIVE([quoted string must not end with backslash],
332 [parse-atom-strings '[["string"]]' '"asdf\"'],
333 ["asdf\": quoted string may not end with backslash])
335 OVSDB_CHECK_NEGATIVE([uuids must be valid],
336 [parse-atom-strings '[["uuid"]]' '1234-5678'],
337 ["1234-5678" is not a valid UUID])
339 AT_BANNER([OVSDB -- atoms with enum constraints])
341 OVSDB_CHECK_POSITIVE_CPY([integer atom enum],
342 [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
353 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
355 constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
356 constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
358 constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
360 constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
362 constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
364 OVSDB_CHECK_POSITIVE([integer atom enum from string],
365 [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10, 20, 21, 22, 23, 24, 25]]}]' \
377 OVSDB_CHECK_NEGATIVE([integer not in enum set from string],
378 [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' '0' ]],
379 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])]])
381 OVSDB_CHECK_NEGATIVE([integer range not in enum set from string],
382 [[parse-atom-strings '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' '8-10' ]],
383 [[constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])]])
385 OVSDB_CHECK_POSITIVE_CPY([real atom enum],
386 [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
394 [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
395 constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
397 constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
398 constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
400 constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
402 OVSDB_CHECK_POSITIVE_CPY([boolean atom enum],
403 [[parse-atoms '[{"type": "boolean", "enum": false}]' \
407 constraint violation: true is not one of the allowed values ([false])]])
409 OVSDB_CHECK_POSITIVE_CPY([string atom enum],
410 [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
417 [[constraint violation: "" is not one of the allowed values ([abc, def])
418 constraint violation: ab is not one of the allowed values ([abc, def])
421 constraint violation: defg is not one of the allowed values ([abc, def])
422 constraint violation: DEF is not one of the allowed values ([abc, def])]])
424 OVSDB_CHECK_POSITIVE_CPY([uuid atom enum],
425 [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
426 '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
427 '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
428 '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']],
429 [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
430 ["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
431 constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])
433 AT_BANNER([OVSDB -- atoms with other constraints])
435 OVSDB_CHECK_POSITIVE_CPY([integers >= 5],
436 [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
442 [constraint violation: 0 is less than minimum allowed value 5
443 constraint violation: 4 is less than minimum allowed value 5
448 OVSDB_CHECK_POSITIVE_CPY([integers <= -1],
449 [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
454 [constraint violation: 0 is greater than maximum allowed value -1
459 OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10],
460 [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
470 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
471 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
477 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
478 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
480 OVSDB_CHECK_POSITIVE_CPY([reals >= 5],
481 [[parse-atoms '[{"type": "real", "minReal": 5}]' \
487 [constraint violation: 0 is less than minimum allowed value 5
488 constraint violation: 4 is less than minimum allowed value 5
493 OVSDB_CHECK_POSITIVE_CPY([reals <= -1],
494 [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
499 [constraint violation: 0 is greater than maximum allowed value -1
504 OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10],
505 [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
515 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
516 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
522 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
523 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
525 OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
526 [[parse-atoms '{"type": "string", "minLength": 2}' \
531 '["\ud834\udd1e"]']],
532 [[constraint violation: "" length 0 is less than minimum allowed length 2
533 constraint violation: "a" length 1 is less than minimum allowed length 2
536 constraint violation: "𝄞" length 1 is less than minimum allowed length 2]],
539 [dnl This test requires a wide build of Python.
540 AT_CHECK([$PYTHON -c 'unichr(0x10000)' || exit 77],
541 [0], [ignore], [ignore])])
543 OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
544 [[parse-atoms '{"type": "string", "maxLength": 2}' \
553 constraint violation: "abc" length 3 is greater than maximum allowed length 2
556 AT_BANNER([OVSDB -- simple data])
558 OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
559 [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
564 OVSDB_CHECK_POSITIVE([integer string datum],
565 [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
571 OVSDB_CHECK_POSITIVE_CPY([real JSON datum],
572 [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
577 OVSDB_CHECK_POSITIVE([real string datum],
578 [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
583 OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
584 [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
588 OVSDB_CHECK_POSITIVE([boolean string datum],
589 [[parse-data-strings '["boolean"]' 'true' 'false' ]],
593 OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
594 [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
599 OVSDB_CHECK_POSITIVE([string string datum],
600 [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
606 AT_BANNER([OVSDB -- set data])
608 OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
609 [[parse-data '{"key": "boolean", "min": 0}' \
618 OVSDB_CHECK_POSITIVE([string optional boolean],
619 [[parse-data-strings '{"key": "boolean", "min": 0}' \
628 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
629 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
633 '["set", [0, 1, 2]]' \
634 '["set", [0, 1, 2, 3, 4, 5]]' \
635 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
636 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
641 ["set",[0,1,2,3,4,5]]
642 ["set",[0,1,2,3,4,5,6,7,8]]
643 ["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
645 OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
646 [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
650 '[0, 1,2, 3, 4, 5]' \
651 '0, 1,2, 3,4, 5, 6, 7, 8' \
652 '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]' \
659 [0, 1, 2, 3, 4, 5, 6, 7, 8]
660 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
661 [0, 1, 2, 3, 4, 5, 6, 7, 8]
662 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
664 OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
665 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
666 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
667 '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
668 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
669 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
670 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
671 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
672 ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
673 ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
675 OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
676 [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
677 '[550e8400-e29b-41d4-a716-446655440000]' \
678 '[c5051240-30ff-43ed-b4b9-93cf3f050813,
679 90558331-09af-4d2f-a572-509cad2e9088,
680 550e8400-e29b-41d4-a716-446655440000]']],
681 [[[550e8400-e29b-41d4-a716-446655440000]
682 [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
684 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
685 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
687 '["a longer string"]' \
688 '["set", ["a relatively long string"]]' \
689 '["set", ["short string", "a relatively long string"]]' \
690 '["set", ["zzz", "short string", "a relatively long string"]]']],
693 "a relatively long string"
694 ["set",["a relatively long string","short string"]]
695 ["set",["a relatively long string","short string","zzz"]]]])
697 OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
698 [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
700 '"a relatively long string"' \
701 '["short string", "a relatively long string"]' \
702 '"zzz","short string","a relatively long string"']],
704 ["a relatively long string"]
705 ["a relatively long string", "short string"]
706 ["a relatively long string", "short string", zzz]]])
708 OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
709 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
710 [ovsdb error: set contains duplicate])
712 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
713 [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
714 [set contains duplicate value])
716 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
717 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
718 [ovsdb error: set contains duplicate])
720 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
721 [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
722 [set contains duplicate value])
724 OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
725 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
726 [ovsdb error: set contains duplicate])
728 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
729 [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
730 [set contains duplicate value])
732 OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
733 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
734 [ovsdb error: set contains duplicate])
736 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
737 [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
738 [set contains duplicate value])
740 OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
741 [[parse-data '{"key": "uuid", "max": 5}' \
742 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
743 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
744 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
745 [ovsdb error: set contains duplicate])
747 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
748 [[parse-data-strings '{"key": "uuid", "max": 5}' \
749 '7ef21525-0088-4a28-a418-5518413e43ea,
750 355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
751 7ef21525-0088-4a28-a418-5518413e43ea']],
752 [set contains duplicate value])
754 AT_BANNER([OVSDB -- map data])
756 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
757 [[parse-data '{"key": "integer", "value": "boolean"}' \
758 '["map", [[1, true]]]']],
759 [[["map",[[1,true]]]]])
761 OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
762 [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
766 OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
767 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
768 '["map", [[1, true]]]' \
769 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
770 '["map", [[3, false], [0, true], [4, false]]]']],
772 ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
773 ["map",[[0,true],[3,false],[4,false]]]]])
775 OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
776 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
778 '0=true 1=false 2=true, 3=true 4=true,' \
779 '3=false,0=true ,4=false']],
781 {0=true, 1=false, 2=true, 3=true, 4=true}
782 {0=true, 3=false, 4=false}]])
784 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
785 [[parse-data '{"key": "boolean", "value": "integer"}' \
786 '["map", [[true, 1]]]']],
787 [[["map",[[true,1]]]]])
789 OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
790 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
794 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
795 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
796 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
797 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
798 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
799 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
800 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
801 [[["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]]]]])
803 OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
804 [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
805 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
806 6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
807 d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
808 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
809 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
810 [[{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}]])
812 OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
813 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
814 '["map", [["2 gills", "1 chopin"],
815 ["2 chopins", "1 pint"],
816 ["2 pints", "1 quart"],
817 ["2 quarts", "1 pottle"],
818 ["2 pottles", "1 gallon"],
819 ["2 gallons", "1 peck"],
820 ["2 pecks", "1 demibushel"],
821 ["2 demibushel", "1 firkin"],
822 ["2 firkins", "1 kilderkin"],
823 ["2 kilderkins", "1 barrel"]]]']],
824 [[["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"]]]]])
826 OVSDB_CHECK_POSITIVE([string map of 10 string to string],
827 [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
828 '{"2 gills"="1 chopin",
829 "2 chopins"= "1 pint",
830 "2 pints"= "1 quart",
831 "2 quarts"= "1 pottle",
832 "2 pottles"= "1 gallon",
833 "2 gallons"= "1 peck",
834 "2 pecks"= "1 demibushel",
835 "2 demibushel"= "1 firkin",
836 "2 firkins"= "1 kilderkin",
837 "2 kilderkins"= "1 barrel"}']],
838 [[{"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"}]])
840 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
841 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
842 '["map", [[1, true], [2, false], [1, false]]]']],
843 [ovsdb error: map contains duplicate key])
845 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
846 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
847 '1=true 2=false 1=false']],
848 [map contains duplicate key])
850 OVSDB_CHECK_POSITIVE([generate and apply diff -- integer],
851 [[diff-data '["integer"]' '[0]' '[2]']],
856 OVSDB_CHECK_POSITIVE([generate and apply diff -- boolean],
857 [[diff-data '["boolean"]' '[true]' '[false]']],
862 OVSDB_CHECK_POSITIVE([generate and apply diff -- string],
863 [[diff-data '["string"]' '["AAA"]' '["BBB"]']],
868 dnl Test set modifications.
869 OVSDB_CHECK_POSITIVE([generate and apply diff -- set],
870 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
871 '["set", [0, 1]]' '["set", [1,2]]' \
872 '["set", [0, 1]]' '["set", [1]]' \
873 '["set", []]' '["set", [0, 1]]' \
874 '["set", [0, 1]]' '["set", []]'
876 [[diff: ["set",[0,2]]
877 apply diff: ["set",[1,2]]
883 apply diff: ["set",[0,1]]
886 apply diff: ["set",[]]
889 dnl Test set modifications causes data to violate set size constrain.
890 OVSDB_CHECK_NEGATIVE([generate and apply diff -- set -- size error],
891 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
892 '["set", [0, 1]]' '["set", [1, 2, 3, 4]]']],
893 [[ovsdb error: Datum crated by diff has size error]])
895 dnl Test set modifications.
896 OVSDB_CHECK_POSITIVE([generate and apply diff -- map],
897 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
898 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 pints", "1 quart"]]]' \
899 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 chopin"]]]' \
900 '["map", [["2 gills", "1 chopin"]]]' '["map", []]' \
901 '["map", []]' '["map", [["2 pints", "1 quart"]]]' \
902 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 gallon"]]]' \
904 [[diff: ["map",[["2 gills","1 chopin"],["2 pints","1 quart"]]]
905 apply diff: ["map",[["2 pints","1 quart"]]]
908 apply diff: ["map",[["2 gills","1 chopin"]]]
910 diff: ["map",[["2 gills","1 chopin"]]]
911 apply diff: ["map",[]]
913 diff: ["map",[["2 pints","1 quart"]]]
914 apply diff: ["map",[["2 pints","1 quart"]]]
916 diff: ["map",[["2 gills","1 gallon"]]]
917 apply diff: ["map",[["2 gills","1 gallon"]]]
920 OVSDB_CHECK_NEGATIVE([generate and apply diff with map -- size error],
921 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
922 '["map", [["2 gills", "1 chopin"]]]' \
923 '["map", [["2 gills", "1 gallon"],
924 ["2 pints", "1 quart"],
925 ["2 quarts", "1 pottle"],
926 ["2 gallons", "1 peck"]]]' \
928 [[ovsdb error: Datum crated by diff has size error]])