1 AT_BANNER([OVSDB -- atomic types])
3 OVSDB_CHECK_POSITIVE([integer],
4 [[parse-atomic-type '["integer"]' ]], ["integer"])
5 OVSDB_CHECK_POSITIVE([real],
6 [[parse-atomic-type '["real"]' ]], ["real"])
7 OVSDB_CHECK_POSITIVE([boolean],
8 [[parse-atomic-type '["boolean"]' ]], ["boolean"])
9 OVSDB_CHECK_POSITIVE([string],
10 [[parse-atomic-type '["string"]' ]], ["string"])
11 OVSDB_CHECK_POSITIVE([uuid],
12 [[parse-atomic-type '["uuid"]' ]], ["uuid"])
13 OVSDB_CHECK_NEGATIVE([void is not a valid atomic-type],
14 [[parse-atomic-type '["void"]' ]], ["void" is not an atomic-type])
16 AT_BANNER([OVSDB -- base types])
18 OVSDB_CHECK_POSITIVE([integer >= 5],
19 [[parse-base-type '{"type": "integer", "minInteger": 5}' ]],
20 [{"minInteger":5,"type":"integer"}])
21 OVSDB_CHECK_POSITIVE([integer <= 7],
22 [[parse-base-type '{"type": "integer", "maxInteger": 7}' ]],
23 [{"maxInteger":7,"type":"integer"}])
24 OVSDB_CHECK_POSITIVE([integer between -5 and 10],
25 [[parse-base-type '{"type": "integer", "minInteger": -5, "maxInteger": 10}']],
26 [{"maxInteger":10,"minInteger":-5,"type":"integer"}])
27 OVSDB_CHECK_NEGATIVE([integer max may not be less than min],
28 [[parse-base-type '{"type": "integer", "minInteger": 5, "maxInteger": 3}']],
29 [minInteger exceeds maxInteger])
31 OVSDB_CHECK_POSITIVE([real >= -1.5],
32 [[parse-base-type '{"type": "real", "minReal": -1.5}']],
33 [{"minReal":-1.5,"type":"real"}])
34 OVSDB_CHECK_POSITIVE([real <= 1e5],
35 [[parse-base-type '{"type": "real", "maxReal": 1e5}']],
36 [{"maxReal":100000,"type":"real"}])
37 OVSDB_CHECK_POSITIVE([real between -2.5 and 3.75],
38 [[parse-base-type '{"type": "real", "minReal": -2.5, "maxReal": 3.75}']],
39 [{"maxReal":3.75,"minReal":-2.5,"type":"real"}])
40 OVSDB_CHECK_NEGATIVE([real max may not be less than min],
41 [[parse-base-type '{"type": "real", "minReal": 555, "maxReal": 444}']],
42 [minReal exceeds maxReal])
44 OVSDB_CHECK_POSITIVE([boolean],
45 [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
47 OVSDB_CHECK_POSITIVE([string reMatch],
48 [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}"}']],
49 [{"reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
50 OVSDB_CHECK_POSITIVE([string reMatch + reComment],
51 [[parse-base-type '{"type": "string", "reMatch": "\\d{3}-\\d{3}-\\d{4}", "reComment": "US-style telephone number"}']],
52 [{"reComment":"US-style telephone number","reMatch":"\\d{3}-\\d{3}-\\d{4}","type":"string"}])
54 AT_SETUP([reMatch must be a valid regexp])
55 AT_KEYWORDS([ovsdb negative])
56 if test "$HAVE_PCRE" = yes; then
58 [[test-ovsdb parse-base-type \
59 '{"type": "string", "reMatch": "x{2,1}"}']],
61 [[test-ovsdb: invalid regular expression: "x{2,1}" is not a valid regular expression: numbers out of order in {} quantifier
65 [[test-ovsdb parse-base-type \
66 '{"type": "string", "reMatch": "x{2,1}"}']],
67 [0], [[{"reMatch":"x{2,1}","type":"string"}
72 OVSDB_CHECK_POSITIVE([string minLength],
73 [[parse-base-type '{"type": "string", "minLength": 1}']],
74 [{"minLength":1,"type":"string"}])
75 OVSDB_CHECK_POSITIVE([string maxLength],
76 [[parse-base-type '{"type": "string", "maxLength": 5}']],
77 [{"maxLength":5,"type":"string"}])
78 OVSDB_CHECK_POSITIVE([string minLength and maxLength],
79 [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
80 [{"maxLength":5,"minLength":1,"type":"string"}])
81 OVSDB_CHECK_NEGATIVE([maxLength must not be less than minLength],
82 [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
83 [minLength exceeds maxLength])
84 OVSDB_CHECK_NEGATIVE([maxLength must not be negative],
85 [[parse-base-type '{"type": "string", "maxLength": -1}']],
86 [maxLength out of valid range 0 to 4294967295])
88 OVSDB_CHECK_POSITIVE([uuid refTable],
89 [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
90 [{"refTable":"myTable","type":"uuid"}])
91 OVSDB_CHECK_NEGATIVE([uuid refTable must be valid id],
92 [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
93 [Type mismatch for member 'refTable'])
95 OVSDB_CHECK_NEGATIVE([void is not a valid base-type],
96 [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
97 OVSDB_CHECK_NEGATIVE(["type" member must be present],
98 [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
100 AT_BANNER([OVSDB -- simple types])
102 OVSDB_CHECK_POSITIVE([simple integer],
103 [[parse-type '["integer"]' ]], ["integer"])
104 OVSDB_CHECK_POSITIVE([simple real],
105 [[parse-type '["real"]' ]], ["real"])
106 OVSDB_CHECK_POSITIVE([simple boolean],
107 [[parse-type '["boolean"]' ]], ["boolean"])
108 OVSDB_CHECK_POSITIVE([simple string],
109 [[parse-type '["string"]' ]], ["string"])
110 OVSDB_CHECK_POSITIVE([simple uuid],
111 [[parse-type '["uuid"]' ]], ["uuid"])
112 OVSDB_CHECK_POSITIVE([integer in object],
113 [[parse-type '{"key": "integer"}' ]], ["integer"])
114 OVSDB_CHECK_POSITIVE([real in object with explicit min and max],
115 [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
117 OVSDB_CHECK_NEGATIVE([key type is required],
118 [[parse-type '{}' ]], [Required 'key' member is missing.])
119 OVSDB_CHECK_NEGATIVE([void is not a valid type],
120 [[parse-type '["void"]' ]], ["void" is not an atomic-type])
122 AT_BANNER([OVSDB -- set types])
124 OVSDB_CHECK_POSITIVE([optional boolean],
125 [[parse-type '{"key": "boolean", "min": 0}' ]],
126 [[{"key":"boolean","min":0}]],
128 OVSDB_CHECK_POSITIVE([set of 1 to 3 uuids],
129 [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]],
130 [[{"key":"uuid","max":3}]])
131 OVSDB_CHECK_POSITIVE([set of 0 to 3 strings],
132 [[parse-type '{"key": "string", "min": 0, "max": 3}' ]],
133 [[{"key":"string","max":3,"min":0}]])
134 OVSDB_CHECK_POSITIVE([set of 0 or more integers],
135 [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
136 [[{"key":"integer","max":"unlimited","min":0}]])
137 OVSDB_CHECK_POSITIVE([set of 1 or more reals],
138 [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
139 [[{"key":"real","max":"unlimited"}]])
141 OVSDB_CHECK_NEGATIVE([set max cannot be less than min],
142 [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
143 [ovsdb type fails constraint checks])
144 OVSDB_CHECK_NEGATIVE([set max cannot be negative],
145 [[parse-type '{"key": "real", "max": -1}' ]],
146 [bad min or max value])
147 OVSDB_CHECK_NEGATIVE([set min cannot be negative],
148 [[parse-type '{"key": "real", "min": -1}' ]],
149 [bad min or max value])
150 OVSDB_CHECK_NEGATIVE([set min cannot be greater than one],
151 [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
152 [ovsdb type fails constraint checks])
154 AT_BANNER([OVSDB -- map types])
156 OVSDB_CHECK_POSITIVE([map of 1 integer to boolean],
157 [[parse-type '{"key": "integer", "value": "boolean"}' ]],
158 [[{"key":"integer","value":"boolean"}]])
159 OVSDB_CHECK_POSITIVE([map of 1 boolean to integer, explicit min and max],
160 [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
161 [[{"key":"boolean","value":"integer"}]])
162 OVSDB_CHECK_POSITIVE([map of 1 to 5 uuid to real],
163 [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
164 [[{"key":"uuid","max":5,"value":"real"}]])
165 OVSDB_CHECK_POSITIVE([map of 0 to 10 string to uuid],
166 [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
167 [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
168 OVSDB_CHECK_POSITIVE([map of 1 to 20 real to string],
169 [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
170 [[{"key":"real","max":20,"value":"string"}]])
171 OVSDB_CHECK_POSITIVE([map of 0 or more string to real],
172 [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
173 [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
175 OVSDB_CHECK_NEGATIVE([map key type is required],
176 [[parse-type '{"value": "integer"}' ]],
177 [Required 'key' member is missing.])