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