]> git.proxmox.com Git - mirror_ovs.git/blob - tests/ovsdb-data.at
oss-fuzz: Fix miniflow_target.c.
[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-1000' \
97 '-1000-+1000' \
98 '-1000--10' \
99 '+10-+1000' \
100 '1-4096' \
101 '-4096--1' \
102 '-2000-2095']],
103 [0
104 -1
105 1000
106 9223372036854775807
107 -9223372036854775808
108 0-1000
109 -1000-1000
110 -1000--10
111 10-1000
112 1-4096
113 -4096--1
114 -2000-2095])
115
116 OVSDB_CHECK_POSITIVE_CPY([real atom from JSON],
117 [[parse-atoms '["real"]' \
118 '[0]' \
119 '[0.0]' \
120 '[-0.0]' \
121 '[-1.25]' \
122 '[1e3]' \
123 '[1e37]' \
124 '[0.00390625]' ]],
125 [0
126 0
127 0
128 -1.25
129 1000
130 1e+37
131 0.00390625])
132
133 OVSDB_CHECK_POSITIVE([real atom from string],
134 [[parse-atom-strings -- '["real"]' \
135 '0' \
136 '0.0' \
137 '-0.0' \
138 '-1.25' \
139 '1e3' \
140 '1e37' \
141 '0.00390625' ]],
142 [0
143 0
144 0
145 -1.25
146 1000
147 1e+37
148 0.00390625])
149
150 OVSDB_CHECK_POSITIVE_CPY([boolean atom from JSON],
151 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
152 [true
153 false])
154
155 OVSDB_CHECK_POSITIVE([boolean atom from string],
156 [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
157 [true
158 false])
159
160 OVSDB_CHECK_POSITIVE_CPY([string atom from JSON],
161 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
162 [""
163 "true"
164 "\"\\/\b\f\n\r\t"])
165
166 OVSDB_CHECK_POSITIVE([string atom from string],
167 [[parse-atom-strings '["string"]' \
168 'unquoted' \
169 '"quoted-string"' \
170 '"needs quotes"' \
171 '""' \
172 '"true"' \
173 '"\"\\\/\b\f\n\r\t"']],
174 [unquoted
175 quoted-string
176 "needs quotes"
177 ""
178 "true"
179 "\"\\/\b\f\n\r\t"])
180
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"]]])
184
185 OVSDB_CHECK_POSITIVE([uuid atom from string],
186 [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
187 [550e8400-e29b-41d4-a716-446655440000])
188
189 OVSDB_CHECK_POSITIVE_CPY([integer atom sorting],
190 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
191 [[[-1,0,1,2,55]]])
192
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]]])
196
197 OVSDB_CHECK_POSITIVE_CPY([boolean atom sorting],
198 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
199 [[[false,false,false,true,true]]])
200
201 OVSDB_CHECK_POSITIVE_CPY([string atom sorting],
202 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
203 [[["\b","abc","abd","xxx"]]])
204
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"]]]])
241
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])
245
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"])"@:>@' \
252 ],
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])
255
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.
259 dnl
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_PY3([no invalid UTF-8 sequences in strings - Python],
264 [parse-atoms '[["string"]]' \
265 '@<:@"m4_esyscmd([printf "\300"])"@:>@' \
266 '@<:@"m4_esyscmd([printf "\355\200\177"])"@:>@' \
267 ],
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"])
270
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])
274
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.])
278
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.])
282
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.])
286
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.])
290
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.])
294
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.])
298
299 OVSDB_CHECK_POSITIVE_CPY([string "true" not acceptable boolean JSON atom],
300 [[parse-atoms '["boolean"]' '["true"]' ]],
301 [syntax ""true"": syntax error: expected boolean])
302
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")])
306
307 OVSDB_CHECK_POSITIVE_CPY([integer not acceptable string JSON atom],
308 [[parse-atoms '["string"]' '[1]']],
309 [syntax "1": syntax error: expected string])
310
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>]]])
314
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>]]])
318
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])
322
323 OVSDB_CHECK_NEGATIVE([quotes must be balanced],
324 [parse-atom-strings '[["string"]]' '"asdf'],
325 ["asdf: missing quote at end of quoted string])
326
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 "])
330
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])
334
335 OVSDB_CHECK_NEGATIVE([uuids must be valid],
336 [parse-atom-strings '[["uuid"]]' '1234-5678'],
337 ["1234-5678" is not a valid UUID])
338 \f
339 AT_BANNER([OVSDB -- atoms with enum constraints])
340
341 OVSDB_CHECK_POSITIVE_CPY([integer atom enum],
342 [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
343 '[0]' \
344 '[1]' \
345 '[2]' \
346 '[3]' \
347 '[6]' \
348 '[7]' \
349 '[8]' \
350 '[9]' \
351 '[10]' \
352 '[11]']],
353 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
354 1
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])
357 6
358 constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
359 8
360 constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
361 10
362 constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
363
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]]}]' \
366 '1' \
367 '6' \
368 '8' \
369 '10' \
370 '20-25']],
371 [[1
372 6
373 8
374 10
375 20-25]])
376
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])]])
380
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])]])
384
385 OVSDB_CHECK_POSITIVE_CPY([real atom enum],
386 [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
387 '[-2]' \
388 '[-1]' \
389 '[-1.5]' \
390 '[0]' \
391 '[1]' \
392 '[1.5]' \
393 '[2]']],
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])
396 -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])
399 1.5
400 constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
401
402 OVSDB_CHECK_POSITIVE_CPY([boolean atom enum],
403 [[parse-atoms '[{"type": "boolean", "enum": false}]' \
404 '[false]' \
405 '[true]']],
406 [[false
407 constraint violation: true is not one of the allowed values ([false])]])
408
409 OVSDB_CHECK_POSITIVE_CPY([string atom enum],
410 [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
411 '[""]' \
412 '["ab"]' \
413 '["abc"]' \
414 '["def"]' \
415 '["defg"]' \
416 '["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])
419 "abc"
420 "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])]])
423
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])]])
432 \f
433 AT_BANNER([OVSDB -- atoms with other constraints])
434
435 OVSDB_CHECK_POSITIVE_CPY([integers >= 5],
436 [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
437 '[0]' \
438 '[4]' \
439 '[5]' \
440 '[6]' \
441 '[12345]']],
442 [constraint violation: 0 is less than minimum allowed value 5
443 constraint violation: 4 is less than minimum allowed value 5
444 5
445 6
446 12345])
447
448 OVSDB_CHECK_POSITIVE_CPY([integers <= -1],
449 [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
450 '[0]' \
451 '[-1]' \
452 '[-2]' \
453 '[-123]']],
454 [constraint violation: 0 is greater than maximum allowed value -1
455 -1
456 -2
457 -123])
458
459 OVSDB_CHECK_POSITIVE_CPY([integers in range -10 to 10],
460 [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
461 '[-20]' \
462 '[-11]' \
463 '[-10]' \
464 '[-9]' \
465 '[1]' \
466 '[9]' \
467 '[10]' \
468 '[11]' \
469 '[123576]']],
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)
472 -10
473 -9
474 1
475 9
476 10
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)])
479
480 OVSDB_CHECK_POSITIVE_CPY([reals >= 5],
481 [[parse-atoms '[{"type": "real", "minReal": 5}]' \
482 '[0]' \
483 '[4]' \
484 '[5]' \
485 '[6]' \
486 '[12345]']],
487 [constraint violation: 0 is less than minimum allowed value 5
488 constraint violation: 4 is less than minimum allowed value 5
489 5
490 6
491 12345])
492
493 OVSDB_CHECK_POSITIVE_CPY([reals <= -1],
494 [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
495 '[0]' \
496 '[-1]' \
497 '[-2]' \
498 '[-123]']],
499 [constraint violation: 0 is greater than maximum allowed value -1
500 -1
501 -2
502 -123])
503
504 OVSDB_CHECK_POSITIVE_CPY([reals in range -10 to 10],
505 [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
506 '[-20]' \
507 '[-11]' \
508 '[-10]' \
509 '[-9]' \
510 '[1]' \
511 '[9]' \
512 '[10]' \
513 '[11]' \
514 '[123576]']],
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)
517 -10
518 -9
519 1
520 9
521 10
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)])
524
525 OVSDB_CHECK_POSITIVE_CPY([strings at least 2 characters long],
526 [[parse-atoms '{"type": "string", "minLength": 2}' \
527 '[""]' \
528 '["a"]' \
529 '["ab"]' \
530 '["abc"]' \
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
534 "ab"
535 "abc"
536 constraint violation: "𝄞" length 1 is less than minimum allowed length 2]])
537
538 OVSDB_CHECK_POSITIVE_CPY([strings no more than 2 characters long],
539 [[parse-atoms '{"type": "string", "maxLength": 2}' \
540 '[""]' \
541 '["a"]' \
542 '["ab"]' \
543 '["abc"]' \
544 '["de"]']],
545 [[""
546 "a"
547 "ab"
548 constraint violation: "abc" length 3 is greater than maximum allowed length 2
549 "de"]])
550
551 AT_BANNER([OVSDB -- simple data])
552
553 OVSDB_CHECK_POSITIVE_CPY([integer JSON datum],
554 [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
555 [0
556 1
557 -1])
558
559 OVSDB_CHECK_POSITIVE([integer string datum],
560 [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
561 [0
562 1
563 -1
564 1])
565
566 OVSDB_CHECK_POSITIVE_CPY([real JSON datum],
567 [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
568 [0
569 1
570 -1.25])
571
572 OVSDB_CHECK_POSITIVE([real string datum],
573 [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
574 [0
575 1
576 -1.25])
577
578 OVSDB_CHECK_POSITIVE_CPY([boolean JSON datum],
579 [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
580 [true
581 false])
582
583 OVSDB_CHECK_POSITIVE([boolean string datum],
584 [[parse-data-strings '["boolean"]' 'true' 'false' ]],
585 [true
586 false])
587
588 OVSDB_CHECK_POSITIVE_CPY([string JSON datum],
589 [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
590 [""
591 "true"
592 "\"\\/\b\f\n\r\t"])
593
594 OVSDB_CHECK_POSITIVE([string string datum],
595 [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
596 [x
597 ""
598 "true"
599 "\"\\/\b\f\n\r\t"])
600 \f
601 AT_BANNER([OVSDB -- set data])
602
603 OVSDB_CHECK_POSITIVE_CPY([JSON optional boolean],
604 [[parse-data '{"key": "boolean", "min": 0}' \
605 '[true]' \
606 '["set", [false]]' \
607 '["set", []]']],
608 [[true
609 false
610 ["set",[]]]],
611 [set])
612
613 OVSDB_CHECK_POSITIVE([string optional boolean],
614 [[parse-data-strings '{"key": "boolean", "min": 0}' \
615 'true' \
616 'false' \
617 '[]']],
618 [[true
619 false
620 []]],
621 [set])
622
623 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 or more integers],
624 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
625 '["set", [0]]' \
626 '[1]' \
627 '["set", [0, 1]]' \
628 '["set", [0, 1, 2]]' \
629 '["set", [0, 1, 2, 3, 4, 5]]' \
630 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
631 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
632 [[0
633 1
634 ["set",[0,1]]
635 ["set",[0,1,2]]
636 ["set",[0,1,2,3,4,5]]
637 ["set",[0,1,2,3,4,5,6,7,8]]
638 ["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
639
640 OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
641 [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
642 '0' \
643 '0,1' \
644 '0, 1, 2' \
645 '[0, 1,2, 3, 4, 5]' \
646 '0, 1,2, 3,4, 5, 6, 7, 8' \
647 '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]' \
648 '0-8' \
649 '[0-10']]],
650 [[[0]
651 [0, 1]
652 [0, 1, 2]
653 [0, 1, 2, 3, 4, 5]
654 [0, 1, 2, 3, 4, 5, 6, 7, 8]
655 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
656 [0, 1, 2, 3, 4, 5, 6, 7, 8]
657 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
658
659 OVSDB_CHECK_POSITIVE_CPY([JSON set of 1 to 3 uuids],
660 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
661 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
662 '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
663 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
664 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
665 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
666 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
667 ["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
668 ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
669
670 OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
671 [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
672 '[550e8400-e29b-41d4-a716-446655440000]' \
673 '[c5051240-30ff-43ed-b4b9-93cf3f050813,
674 90558331-09af-4d2f-a572-509cad2e9088,
675 550e8400-e29b-41d4-a716-446655440000]']],
676 [[[550e8400-e29b-41d4-a716-446655440000]
677 [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
678
679 OVSDB_CHECK_POSITIVE_CPY([JSON set of 0 to 3 strings],
680 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
681 '["set", []]' \
682 '["a longer string"]' \
683 '["set", ["a relatively long string"]]' \
684 '["set", ["short string", "a relatively long string"]]' \
685 '["set", ["zzz", "short string", "a relatively long string"]]']],
686 [[["set",[]]
687 "a longer string"
688 "a relatively long string"
689 ["set",["a relatively long string","short string"]]
690 ["set",["a relatively long string","short string","zzz"]]]])
691
692 OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
693 [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
694 '[]' \
695 '"a relatively long string"' \
696 '["short string", "a relatively long string"]' \
697 '"zzz","short string","a relatively long string"']],
698 [[[]
699 ["a relatively long string"]
700 ["a relatively long string", "short string"]
701 ["a relatively long string", "short string", zzz]]])
702
703 OVSDB_CHECK_NEGATIVE_CPY([duplicate boolean not allowed in JSON set],
704 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
705 [ovsdb error: set contains duplicate])
706
707 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
708 [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
709 [set contains duplicate value])
710
711 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer not allowed in JSON set],
712 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
713 [ovsdb error: set contains duplicate])
714
715 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
716 [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
717 [set contains duplicate value])
718
719 OVSDB_CHECK_NEGATIVE_CPY([duplicate real not allowed in JSON set],
720 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
721 [ovsdb error: set contains duplicate])
722
723 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
724 [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
725 [set contains duplicate value])
726
727 OVSDB_CHECK_NEGATIVE_CPY([duplicate string not allowed in JSON set],
728 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
729 [ovsdb error: set contains duplicate])
730
731 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
732 [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
733 [set contains duplicate value])
734
735 OVSDB_CHECK_NEGATIVE_CPY([duplicate uuid not allowed in JSON set],
736 [[parse-data '{"key": "uuid", "max": 5}' \
737 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
738 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
739 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
740 [ovsdb error: set contains duplicate])
741
742 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
743 [[parse-data-strings '{"key": "uuid", "max": 5}' \
744 '7ef21525-0088-4a28-a418-5518413e43ea,
745 355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
746 7ef21525-0088-4a28-a418-5518413e43ea']],
747 [set contains duplicate value])
748 \f
749 AT_BANNER([OVSDB -- map data])
750
751 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 integer to boolean],
752 [[parse-data '{"key": "integer", "value": "boolean"}' \
753 '["map", [[1, true]]]']],
754 [[["map",[[1,true]]]]])
755
756 OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
757 [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
758 '1=true']],
759 [[1=true]])
760
761 OVSDB_CHECK_POSITIVE_CPY([JSON map of at least 1 integer to boolean],
762 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
763 '["map", [[1, true]]]' \
764 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
765 '["map", [[3, false], [0, true], [4, false]]]']],
766 [[["map",[[1,true]]]
767 ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
768 ["map",[[0,true],[3,false],[4,false]]]]])
769
770 OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
771 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
772 '1=true' \
773 '0=true 1=false 2=true, 3=true 4=true,' \
774 '3=false,0=true ,4=false']],
775 [[{1=true}
776 {0=true, 1=false, 2=true, 3=true, 4=true}
777 {0=true, 3=false, 4=false}]])
778
779 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 boolean to integer],
780 [[parse-data '{"key": "boolean", "value": "integer"}' \
781 '["map", [[true, 1]]]']],
782 [[["map",[[true,1]]]]])
783
784 OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
785 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
786 'true=1']],
787 [[true=1]])
788
789 OVSDB_CHECK_POSITIVE_CPY([JSON map of 1 uuid to real],
790 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
791 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
792 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
793 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
794 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
795 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
796 [[["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]]]]])
797
798 OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
799 [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
800 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
801 6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
802 d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
803 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
804 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
805 [[{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}]])
806
807 OVSDB_CHECK_POSITIVE_CPY([JSON map of 10 string to string],
808 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
809 '["map", [["2 gills", "1 chopin"],
810 ["2 chopins", "1 pint"],
811 ["2 pints", "1 quart"],
812 ["2 quarts", "1 pottle"],
813 ["2 pottles", "1 gallon"],
814 ["2 gallons", "1 peck"],
815 ["2 pecks", "1 demibushel"],
816 ["2 demibushel", "1 firkin"],
817 ["2 firkins", "1 kilderkin"],
818 ["2 kilderkins", "1 barrel"]]]']],
819 [[["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"]]]]])
820
821 OVSDB_CHECK_POSITIVE([string map of 10 string to string],
822 [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
823 '{"2 gills"="1 chopin",
824 "2 chopins"= "1 pint",
825 "2 pints"= "1 quart",
826 "2 quarts"= "1 pottle",
827 "2 pottles"= "1 gallon",
828 "2 gallons"= "1 peck",
829 "2 pecks"= "1 demibushel",
830 "2 demibushel"= "1 firkin",
831 "2 firkins"= "1 kilderkin",
832 "2 kilderkins"= "1 barrel"}']],
833 [[{"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"}]])
834
835 OVSDB_CHECK_NEGATIVE_CPY([duplicate integer key not allowed in JSON map],
836 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
837 '["map", [[1, true], [2, false], [1, false]]]']],
838 [ovsdb error: map contains duplicate key])
839
840 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
841 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
842 '1=true 2=false 1=false']],
843 [map contains duplicate key])
844
845 OVSDB_CHECK_POSITIVE([generate and apply diff -- integer],
846 [[diff-data '["integer"]' '[0]' '[2]']],
847 [[diff: 2
848 apply diff: 2
849 OK]])
850
851 OVSDB_CHECK_POSITIVE([generate and apply diff -- boolean],
852 [[diff-data '["boolean"]' '[true]' '[false]']],
853 [[diff: false
854 apply diff: false
855 OK]])
856
857 OVSDB_CHECK_POSITIVE([generate and apply diff -- string],
858 [[diff-data '["string"]' '["AAA"]' '["BBB"]']],
859 [[diff: "BBB"
860 apply diff: "BBB"
861 OK]])
862
863 dnl Test set modifications.
864 OVSDB_CHECK_POSITIVE([generate and apply diff -- set],
865 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
866 '["set", [0, 1]]' '["set", [1,2]]' \
867 '["set", [0, 1]]' '["set", [1]]' \
868 '["set", []]' '["set", [0, 1]]' \
869 '["set", [0, 1]]' '["set", []]'
870 ]],
871 [[diff: ["set",[0,2]]
872 apply diff: ["set",[1,2]]
873 OK
874 diff: 0
875 apply diff: 1
876 OK
877 diff: ["set",[0,1]]
878 apply diff: ["set",[0,1]]
879 OK
880 diff: ["set",[0,1]]
881 apply diff: ["set",[]]
882 OK]])
883
884 dnl Test set modifications causes data to violate set size constrain.
885 OVSDB_CHECK_NEGATIVE([generate and apply diff -- set -- size error],
886 [[diff-data '{"key": "integer", "min":0, "max": 3}' \
887 '["set", [0, 1]]' '["set", [1, 2, 3, 4]]']],
888 [[ovsdb error: Datum crated by diff has size error]])
889
890 dnl Test set modifications.
891 OVSDB_CHECK_POSITIVE([generate and apply diff -- map],
892 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
893 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 pints", "1 quart"]]]' \
894 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 chopin"]]]' \
895 '["map", [["2 gills", "1 chopin"]]]' '["map", []]' \
896 '["map", []]' '["map", [["2 pints", "1 quart"]]]' \
897 '["map", [["2 gills", "1 chopin"]]]' '["map", [["2 gills", "1 gallon"]]]' \
898 ]],
899 [[diff: ["map",[["2 gills","1 chopin"],["2 pints","1 quart"]]]
900 apply diff: ["map",[["2 pints","1 quart"]]]
901 OK
902 diff: ["map",[]]
903 apply diff: ["map",[["2 gills","1 chopin"]]]
904 OK
905 diff: ["map",[["2 gills","1 chopin"]]]
906 apply diff: ["map",[]]
907 OK
908 diff: ["map",[["2 pints","1 quart"]]]
909 apply diff: ["map",[["2 pints","1 quart"]]]
910 OK
911 diff: ["map",[["2 gills","1 gallon"]]]
912 apply diff: ["map",[["2 gills","1 gallon"]]]
913 OK]])
914
915 OVSDB_CHECK_NEGATIVE([generate and apply diff with map -- size error],
916 [[diff-data '{"key": "string", "value": "string", "min":0, "max": 3}' \
917 '["map", [["2 gills", "1 chopin"]]]' \
918 '["map", [["2 gills", "1 gallon"],
919 ["2 pints", "1 quart"],
920 ["2 quarts", "1 pottle"],
921 ["2 gallons", "1 peck"]]]' \
922 ]],
923 [[ovsdb error: Datum crated by diff has size error]])