netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / tests / ovsdb-types.at
1 AT_BANNER([OVSDB -- atomic types])
2
3 OVSDB_CHECK_POSITIVE_CPY([integer], 
4   [[parse-atomic-type '["integer"]' ]], ["integer"])
5 OVSDB_CHECK_POSITIVE_CPY([real], 
6   [[parse-atomic-type '["real"]' ]], ["real"])
7 OVSDB_CHECK_POSITIVE_CPY([boolean], 
8   [[parse-atomic-type '["boolean"]' ]], ["boolean"])
9 OVSDB_CHECK_POSITIVE_CPY([string], 
10   [[parse-atomic-type '["string"]' ]], ["string"])
11 OVSDB_CHECK_POSITIVE_CPY([uuid], 
12   [[parse-atomic-type '["uuid"]' ]], ["uuid"])
13 OVSDB_CHECK_NEGATIVE_CPY([void is not a valid atomic-type],
14   [[parse-atomic-type '["void"]' ]], ["void" is not an atomic-type])
15
16 AT_BANNER([OVSDB -- base types])
17
18 OVSDB_CHECK_POSITIVE_CPY([integer enum],
19   [[parse-base-type '{"type": "integer", "enum": ["set", [-1, 4, 5]]}' ]],
20   [[{"enum":["set",[-1,4,5]],"type":"integer"}]])
21 OVSDB_CHECK_POSITIVE_CPY([integer >= 5], 
22   [[parse-base-type '{"type": "integer", "minInteger": 5}' ]],
23   [{"minInteger":5,"type":"integer"}])
24 OVSDB_CHECK_POSITIVE_CPY([integer <= 7], 
25   [[parse-base-type '{"type": "integer", "maxInteger": 7}' ]],
26   [{"maxInteger":7,"type":"integer"}])
27 OVSDB_CHECK_POSITIVE_CPY([integer between -5 and 10], 
28   [[parse-base-type '{"type": "integer", "minInteger": -5, "maxInteger": 10}']],
29   [{"maxInteger":10,"minInteger":-5,"type":"integer"}])
30 OVSDB_CHECK_NEGATIVE_CPY([integer max may not be less than min],
31   [[parse-base-type '{"type": "integer", "minInteger": 5, "maxInteger": 3}']],
32   [minInteger exceeds maxInteger])
33
34 OVSDB_CHECK_POSITIVE_CPY([real enum],
35   [[parse-base-type '{"type": "real", "enum": ["set", [1.5, 0, 2.75]]}' ]],
36   [[{"enum":["set",[0,1.5,2.75]],"type":"real"}]])
37 OVSDB_CHECK_POSITIVE_CPY([real >= -1.5], 
38   [[parse-base-type '{"type": "real", "minReal": -1.5}']],
39   [{"minReal":-1.5,"type":"real"}])
40 OVSDB_CHECK_POSITIVE_CPY([real <= 1e5], 
41   [[parse-base-type '{"type": "real", "maxReal": 1e5}']],
42   [{"maxReal":100000,"type":"real"}])
43 OVSDB_CHECK_POSITIVE_CPY([real between -2.5 and 3.75], 
44   [[parse-base-type '{"type": "real", "minReal": -2.5, "maxReal": 3.75}']],
45   [{"maxReal":3.75,"minReal":-2.5,"type":"real"}])
46 OVSDB_CHECK_NEGATIVE_CPY([real max may not be less than min], 
47   [[parse-base-type '{"type": "real", "minReal": 555, "maxReal": 444}']],
48   [minReal exceeds maxReal])
49
50 OVSDB_CHECK_POSITIVE_CPY([boolean], 
51   [[parse-base-type '[{"type": "boolean"}]' ]], ["boolean"])
52 OVSDB_CHECK_POSITIVE_CPY([boolean enum],
53   [[parse-base-type '{"type": "boolean", "enum": true}' ]],
54   [[{"enum":true,"type":"boolean"}]])
55
56 OVSDB_CHECK_POSITIVE_CPY([string enum], 
57   [[parse-base-type '{"type": "string", "enum": ["set", ["def", "abc"]]}']],
58   [[{"enum":["set",["abc","def"]],"type":"string"}]])
59 OVSDB_CHECK_POSITIVE_CPY([string minLength], 
60   [[parse-base-type '{"type": "string", "minLength": 1}']],
61   [{"minLength":1,"type":"string"}])
62 OVSDB_CHECK_POSITIVE_CPY([string maxLength], 
63   [[parse-base-type '{"type": "string", "maxLength": 5}']],
64   [{"maxLength":5,"type":"string"}])
65 OVSDB_CHECK_POSITIVE_CPY([string minLength and maxLength], 
66   [[parse-base-type '{"type": "string", "minLength": 1, "maxLength": 5}']],
67   [{"maxLength":5,"minLength":1,"type":"string"}])
68 OVSDB_CHECK_NEGATIVE_CPY([maxLength must not be less than minLength], 
69   [[parse-base-type '{"type": "string", "minLength": 5, "maxLength": 3}']],
70   [minLength exceeds maxLength])
71 OVSDB_CHECK_NEGATIVE_CPY([maxLength must not be negative], 
72   [[parse-base-type '{"type": "string", "maxLength": -1}']],
73   [maxLength out of valid range 0 to 4294967295])
74
75 OVSDB_CHECK_POSITIVE_CPY([uuid enum], 
76   [[parse-base-type '{"type": "uuid", "enum": ["uuid", "36bf19c0-ad9d-4232-bb85-b3d73dfe2123"]}' ]],
77   [[{"enum":["uuid","36bf19c0-ad9d-4232-bb85-b3d73dfe2123"],"type":"uuid"}]])
78 OVSDB_CHECK_POSITIVE_CPY([uuid refTable], 
79   [[parse-base-type '{"type": "uuid", "refTable": "myTable"}' ]],
80   [{"refTable":"myTable","type":"uuid"}])
81 OVSDB_CHECK_NEGATIVE_CPY([uuid refTable must be valid id], 
82   [[parse-base-type '{"type": "uuid", "refTable": "a-b-c"}' ]],
83   [Type mismatch for member 'refTable'])
84
85 OVSDB_CHECK_NEGATIVE_CPY([void is not a valid base-type],
86   [[parse-base-type '["void"]' ]], ["void" is not an atomic-type])
87 OVSDB_CHECK_NEGATIVE_CPY(["type" member must be present],
88   [[parse-base-type '{}']], [Parsing ovsdb type failed: Required 'type' member is missing.])
89
90 AT_BANNER([OVSDB -- simple types])
91
92 OVSDB_CHECK_POSITIVE_CPY([simple integer], 
93   [[parse-type '["integer"]' ]], ["integer"])
94 OVSDB_CHECK_POSITIVE_CPY([simple real], 
95   [[parse-type '["real"]' ]], ["real"])
96 OVSDB_CHECK_POSITIVE_CPY([simple boolean], 
97   [[parse-type '["boolean"]' ]], ["boolean"])
98 OVSDB_CHECK_POSITIVE_CPY([simple string], 
99   [[parse-type '["string"]' ]], ["string"])
100 OVSDB_CHECK_POSITIVE_CPY([simple uuid], 
101   [[parse-type '["uuid"]' ]], ["uuid"])
102 OVSDB_CHECK_POSITIVE_CPY([integer in object],
103   [[parse-type '{"key": "integer"}' ]], ["integer"])
104 OVSDB_CHECK_POSITIVE_CPY([real in object with explicit min and max],
105   [[parse-type '{"key": "real", "min": 1, "max": 1}' ]], ["real"])
106
107 OVSDB_CHECK_NEGATIVE_CPY([key type is required],
108   [[parse-type '{}' ]], [Required 'key' member is missing.])
109 OVSDB_CHECK_NEGATIVE_CPY([void is not a valid type],
110   [[parse-type '["void"]' ]], ["void" is not an atomic-type])
111
112 AT_BANNER([OVSDB -- set types])
113
114 OVSDB_CHECK_POSITIVE_CPY([optional boolean],
115   [[parse-type '{"key": "boolean", "min": 0}' ]], 
116   [[{"key":"boolean","min":0}]],
117   [set])
118 OVSDB_CHECK_POSITIVE_CPY([set of 1 to 3 uuids],
119   [[parse-type '{"key": "uuid", "min": 1, "max": 3}' ]], 
120   [[{"key":"uuid","max":3}]])
121 OVSDB_CHECK_POSITIVE_CPY([set of 0 to 3 strings],
122   [[parse-type '{"key": "string", "min": 0, "max": 3}' ]], 
123   [[{"key":"string","max":3,"min":0}]])
124 OVSDB_CHECK_POSITIVE_CPY([set of 0 or more integers],
125   [[parse-type '{"key": "integer", "min": 0, "max": "unlimited"}']],
126   [[{"key":"integer","max":"unlimited","min":0}]])
127 OVSDB_CHECK_POSITIVE_CPY([set of 1 or more reals],
128   [[parse-type '{"key": "real", "min": 1, "max": "unlimited"}']],
129   [[{"key":"real","max":"unlimited"}]])
130
131 OVSDB_CHECK_NEGATIVE_CPY([set max cannot be less than min],
132   [[parse-type '{"key": "real", "min": 5, "max": 3}' ]],
133   [ovsdb type fails constraint checks])
134 OVSDB_CHECK_NEGATIVE_CPY([set max cannot be negative],
135   [[parse-type '{"key": "real", "max": -1}' ]],
136   [bad min or max value])
137 OVSDB_CHECK_NEGATIVE_CPY([set min cannot be negative],
138   [[parse-type '{"key": "real", "min": -1}' ]],
139   [bad min or max value])
140 OVSDB_CHECK_NEGATIVE_CPY([set min cannot be greater than one],
141   [[parse-type '{"key": "real", "min": 10, "max": "unlimited"}']],
142   [ovsdb type fails constraint checks])
143
144 AT_BANNER([OVSDB -- map types])
145
146 OVSDB_CHECK_POSITIVE_CPY([map of 1 integer to boolean],
147  [[parse-type '{"key": "integer", "value": "boolean"}' ]],
148  [[{"key":"integer","value":"boolean"}]])
149 OVSDB_CHECK_POSITIVE_CPY([map of 1 boolean to integer, explicit min and max],
150  [[parse-type '{"key": "boolean", "value": "integer", "min": 1, "max": 1}' ]],
151  [[{"key":"boolean","value":"integer"}]])
152 OVSDB_CHECK_POSITIVE_CPY([map of 1 to 5 uuid to real],
153  [[parse-type '{"key": "uuid", "value": "real", "min": 1, "max": 5}' ]],
154  [[{"key":"uuid","max":5,"value":"real"}]])
155 OVSDB_CHECK_POSITIVE_CPY([map of 0 to 10 string to uuid],
156  [[parse-type '{"key": "string", "value": "uuid", "min": 0, "max": 10}' ]],
157  [[{"key":"string","max":10,"min":0,"value":"uuid"}]])
158 OVSDB_CHECK_POSITIVE_CPY([map of 1 to 20 real to string],
159  [[parse-type '{"key": "real", "value": "string", "min": 1, "max": 20}' ]],
160  [[{"key":"real","max":20,"value":"string"}]])
161 OVSDB_CHECK_POSITIVE_CPY([map of 0 or more string to real],
162  [[parse-type '{"key": "string", "value": "real", "min": 0, "max": "unlimited"}' ]],
163  [[{"key":"string","max":"unlimited","min":0,"value":"real"}]])
164
165 OVSDB_CHECK_NEGATIVE_CPY([map key type is required],
166  [[parse-type '{"value": "integer"}' ]],
167  [Required 'key' member is missing.])