ovsdb: Fix support for systems where libpcre is not installed.
[sliver-openvswitch.git] / tests / ovsdb-data.at
1 AT_BANNER([OVSDB -- atoms without constraints])
2
3 OVSDB_CHECK_POSITIVE([integer atom from JSON], 
4   [[parse-atoms '["integer"]' \
5     '[0]' \
6     '[-1]' \
7     '[1e3]' \
8     '[9223372036854775807]' \
9     '[-9223372036854775808]' ]], 
10   [0
11 -1
12 1000
13 9223372036854775807
14 -9223372036854775808])
15
16 OVSDB_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
25 1000
26 9223372036854775807
27 -9223372036854775808])
28
29 OVSDB_CHECK_POSITIVE([real atom from JSON], 
30   [[parse-atoms '["real"]' \
31     '[0]' \
32     '[0.0]' \
33     '[-0.0]' \
34     '[-1.25]' \
35     '[1e3]' \
36     '[1e37]' \
37     '[0.00390625]' ]], 
38   [0
39 0
40 0
41 -1.25
42 1000
43 1e+37
44 0.00390625])
45
46 OVSDB_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
56 0
57 0
58 -1.25
59 1000
60 1e+37
61 0.00390625])
62
63 OVSDB_CHECK_POSITIVE([boolean atom from JSON],
64   [[parse-atoms '["boolean"]' '[true]' '[false]' ]],
65   [true
66 false])
67
68 OVSDB_CHECK_POSITIVE([boolean atom from string],
69   [[parse-atom-strings '["boolean"]' 'true' 'false' ]],
70   [true
71 false])
72
73 OVSDB_CHECK_POSITIVE([string atom from JSON],
74   [[parse-atoms '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
75   [""
76 "true"
77 "\"\\/\b\f\n\r\t"])
78
79 OVSDB_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
88 quoted-string
89 "needs quotes"
90 ""
91 "true"
92 "\"\\/\b\f\n\r\t"])
93
94 OVSDB_CHECK_POSITIVE([uuid atom from JSON],
95   [[parse-atoms '["uuid"]' '["uuid", "550e8400-e29b-41d4-a716-446655440000"]']],
96   [[["uuid","550e8400-e29b-41d4-a716-446655440000"]]])
97
98 OVSDB_CHECK_POSITIVE([uuid atom from string],
99   [[parse-atom-strings '["uuid"]' '550e8400-e29b-41d4-a716-446655440000']],
100   [550e8400-e29b-41d4-a716-446655440000])
101
102 OVSDB_CHECK_POSITIVE([integer atom sorting],
103   [[sort-atoms '["integer"]' '[55,0,-1,2,1]']],
104   [[[-1,0,1,2,55]]])
105
106 OVSDB_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
110 OVSDB_CHECK_POSITIVE([boolean atom sorting],
111   [[sort-atoms '["boolean"]' '[true,false,true,false,false]']],
112   [[[false,false,false,true,true]]])
113
114 OVSDB_CHECK_POSITIVE([string atom sorting],
115   [[sort-atoms '["string"]' '["abd","abc","\b","xxx"]']],
116   [[["\b","abc","abd","xxx"]]])
117
118 OVSDB_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
155 OVSDB_CHECK_POSITIVE([real not acceptable integer JSON atom],
156   [[parse-atoms '["integer"]' '[0.5]' ]],
157   [syntax "0.5": syntax error: expected integer])
158
159 dnl <C0> is not allowed anywhere in a UTF-8 string.
160 dnl <ED A0 80> is a surrogate and not allowed in UTF-8.
161 OVSDB_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
167 constraint violation: "m4_esyscmd([printf "\xed\xa0\x80"])" is not a valid UTF-8 string: invalid UTF-8 sequence 0xed 0xa0])
168
169 OVSDB_CHECK_NEGATIVE([real not acceptable integer string atom],
170   [[parse-atom-strings '["integer"]' '0.5' ]],
171   ["0.5" is not a valid integer])
172
173 OVSDB_CHECK_POSITIVE([string "true" not acceptable boolean JSON atom],
174   [[parse-atoms '["boolean"]' '["true"]' ]],
175   [syntax ""true"": syntax error: expected boolean])
176
177 OVSDB_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
181 OVSDB_CHECK_POSITIVE([integer not acceptable string JSON atom],
182   [[parse-atoms '["string"]' '[1]']],
183   [syntax "1": syntax error: expected string])
184
185 OVSDB_CHECK_POSITIVE([uuid atom must be expressed as JSON array],
186   [[parse-atoms '["uuid"]' '["550e8400-e29b-41d4-a716-446655440000"]']],
187   [[syntax ""550e8400-e29b-41d4-a716-446655440000"": syntax error: expected ["uuid", <string>]]])
188
189 OVSDB_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
193 OVSDB_CHECK_NEGATIVE([quotes must be balanced],
194   [parse-atom-strings '[["string"]]' '"asdf'],
195   ["asdf: missing quote at end of quoted string])
196
197 OVSDB_CHECK_NEGATIVE([uuids must be valid],
198   [parse-atom-strings '[["uuid"]]' '1234-5678'],
199   ["1234-5678" is not a valid UUID])
200 \f
201 AT_BANNER([OVSDB -- atoms with constraints])
202
203 OVSDB_CHECK_POSITIVE([integers >= 5], 
204   [[parse-atoms '[{"type": "integer", "minInteger": 5}]' \
205     '[0]' \
206     '[4]' \
207     '[5]' \
208     '[6]' \
209     '[12345]']], 
210   [constraint violation: 0 is less than minimum allowed value 5
211 constraint violation: 4 is less than minimum allowed value 5
212 5
213 6
214 12345])
215
216 OVSDB_CHECK_POSITIVE([integers <= -1], 
217   [[parse-atoms '[{"type": "integer", "maxInteger": -1}]' \
218     '[0]' \
219     '[-1]' \
220     '[-2]' \
221     '[-123]']], 
222   [constraint violation: 0 is greater than maximum allowed value -1
223 -1
224 -2
225 -123])
226
227 OVSDB_CHECK_POSITIVE([integers in range -10 to 10], 
228   [[parse-atoms '[{"type": "integer", "minInteger": -10, "maxInteger": 10}]' \
229     '[-20]' \
230     '[-11]' \
231     '[-10]' \
232     '[-9]' \
233     '[1]' \
234     '[9]' \
235     '[10]' \
236     '[11]' \
237     '[123576]']], 
238   [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
239 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
240 -10
241 -9
242 1
243 9
244 10
245 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
246 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
247
248 OVSDB_CHECK_POSITIVE([reals >= 5], 
249   [[parse-atoms '[{"type": "real", "minReal": 5}]' \
250     '[0]' \
251     '[4]' \
252     '[5]' \
253     '[6]' \
254     '[12345]']], 
255   [constraint violation: 0 is less than minimum allowed value 5
256 constraint violation: 4 is less than minimum allowed value 5
257 5
258 6
259 12345])
260
261 OVSDB_CHECK_POSITIVE([reals <= -1], 
262   [[parse-atoms '[{"type": "real", "maxReal": -1}]' \
263     '[0]' \
264     '[-1]' \
265     '[-2]' \
266     '[-123]']], 
267   [constraint violation: 0 is greater than maximum allowed value -1
268 -1
269 -2
270 -123])
271
272 OVSDB_CHECK_POSITIVE([reals in range -10 to 10], 
273   [[parse-atoms '[{"type": "real", "minReal": -10, "maxReal": 10}]' \
274     '[-20]' \
275     '[-11]' \
276     '[-10]' \
277     '[-9]' \
278     '[1]' \
279     '[9]' \
280     '[10]' \
281     '[11]' \
282     '[123576]']], 
283   [constraint violation: -20 is not in the valid range -10 to 10 (inclusive)
284 constraint violation: -11 is not in the valid range -10 to 10 (inclusive)
285 -10
286 -9
287 1
288 9
289 10
290 constraint violation: 11 is not in the valid range -10 to 10 (inclusive)
291 constraint violation: 123576 is not in the valid range -10 to 10 (inclusive)])
292
293 AT_SETUP([strings matching /(a(b)?)c?/])
294 AT_KEYWORDS([ovsdb positive])
295 if test "$HAVE_PCRE" = yes; then
296    b_out='constraint violation: "b" does not match regular expression /(a(b)?)?c?/'
297    bc_out='constraint violation: "bc" does not match regular expression /(a(b)?)?c?/'
298 else
299    b_out='"b"'
300    bc_out='"bc"'
301 fi
302 AT_CHECK_UNQUOTED(
303   [[test-ovsdb parse-atoms '{"type": "string", "reMatch": "(a(b)?)?c?"}' \
304     '[""]' \
305     '["a"]' \
306     '["ab"]' \
307     '["abc"]' \
308     '["ac"]' \
309     '["b"]' \
310     '["bc"]' \
311     '["c"]']],
312   [0],
313   [[""
314 "a"
315 "ab"
316 "abc"
317 "ac"
318 $b_out
319 $bc_out
320 "c"
321 ]])
322 AT_CLEANUP
323
324 OVSDB_CHECK_POSITIVE([strings at least 2 characters long],
325   [[parse-atoms '{"type": "string", "minLength": 2}' \
326     '[""]' \
327     '["a"]' \
328     '["ab"]' \
329     '["abc"]' \
330     '["\ud834\udd1e"]']],
331   [[constraint violation: "" length 0 is less than minimum allowed length 2
332 constraint violation: "a" length 1 is less than minimum allowed length 2
333 "ab"
334 "abc"
335 constraint violation: "𝄞" length 1 is less than minimum allowed length 2]])
336
337 OVSDB_CHECK_POSITIVE([strings no more than 2 characters long],
338   [[parse-atoms '{"type": "string", "maxLength": 2}' \
339     '[""]' \
340     '["a"]' \
341     '["ab"]' \
342     '["abc"]' \
343     '["\ud834\udd1e"]']],
344   [[""
345 "a"
346 "ab"
347 constraint violation: "abc" length 3 is greater than maximum allowed length 2
348 "𝄞"]])
349
350 AT_BANNER([OSVDB -- simple data])
351
352 OVSDB_CHECK_POSITIVE([integer JSON datum],
353   [[parse-data '["integer"]' '[0]' '[1]' '[-1]']],
354   [0
355 1
356 -1])
357
358 OVSDB_CHECK_POSITIVE([integer string datum],
359   [[parse-data-strings -- '["integer"]' '0' '1' '-1' '+1']],
360   [0
361 1
362 -1
363 1])
364
365 OVSDB_CHECK_POSITIVE([real JSON datum], 
366   [[parse-data '["real"]' '[0]' '[1.0]' '[-1.25]']],
367   [0
368 1
369 -1.25])
370
371 OVSDB_CHECK_POSITIVE([real string datum], 
372   [[parse-data-strings -- '["real"]' '0' '1.0' '-1.25']],
373   [0
374 1
375 -1.25])
376
377 OVSDB_CHECK_POSITIVE([boolean JSON datum],
378   [[parse-data '["boolean"]' '[true]' '[false]' ]],
379   [true
380 false])
381
382 OVSDB_CHECK_POSITIVE([boolean string datum],
383   [[parse-data-strings '["boolean"]' 'true' 'false' ]],
384   [true
385 false])
386
387 OVSDB_CHECK_POSITIVE([string JSON datum],
388   [[parse-data '["string"]' '[""]' '["true"]' '["\"\\\/\b\f\n\r\t"]']],
389   [""
390 "true"
391 "\"\\/\b\f\n\r\t"])
392
393 OVSDB_CHECK_POSITIVE([string string datum],
394   [[parse-data-strings '["string"]' '"x"' '""' '"true"' '"\"\\\/\b\f\n\r\t"']],
395   [x
396 ""
397 "true"
398 "\"\\/\b\f\n\r\t"])
399 \f
400 AT_BANNER([OVSDB -- set data])
401
402 OVSDB_CHECK_POSITIVE([JSON optional boolean],
403   [[parse-data '{"key": "boolean", "min": 0}' \
404     '["set", [true]]' \
405     '["set", [false]]' \
406     '["set", []]']], 
407   [[["set",[true]]
408 ["set",[false]]
409 ["set",[]]]],
410   [set])
411
412 OVSDB_CHECK_POSITIVE([string optional boolean],
413   [[parse-data-strings '{"key": "boolean", "min": 0}' \
414     'true' \
415     'false' \
416     '[]']], 
417   [[true
418 false
419 []]],
420   [set])
421
422 OVSDB_CHECK_POSITIVE([JSON set of 0 or more integers],
423   [[parse-data '{"key": "integer", "min": 0, "max": "unlimited"}' \
424     '["set", [0]]' \
425     '["set", [0, 1]]' \
426     '["set", [0, 1, 2]]' \
427     '["set", [0, 1, 2, 3, 4, 5]]' \
428     '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8]]' \
429     '["set", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]']],
430   [[["set",[0]]
431 ["set",[0,1]]
432 ["set",[0,1,2]]
433 ["set",[0,1,2,3,4,5]]
434 ["set",[0,1,2,3,4,5,6,7,8]]
435 ["set",[0,1,2,3,4,5,6,7,8,9,10]]]])
436
437 OVSDB_CHECK_POSITIVE([string set of 0 or more integers],
438   [[parse-data-strings '{"key": "integer", "min": 0, "max": "unlimited"}' \
439     '0' \
440     '0,1' \
441     '0, 1, 2' \
442     '[0, 1,2, 3, 4, 5]' \
443     '0, 1,2, 3,4, 5, 6, 7, 8' \
444     '[0, 1, 2, 3, 4,5, 6,7, 8, 9, 10]']],
445   [[[0]
446 [0, 1]
447 [0, 1, 2]
448 [0, 1, 2, 3, 4, 5]
449 [0, 1, 2, 3, 4, 5, 6, 7, 8]
450 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]])
451
452 OVSDB_CHECK_POSITIVE([JSON set of 1 to 3 uuids],
453   [[parse-data '{"key": "uuid", "min": 1, "max": 3}' \
454     '["set", [["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]' \
455     '["set", [["uuid", "c5051240-30ff-43ed-b4b9-93cf3f050813"],
456               ["uuid", "90558331-09af-4d2f-a572-509cad2e9088"],
457               ["uuid", "550e8400-e29b-41d4-a716-446655440000"]]]']],
458   [[["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"]]]
459 ["set",[["uuid","550e8400-e29b-41d4-a716-446655440000"],["uuid","90558331-09af-4d2f-a572-509cad2e9088"],["uuid","c5051240-30ff-43ed-b4b9-93cf3f050813"]]]]])
460
461 OVSDB_CHECK_POSITIVE([string set of 1 to 3 uuids],
462   [[parse-data-strings '{"key": "uuid", "min": 1, "max": 3}' \
463     '[550e8400-e29b-41d4-a716-446655440000]' \
464     '[c5051240-30ff-43ed-b4b9-93cf3f050813,
465       90558331-09af-4d2f-a572-509cad2e9088,
466       550e8400-e29b-41d4-a716-446655440000]']],
467   [[[550e8400-e29b-41d4-a716-446655440000]
468 [550e8400-e29b-41d4-a716-446655440000, 90558331-09af-4d2f-a572-509cad2e9088, c5051240-30ff-43ed-b4b9-93cf3f050813]]])
469
470 OVSDB_CHECK_POSITIVE([JSON set of 0 to 3 strings],
471   [[parse-data '{"key": "string", "min": 0, "max": 3}' \
472     '["set", []]' \
473     '["set", ["a relatively long string"]]' \
474     '["set", ["short string", "a relatively long string"]]' \
475     '["set", ["zzz", "short string", "a relatively long string"]]']],
476   [[["set",[]]
477 ["set",["a relatively long string"]]
478 ["set",["a relatively long string","short string"]]
479 ["set",["a relatively long string","short string","zzz"]]]])
480
481 OVSDB_CHECK_POSITIVE([string set of 0 to 3 strings],
482   [[parse-data-strings '{"key": "string", "min": 0, "max": 3}' \
483     '[]' \
484     '"a relatively long string"' \
485     '["short string", "a relatively long string"]' \
486     '"zzz","short string","a relatively long string"']],
487   [[[]
488 ["a relatively long string"]
489 ["a relatively long string", "short string"]
490 ["a relatively long string", "short string", zzz]]])
491
492 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in JSON set],
493   [[parse-data '{"key": "boolean", "max": 5}' '["set", [true, true]]']],
494   [ovsdb error: set contains duplicate])
495
496 OVSDB_CHECK_NEGATIVE([duplicate boolean not allowed in string set],
497   [[parse-data-strings '{"key": "boolean", "max": 5}' 'true, true']],
498   [set contains duplicate value])
499
500 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in JSON set],
501   [[parse-data '{"key": "integer", "max": 5}' '["set", [1, 2, 3, 1]]']],
502   [ovsdb error: set contains duplicate])
503
504 OVSDB_CHECK_NEGATIVE([duplicate integer not allowed in string set],
505   [[parse-data-strings '{"key": "integer", "max": 5}' '[1, 2, 3, 1]']],
506   [set contains duplicate value])
507
508 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in JSON set],
509   [[parse-data '{"key": "real", "max": 5}' '["set", [0.0, -0.0]]']],
510   [ovsdb error: set contains duplicate])
511
512 OVSDB_CHECK_NEGATIVE([duplicate real not allowed in string set],
513   [[parse-data-strings '{"key": "real", "max": 5}' '0.0, -0.0']],
514   [set contains duplicate value])
515
516 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in JSON set],
517   [[parse-data '{"key": "string", "max": 5}' '["set", ["asdf", "ASDF", "asdf"]]']],
518   [ovsdb error: set contains duplicate])
519
520 OVSDB_CHECK_NEGATIVE([duplicate string not allowed in string set],
521   [[parse-data-strings '{"key": "string", "max": 5}' 'asdf, ASDF, "asdf"']],
522   [set contains duplicate value])
523
524 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in JSON set],
525   [[parse-data '{"key": "uuid", "max": 5}' \
526     '["set", [["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"],
527               ["uuid", "355ad037-f1da-40aa-b47c-ff9c7e8c6a38"],
528               ["uuid", "7ef21525-0088-4a28-a418-5518413e43ea"]]]']],
529   [ovsdb error: set contains duplicate])
530
531 OVSDB_CHECK_NEGATIVE([duplicate uuid not allowed in string set],
532   [[parse-data-strings '{"key": "uuid", "max": 5}' \
533     '7ef21525-0088-4a28-a418-5518413e43ea,
534      355ad037-f1da-40aa-b47c-ff9c7e8c6a38,
535      7ef21525-0088-4a28-a418-5518413e43ea']],
536   [set contains duplicate value])
537 \f
538 AT_BANNER([OVSDB -- map data])
539
540 OVSDB_CHECK_POSITIVE([JSON map of 1 integer to boolean],
541   [[parse-data '{"key": "integer", "value": "boolean"}' \
542     '["map", [[1, true]]]']],
543   [[["map",[[1,true]]]]])
544
545 OVSDB_CHECK_POSITIVE([string map of 1 integer to boolean],
546   [[parse-data-strings '{"key": "integer", "value": "boolean"}' \
547     '1=true']],
548   [[1=true]])
549
550 OVSDB_CHECK_POSITIVE([JSON map of at least 1 integer to boolean],
551   [[parse-data '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
552     '["map", [[1, true]]]' \
553     '["map", [[0, true], [1, false], [2, true], [3, true], [4, true]]]' \
554     '["map", [[3, false], [0, true], [4, false]]]']],
555   [[["map",[[1,true]]]
556 ["map",[[0,true],[1,false],[2,true],[3,true],[4,true]]]
557 ["map",[[0,true],[3,false],[4,false]]]]])
558
559 OVSDB_CHECK_POSITIVE([string map of at least 1 integer to boolean],
560   [[parse-data-strings '{"key": "integer", "value": "boolean", "max": "unlimited"}' \
561     '1=true' \
562     '0=true 1=false 2=true, 3=true 4=true,' \
563     '3=false,0=true ,4=false']],
564   [[{1=true}
565 {0=true, 1=false, 2=true, 3=true, 4=true}
566 {0=true, 3=false, 4=false}]])
567
568 OVSDB_CHECK_POSITIVE([JSON map of 1 boolean to integer],
569  [[parse-data '{"key": "boolean", "value": "integer"}' \
570    '["map", [[true, 1]]]']],
571  [[["map",[[true,1]]]]])
572
573 OVSDB_CHECK_POSITIVE([string map of 1 boolean to integer],
574  [[parse-data-strings '{"key": "boolean", "value": "integer"}' \
575    'true=1']],
576  [[true=1]])
577
578 OVSDB_CHECK_POSITIVE([JSON map of 1 uuid to real],
579   [[parse-data '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
580     '["map", [[["uuid", "cad8542b-6ee1-486b-971b-7dcbf6e14979"], 1.0],
581               [["uuid", "6b94b968-2702-4f64-9457-314a34d69b8c"], 2.0],
582               [["uuid", "d2c4a168-24de-47eb-a8a3-c1abfc814979"], 3.0],
583               [["uuid", "25bfa475-d072-4f60-8be1-00f48643e9cb"], 4.0],
584               [["uuid", "1c92b8ca-d5e4-4628-a85d-1dc2d099a99a"], 5.0]]]']],
585   [[["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]]]]])
586
587 OVSDB_CHECK_POSITIVE([string map of 1 uuid to real],
588   [[parse-data-strings '{"key": "uuid", "value": "real", "min": 1, "max": 5}' \
589     'cad8542b-6ee1-486b-971b-7dcbf6e14979=1.0,
590      6b94b968-2702-4f64-9457-314a34d69b8c=2.0,
591      d2c4a168-24de-47eb-a8a3-c1abfc814979=3.0,
592      25bfa475-d072-4f60-8be1-00f48643e9cb=4.0,
593      1c92b8ca-d5e4-4628-a85d-1dc2d099a99a=5.0']],
594   [[{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}]])
595
596 OVSDB_CHECK_POSITIVE([JSON map of 10 string to string],
597   [[parse-data '{"key": "string", "value": "string", "min": 1, "max": 10}' \
598     '["map", [["2 gills", "1 chopin"],
599               ["2 chopins", "1 pint"],
600               ["2 pints", "1 quart"],
601               ["2 quarts", "1 pottle"],
602               ["2 pottles", "1 gallon"],
603               ["2 gallons", "1 peck"],
604               ["2 pecks", "1 demibushel"],
605               ["2 demibushel", "1 firkin"],
606               ["2 firkins", "1 kilderkin"],
607               ["2 kilderkins", "1 barrel"]]]']],
608    [[["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"]]]]])
609
610 OVSDB_CHECK_POSITIVE([string map of 10 string to string],
611   [[parse-data-strings '{"key": "string", "value": "string", "min": 1, "max": 10}' \
612     '{"2 gills"="1 chopin",
613       "2 chopins"= "1 pint",
614       "2 pints"= "1 quart",
615       "2 quarts"= "1 pottle",
616       "2 pottles"= "1 gallon",
617       "2 gallons"= "1 peck",
618       "2 pecks"= "1 demibushel",
619       "2 demibushel"= "1 firkin",
620       "2 firkins"= "1 kilderkin",
621       "2 kilderkins"= "1 barrel"}']],
622    [[{"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"}]])
623
624 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in JSON map],
625   [[parse-data '{"key": "integer", "value": "boolean", "max": 5}' \
626     '["map", [[1, true], [2, false], [1, false]]]']],
627   [ovsdb error: map contains duplicate key])
628
629 OVSDB_CHECK_NEGATIVE([duplicate integer key not allowed in string map],
630   [[parse-data-strings '{"key": "integer", "value": "boolean", "max": 5}' \
631     '1=true 2=false 1=false']],
632   [map contains duplicate key])