]> git.proxmox.com Git - ovs.git/blame - tests/ovsdb-data.at
poll-loop: New function poll_timer_wait_until().
[ovs.git] / tests / ovsdb-data.at
CommitLineData
bd76d25d 1AT_BANNER([OVSDB -- atoms without constraints])
f85f8ebb 2
5c414a2e 3OVSDB_CHECK_POSITIVE([integer atom from JSON],
f85f8ebb
BP
4 [[parse-atoms '["integer"]' \
5 '[0]' \
6 '[-1]' \
7 '[1e3]' \
8 '[9223372036854775807]' \
9 '[-9223372036854775808]' ]],
10 [0
11-1
121000
139223372036854775807
14-9223372036854775808])
15
5c414a2e
BP
16OVSDB_CHECK_POSITIVE([integer atom from string],
17 [[parse-atom-strings -- '["integer"]' \
18 '0' \
19 '-1' \
20 '+1000' \
21 '9223372036854775807' \
22 '-9223372036854775808' ]],
23 [0
24-1
251000
269223372036854775807
27-9223372036854775808])
28
29OVSDB_CHECK_POSITIVE([real atom from JSON],
f85f8ebb
BP
30 [[parse-atoms '["real"]' \
31 '[0]' \
32 '[0.0]' \
33 '[-0.0]' \
34 '[-1.25]' \
35 '[1e3]' \
36 '[1e37]' \
37 '[0.00390625]' ]],
38 [0
390
400
41-1.25
421000
431e+37
440.00390625])
45
5c414a2e
BP
46OVSDB_CHECK_POSITIVE([real atom from string],
47 [[parse-atom-strings -- '["real"]' \
48 '0' \
49 '0.0' \
50 '-0.0' \
51 '-1.25' \
52 '1e3' \
53 '1e37' \
54 '0.00390625' ]],
55 [0
560
570
58-1.25
591000
601e+37
610.00390625])
62
63OVSDB_CHECK_POSITIVE([boolean atom from JSON],
f85f8ebb
BP
64 [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
65 [true
66false])
67
5c414a2e
BP
68OVSDB_CHECK_POSITIVE([boolean atom from string],
69 [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
70 [true
71false])
72
73OVSDB_CHECK_POSITIVE([string atom from JSON],
f85f8ebb
BP
74 [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
75 [""
76"true"
77"\"\\/\b\f\n\r\t"])
78
5c414a2e
BP
79OVSDB_CHECK_POSITIVE([string atom from string],
80 [[parse-atom-strings '["string"]' \
81 'unquoted' \
82 '"quoted-string"' \
83 '"needs quotes"' \
84 '""' \
85 '"true"' \
86 '"\"\\\/\b\f\n\r\t"']],
87 [unquoted
88quoted-string
89"needs quotes"
90""
91"true"
92"\"\\/\b\f\n\r\t"])
93
94OVSDB_CHECK_POSITIVE([uuid atom from JSON],
f85f8ebb
BP
95 [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
96 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
97
5c414a2e
BP
98OVSDB_CHECK_POSITIVE([uuid atom from string],
99 [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
100 [550e8400-e29b-41d4-a716-446655440000])
101
f85f8ebb
BP
102OVSDB_CHECK_POSITIVE([integer atom sorting],
103 [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
104 [[[-1,0,1,2,55]]])
105
106OVSDB_CHECK_POSITIVE([real atom sorting],
107 [[sort-atoms '["real"]' '[1.25,1.23,0.0,-0.0,-1e99]']],
108 [[[-1e+99,0,0,1.23,1.25]]])
109
110OVSDB_CHECK_POSITIVE([boolean atom sorting],
111 [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
112 [[[false,false,false,true,true]]])
113
114OVSDB_CHECK_POSITIVE([string atom sorting],
115 [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
116 [[["\b","abc","abd","xxx"]]])
117
118OVSDB_CHECK_POSITIVE([uuid atom sorting],
119 [[sort-atoms '["uuid"]' '[
120 ["uuid", "00000000-0000-0000-0000-000000000001"],
121 ["uuid", "00000000-1000-0000-0000-000000000000"],
122 ["uuid", "00000000-0000-1000-0000-000000000000"],
123 ["uuid", "00010000-0000-0000-0000-000000000000"],
124 ["uuid", "00000000-0000-0000-0000-000000000100"],
125 ["uuid", "00000000-0000-0000-0000-000100000000"],
126 ["uuid", "00000000-0000-0010-0000-000000000000"],
127 ["uuid", "00000100-0000-0000-0000-000000000000"],
128 ["uuid", "00000000-0000-0001-0000-000000000000"],
129 ["uuid", "00000000-0000-0000-0000-000001000000"],
130 ["uuid", "01000000-0000-0000-0000-000000000000"],
131 ["uuid", "00000000-0000-0000-0000-000000001000"],
132 ["uuid", "00000000-0000-0000-0000-000010000000"],
133 ["uuid", "00000000-0000-0000-0000-010000000000"],
134 ["uuid", "00000000-0000-0100-0000-000000000000"],
135 ["uuid", "10000000-0000-0000-0000-000000000000"],
136 ["uuid", "00000000-0000-0000-0000-000000000010"],
137 ["uuid", "00000000-0100-0000-0000-000000000000"],
138 ["uuid", "00000000-0000-0000-0100-000000000000"],
139 ["uuid", "00000000-0000-0000-0001-000000000000"],
140 ["uuid", "00000010-0000-0000-0000-000000000000"],
141 ["uuid", "00000000-0000-0000-0010-000000000000"],
142 ["uuid", "00000000-0000-0000-0000-000000010000"],
143 ["uuid", "00000000-0000-0000-1000-000000000000"],
144 ["uuid", "00000000-0000-0000-0000-100000000000"],
145 ["uuid", "00000000-0000-0000-0000-001000000000"],
146 ["uuid", "00000000-0000-0000-0000-000000100000"],
147 ["uuid", "00000000-0000-0000-0000-000000000000"],
148 ["uuid", "00000000-0010-0000-0000-000000000000"],
149 ["uuid", "00100000-0000-0000-0000-000000000000"],
150 ["uuid", "00000000-0001-0000-0000-000000000000"],
151 ["uuid", "00000001-0000-0000-0000-000000000000"],
152 ["uuid", "00001000-0000-0000-0000-000000000000"]]']],
153 [[[["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"]]]])
154
bd76d25d 155OVSDB_CHECK_POSITIVE([real not acceptable integer JSON atom],
f85f8ebb 156 [[parse-atoms '["integer"]' '[0.5]' ]],
bd76d25d
BP
157 [syntax "0.5": syntax error: expected integer])
158
159dnl <C0> is not allowed anywhere in a UTF-8 string.
160dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
161OVSDB_CHECK_POSITIVE([no invalid UTF-8 sequences in strings],
162 [parse-atoms '[["string"]]' \
163 '@<:@"m4_esyscmd([printf "\xc0"])"@:>@' \
164 '@<:@"m4_esyscmd([printf "\xed\xa0\x80"])"@:>@' \
165],
166 [constraint violation: "m4_esyscmd([printf "\xc0"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xc0
167constraint violation: "m4_esyscmd([printf "\xed\xa0\x80"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])
f85f8ebb 168
5c414a2e
BP
169OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
170 [[parse-atom-strings '["integer"]' '0.5' ]],
171 ["0.5" is not a valid integer])
172
bd76d25d 173OVSDB_CHECK_POSITIVE([string "true" not acceptable boolean JSON atom],
f85f8ebb 174 [[parse-atoms '["boolean"]' '["true"]' ]],
bd76d25d 175 [syntax ""true"": syntax error: expected boolean])
f85f8ebb 176
5c414a2e
BP
177OVSDB_CHECK_NEGATIVE([string "true" not acceptable boolean string atom],
178 [[parse-atom-strings '["boolean"]' '"true"' ]],
179 [""true"" is not a valid boolean (use "true" or "false")])
180
bd76d25d 181OVSDB_CHECK_POSITIVE([integer not acceptable string JSON atom],
f85f8ebb 182 [[parse-atoms '["string"]' '[1]']],
bd76d25d 183 [syntax "1": syntax error: expected string])
f85f8ebb 184
bd76d25d 185OVSDB_CHECK_POSITIVE([uuid atom must be expressed as JSON array],
f85f8ebb 186 [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
bd76d25d 187 [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
f85f8ebb 188
5c414a2e
BP
189OVSDB_CHECK_NEGATIVE([empty string atom must be quoted],
190 [[parse-atom-strings '["string"]' '']],
191 [An empty string is not valid as input; use "" to represent the empty string])
192
193OVSDB_CHECK_NEGATIVE([quotes must be balanced],
194 [parse-atom-strings '[["string"]]' '"asdf'],
195 ["asdf: missing quote at end of quoted string])
196
197OVSDB_CHECK_NEGATIVE([uuids must be valid],
198 [parse-atom-strings '[["uuid"]]' '1234-5678'],
199 ["1234-5678" is not a valid UUID])
bd76d25d 200\f
bfc96d9b
BP
201AT_BANNER([OVSDB -- atoms with enum constraints])
202
203OVSDB_CHECK_POSITIVE([integer atom enum],
204 [[parse-atoms '[{"type": "integer", "enum": ["set", [1, 6, 8, 10]]}]' \
205 '[0]' \
206 '[1]' \
207 '[2]' \
208 '[3]' \
209 '[6]' \
210 '[7]' \
211 '[8]' \
212 '[9]' \
213 '[10]' \
214 '[11]']],
215 [[constraint violation: 0 is not one of the allowed values ([1, 6, 8, 10])
2161
217constraint violation: 2 is not one of the allowed values ([1, 6, 8, 10])
218constraint violation: 3 is not one of the allowed values ([1, 6, 8, 10])
2196
220constraint violation: 7 is not one of the allowed values ([1, 6, 8, 10])
2218
222constraint violation: 9 is not one of the allowed values ([1, 6, 8, 10])
22310
224constraint violation: 11 is not one of the allowed values ([1, 6, 8, 10])]])
225
226OVSDB_CHECK_POSITIVE([real atom enum],
227 [[parse-atoms '[{"type": "real", "enum": ["set", [-1.5, 1.5]]}]' \
228 '[-2]' \
229 '[-1]' \
230 '[-1.5]' \
231 '[0]' \
232 '[1]' \
233 '[1.5]' \
234 '[2]']],
235 [[constraint violation: -2 is not one of the allowed values ([-1.5, 1.5])
236constraint violation: -1 is not one of the allowed values ([-1.5, 1.5])
237-1.5
238constraint violation: 0 is not one of the allowed values ([-1.5, 1.5])
239constraint violation: 1 is not one of the allowed values ([-1.5, 1.5])
2401.5
241constraint violation: 2 is not one of the allowed values ([-1.5, 1.5])]])
242
243OVSDB_CHECK_POSITIVE([boolean atom enum],
244 [[parse-atoms '[{"type": "boolean", "enum": false}]' \
245 '[false]' \
246 '[true]']],
247 [[false
248constraint violation: true is not one of the allowed values ([false])]])
249
250OVSDB_CHECK_POSITIVE([string atom enum],
251 [[parse-atoms '[{"type": "string", "enum": ["set", ["abc", "def"]]}]' \
252 '[""]' \
253 '["ab"]' \
254 '["abc"]' \
255 '["def"]' \
256 '["defg"]' \
257 '["DEF"]']],
258 [[constraint violation: "" is not one of the allowed values ([abc, def])
259constraint violation: ab is not one of the allowed values ([abc, def])
260"abc"
261"def"
262constraint violation: defg is not one of the allowed values ([abc, def])
263constraint violation: DEF is not one of the allowed values ([abc, def])]])
264
265OVSDB_CHECK_POSITIVE([uuid atom enum],
266 [[parse-atoms '[{"type": "uuid", "enum": ["set", [["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"], ["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]]]}]' \
267 '["uuid", "6d53a6dd-2da7-4924-9927-97f613812382"]' \
268 '["uuid", "52cbc842-137a-4db5-804f-9f34106a0ba3"]' \
269 '["uuid", "dab2a6b2-6094-4f43-a7ef-4c0f0608f176"]']],
270 [[["uuid","6d53a6dd-2da7-4924-9927-97f613812382"]
271["uuid","52cbc842-137a-4db5-804f-9f34106a0ba3"]
272constraint violation: dab2a6b2-6094-4f43-a7ef-4c0f0608f176 is not one of the allowed values ([52cbc842-137a-4db5-804f-9f34106a0ba3, 6d53a6dd-2da7-4924-9927-97f613812382])]])
273\f
274AT_BANNER([OVSDB -- atoms with other constraints])
bd76d25d
BP
275
276OVSDB_CHECK_POSITIVE([integers >= 5],
277 [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
278 '[0]' \
279 '[4]' \
280 '[5]' \
281 '[6]' \
282 '[12345]']],
283 [constraint violation: 0 is less than minimum allowed value 5
284constraint violation: 4 is less than minimum allowed value 5
2855
2866
28712345])
288
289OVSDB_CHECK_POSITIVE([integers <= -1],
290 [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
291 '[0]' \
292 '[-1]' \
293 '[-2]' \
294 '[-123]']],
295 [constraint violation: 0 is greater than maximum allowed value -1
296-1
297-2
298-123])
299
300OVSDB_CHECK_POSITIVE([integers in range -10 to 10],
301 [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
302 '[-20]' \
303 '[-11]' \
304 '[-10]' \
305 '[-9]' \
306 '[1]' \
307 '[9]' \
308 '[10]' \
309 '[11]' \
310 '[123576]']],
311 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
312constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
313-10
314-9
3151
3169
31710
318constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
319constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
320
321OVSDB_CHECK_POSITIVE([reals >= 5],
322 [[parse-atoms '[{"type": "real", "minReal": 5}]' \
323 '[0]' \
324 '[4]' \
325 '[5]' \
326 '[6]' \
327 '[12345]']],
328 [constraint violation: 0 is less than minimum allowed value 5
329constraint violation: 4 is less than minimum allowed value 5
3305
3316
33212345])
333
334OVSDB_CHECK_POSITIVE([reals <= -1],
335 [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
336 '[0]' \
337 '[-1]' \
338 '[-2]' \
339 '[-123]']],
340 [constraint violation: 0 is greater than maximum allowed value -1
341-1
342-2
343-123])
344
345OVSDB_CHECK_POSITIVE([reals in range -10 to 10],
346 [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
347 '[-20]' \
348 '[-11]' \
349 '[-10]' \
350 '[-9]' \
351 '[1]' \
352 '[9]' \
353 '[10]' \
354 '[11]' \
355 '[123576]']],
356 [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
357constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
358-10
359-9
3601
3619
36210
363constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
364constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
365
bd76d25d
BP
366OVSDB_CHECK_POSITIVE([strings at least 2 characters long],
367 [[parse-atoms '{"type": "string", "minLength": 2}' \
368 '[""]' \
369 '["a"]' \
370 '["ab"]' \
371 '["abc"]' \
372 '["\ud834\udd1e"]']],
373 [[constraint violation: "" length 0 is less than minimum allowed length 2
374constraint violation: "a" length 1 is less than minimum allowed length 2
375"ab"
376"abc"
377constraint violation: "𝄞" length 1 is less than minimum allowed length 2]])
378
379OVSDB_CHECK_POSITIVE([strings no more than 2 characters long],
380 [[parse-atoms '{"type": "string", "maxLength": 2}' \
381 '[""]' \
382 '["a"]' \
383 '["ab"]' \
384 '["abc"]' \
385 '["\ud834\udd1e"]']],
386 [[""
387"a"
388"ab"
389constraint violation: "abc" length 3 is greater than maximum allowed length 2
390"𝄞"]])
5c414a2e 391
f85f8ebb
BP
392AT_BANNER([OSVDB -- simple data])
393
5c414a2e 394OVSDB_CHECK_POSITIVE([integer JSON datum],
ae8f13e2 395 [[parse-data '["integer"]' '[0]' '["set",[1]]' '[-1]']],
f85f8ebb
BP
396 [0
3971
398-1])
399
5c414a2e
BP
400OVSDB_CHECK_POSITIVE([integer string datum],
401 [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
402 [0
4031
404-1
4051])
406
407OVSDB_CHECK_POSITIVE([real JSON datum],
ae8f13e2 408 [[parse-data '["real"]' '[0]' '["set",[1.0]]' '[-1.25]']],
f85f8ebb
BP
409 [0
4101
411-1.25])
412
5c414a2e
BP
413OVSDB_CHECK_POSITIVE([real string datum],
414 [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
415 [0
4161
417-1.25])
418
419OVSDB_CHECK_POSITIVE([boolean JSON datum],
ae8f13e2 420 [[parse-data '["boolean"]' '["set", [true]]' '[false]' ]],
f85f8ebb
BP
421 [true
422false])
423
5c414a2e
BP
424OVSDB_CHECK_POSITIVE([boolean string datum],
425 [[parse-data-strings '["boolean"]' 'true' 'false' ]],
426 [true
427false])
428
429OVSDB_CHECK_POSITIVE([string JSON datum],
ae8f13e2 430 [[parse-data '["string"]' '["set",[""]]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
f85f8ebb
BP
431 [""
432"true"
433"\"\\/\b\f\n\r\t"])
434
5c414a2e
BP
435OVSDB_CHECK_POSITIVE([string string datum],
436 [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
437 [x
438""
439"true"
440"\"\\/\b\f\n\r\t"])
bd76d25d 441\f
f85f8ebb
BP
442AT_BANNER([OVSDB -- set data])
443
5c414a2e 444OVSDB_CHECK_POSITIVE([JSON optional boolean],
f85f8ebb 445 [[parse-data '{"key": "boolean", "min": 0}' \
ae8f13e2 446 '[true]' \
f85f8ebb
BP
447 '["set", [false]]' \
448 '["set", []]']],
ae8f13e2
BP
449 [[true
450false
f85f8ebb
BP
451["set",[]]]],
452 [set])
453
5c414a2e
BP
454OVSDB_CHECK_POSITIVE([string optional boolean],
455 [[parse-data-strings '{"key": "boolean", "min": 0}' \
456 'true' \
457 'false' \
458 '[]']],
459 [[true
460false
461[]]],
462 [set])
463
464OVSDB_CHECK_POSITIVE([JSON set of 0 or more integers],
f85f8ebb
BP
465 [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
466 '["set", [0]]' \
ae8f13e2 467 '[1]' \
f85f8ebb
BP
468 '["set", [0, 1]]' \
469 '["set", [0, 1, 2]]' \
470 '["set", [0, 1, 2, 3, 4, 5]]' \
471 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
472 '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
ae8f13e2
BP
473 [[0
4741
f85f8ebb
BP
475["set",[0,1]]
476["set",[0,1,2]]
477["set",[0,1,2,3,4,5]]
478["set",[0,1,2,3,4,5,6,7,8]]
479["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
480
5c414a2e
BP
481OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
482 [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
483 '0' \
484 '0,1' \
485 '0, 1, 2' \
486 '[0, 1,2, 3, 4, 5]' \
487 '0, 1,2, 3,4, 5, 6, 7, 8' \
488 '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']],
489 [[[0]
490[0, 1]
491[0, 1, 2]
492[0, 1, 2, 3, 4, 5]
493[0, 1, 2, 3, 4, 5, 6, 7, 8]
494[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
495
496OVSDB_CHECK_POSITIVE([JSON set of 1 to 3 uuids],
f85f8ebb
BP
497 [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
498 '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
ae8f13e2 499 '["uuid", "b5078be0-7664-4299-b836-8bcc03ef941f"]' \
f85f8ebb
BP
500 '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
501 ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
502 ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
ae8f13e2
BP
503 [[["uuid","550e8400-e29b-41d4-a716-446655440000"]
504["uuid","b5078be0-7664-4299-b836-8bcc03ef941f"]
f85f8ebb
BP
505["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
506
5c414a2e
BP
507OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
508 [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
509 '[550e8400-e29b-41d4-a716-446655440000]' \
510 '[c5051240-30ff-43ed-b4b9-93cf3f050813,
511 90558331-09af-4d2f-a572-509cad2e9088,
512 550e8400-e29b-41d4-a716-446655440000]']],
513 [[[550e8400-e29b-41d4-a716-446655440000]
514[550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
515
516OVSDB_CHECK_POSITIVE([JSON set of 0 to 3 strings],
f85f8ebb
BP
517 [[parse-data '{"key": "string", "min": 0, "max": 3}' \
518 '["set", []]' \
ae8f13e2 519 '["a longer string"]' \
f85f8ebb
BP
520 '["set", ["a relatively long string"]]' \
521 '["set", ["short string", "a relatively long string"]]' \
522 '["set", ["zzz", "short string", "a relatively long string"]]']],
523 [[["set",[]]
ae8f13e2
BP
524"a longer string"
525"a relatively long string"
f85f8ebb
BP
526["set",["a relatively long string","short string"]]
527["set",["a relatively long string","short string","zzz"]]]])
528
5c414a2e
BP
529OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
530 [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
531 '[]' \
532 '"a relatively long string"' \
533 '["short string", "a relatively long string"]' \
534 '"zzz","short string","a relatively long string"']],
535 [[[]
536["a relatively long string"]
537["a relatively long string", "short string"]
538["a relatively long string", "short string", zzz]]])
539
540OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in JSON set],
f85f8ebb
BP
541 [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
542 [ovsdb error: set contains duplicate])
543
5c414a2e
BP
544OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
545 [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
546 [set contains duplicate value])
547
548OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in JSON set],
f85f8ebb
BP
549 [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
550 [ovsdb error: set contains duplicate])
551
5c414a2e
BP
552OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
553 [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
554 [set contains duplicate value])
555
556OVSDB_CHECK_NEGATIVE([duplicate real not allowed in JSON set],
f85f8ebb
BP
557 [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
558 [ovsdb error: set contains duplicate])
559
5c414a2e
BP
560OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
561 [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
562 [set contains duplicate value])
563
564OVSDB_CHECK_NEGATIVE([duplicate string not allowed in JSON set],
f85f8ebb
BP
565 [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
566 [ovsdb error: set contains duplicate])
567
5c414a2e
BP
568OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
569 [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
570 [set contains duplicate value])
571
572OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in JSON set],
f85f8ebb
BP
573 [[parse-data '{"key": "uuid", "max": 5}' \
574 '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
575 ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
576 ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
577 [ovsdb error: set contains duplicate])
578
5c414a2e
BP
579OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
580 [[parse-data-strings '{"key": "uuid", "max": 5}' \
581 '7ef21525-0088-4a28-a418-5518413e43ea,
582 355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
583 7ef21525-0088-4a28-a418-5518413e43ea']],
584 [set contains duplicate value])
bd76d25d 585\f
f85f8ebb
BP
586AT_BANNER([OVSDB -- map data])
587
5c414a2e 588OVSDB_CHECK_POSITIVE([JSON map of 1 integer to boolean],
f85f8ebb
BP
589 [[parse-data '{"key": "integer", "value": "boolean"}' \
590 '["map", [[1, true]]]']],
591 [[["map",[[1,true]]]]])
592
5c414a2e
BP
593OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
594 [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
595 '1=true']],
596 [[1=true]])
597
598OVSDB_CHECK_POSITIVE([JSON map of at least 1 integer to boolean],
f85f8ebb
BP
599 [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
600 '["map", [[1, true]]]' \
601 '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
602 '["map", [[3, false], [0, true], [4, false]]]']],
603 [[["map",[[1,true]]]
604["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
605["map",[[0,true],[3,false],[4,false]]]]])
606
5c414a2e
BP
607OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
608 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
609 '1=true' \
610 '0=true 1=false 2=true, 3=true 4=true,' \
611 '3=false,0=true ,4=false']],
612 [[{1=true}
613{0=true, 1=false, 2=true, 3=true, 4=true}
614{0=true, 3=false, 4=false}]])
615
616OVSDB_CHECK_POSITIVE([JSON map of 1 boolean to integer],
f85f8ebb
BP
617 [[parse-data '{"key": "boolean", "value": "integer"}' \
618 '["map", [[true, 1]]]']],
619 [[["map",[[true,1]]]]])
620
5c414a2e
BP
621OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
622 [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
623 'true=1']],
624 [[true=1]])
625
626OVSDB_CHECK_POSITIVE([JSON map of 1 uuid to real],
31a763d7 627 [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
f85f8ebb
BP
628 '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
629 [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
630 [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
631 [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
632 [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
633 [[["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]]]]])
634
5c414a2e
BP
635OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
636 [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
637 'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
638 6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
639 d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
640 25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
641 1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
642 [[{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}]])
643
644OVSDB_CHECK_POSITIVE([JSON map of 10 string to string],
31a763d7 645 [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
f85f8ebb
BP
646 '["map", [["2 gills", "1 chopin"],
647 ["2 chopins", "1 pint"],
648 ["2 pints", "1 quart"],
649 ["2 quarts", "1 pottle"],
650 ["2 pottles", "1 gallon"],
651 ["2 gallons", "1 peck"],
652 ["2 pecks", "1 demibushel"],
653 ["2 demibushel", "1 firkin"],
654 ["2 firkins", "1 kilderkin"],
655 ["2 kilderkins", "1 barrel"]]]']],
656 [[["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"]]]]])
657
5c414a2e
BP
658OVSDB_CHECK_POSITIVE([string map of 10 string to string],
659 [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
660 '{"2 gills"="1 chopin",
661 "2 chopins"= "1 pint",
662 "2 pints"= "1 quart",
663 "2 quarts"= "1 pottle",
664 "2 pottles"= "1 gallon",
665 "2 gallons"= "1 peck",
666 "2 pecks"= "1 demibushel",
667 "2 demibushel"= "1 firkin",
668 "2 firkins"= "1 kilderkin",
669 "2 kilderkins"= "1 barrel"}']],
670 [[{"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"}]])
671
672OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in JSON map],
f85f8ebb
BP
673 [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
674 '["map", [[1, true], [2, false], [1, false]]]']],
675 [ovsdb error: map contains duplicate key])
5c414a2e
BP
676
677OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
678 [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
679 '1=true 2=false 1=false']],
680 [map contains duplicate key])