1 dnl RUN_OVS_VSCTL(COMMAND, ...)
3 dnl Executes each ovs-vsctl COMMAND on a file named "conf" in the
4 dnl current directory. Creates "conf" if it does not already exist.
5 m4_define([RUN_OVS_VSCTL],
7 m4_foreach([command], [$@], [ovs-vsctl --no-reload --config=conf command
10 dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
12 dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
13 dnl which must be in alphabetical order. Also checks that each BRIDGE has the
14 dnl specified PARENT and is on the given VLAN.
15 m4_define([_CHECK_BRIDGE],
16 [AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2
18 AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3
20 m4_define([CHECK_BRIDGES],
21 [dnl Check that the bridges appear on list-br.
23 [RUN_OVS_VSCTL([list-br])],
25 [m4_foreach([brinfo], [$@], [m4_car(brinfo)
28 dnl Check that each bridge exists according to br-exists and that
29 dnl a bridge that should not exist does not.
30 m4_foreach([brinfo], [$@],
31 [AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])])])
32 AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2])
34 dnl Check that each bridge has the expected parent and VLAN.
35 m4_map([_CHECK_BRIDGE], [$@])])
37 dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
39 dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
40 dnl list of ports, which must be in alphabetical order. Also checks
41 dnl that "ovs-vsctl port-to-br" reports that each port is
43 m4_define([CHECK_PORTS],
45 [RUN_OVS_VSCTL([list-ports $1])],
47 [m4_foreach([port], m4_cdr($@), [port
49 AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [], [ovs-vsctl: no port named $1
53 [AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
56 dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
58 dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
59 dnl list of ifaces, which must be in alphabetical order. Also checks
60 dnl that "ovs-vsctl iface-to-br" reports that each interface is
62 m4_define([CHECK_IFACES],
64 [RUN_OVS_VSCTL([list-ifaces $1])],
66 [m4_foreach([iface], m4_cdr($@), [iface
68 AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [], [ovs-vsctl: no interface named $1
72 [AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
75 dnl ----------------------------------------------------------------------
76 AT_BANNER([ovs-vsctl unit tests -- real bridges])
79 AT_KEYWORDS([ovs-vsctl])
80 AT_CHECK([RUN_OVS_VSCTL([add-br a])])
81 AT_CHECK([cat conf], [0], [dnl
84 CHECK_BRIDGES([a, a, 0])
89 AT_SETUP([add-br a, add-br b])
90 AT_KEYWORDS([ovs-vsctl])
91 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])])
92 AT_CHECK([cat conf], [0], [dnl
96 CHECK_BRIDGES([a, a, 0], [b, b, 0])
103 AT_SETUP([add-br a, add-br b, del-br a])
104 AT_KEYWORDS([ovs-vsctl])
105 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])])
106 AT_CHECK([cat conf], [0], [dnl
109 CHECK_BRIDGES([b, b, 0])
114 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
115 AT_KEYWORDS([ovs-vsctl])
116 AT_CHECK([RUN_OVS_VSCTL(
122 AT_CHECK([cat conf], [0],
126 CHECK_BRIDGES([b, b, 0])
127 CHECK_PORTS([b], [b1])
128 CHECK_IFACES([b], [b1])
131 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
132 AT_KEYWORDS([ovs-vsctl])
133 AT_CHECK([RUN_OVS_VSCTL(
135 [add-bond a bond0 a1 a2 a3])])
136 AT_CHECK([cat conf], [0], [dnl
137 bonding.bond0.slave=a1
138 bonding.bond0.slave=a2
139 bonding.bond0.slave=a3
143 CHECK_BRIDGES([a, a, 0])
144 CHECK_PORTS([a], [bond0])
145 CHECK_IFACES([a], [a1], [a2], [a3])
148 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
149 AT_KEYWORDS([ovs-vsctl])
150 AT_CHECK([RUN_OVS_VSCTL(
156 AT_CHECK([cat conf], [0], [dnl
161 CHECK_BRIDGES([a, a, 0], [b, b, 0])
164 CHECK_PORTS([b], [b1])
165 CHECK_IFACES([b], [b1])
168 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port a bond0])
169 AT_KEYWORDS([ovs-vsctl])
170 AT_CHECK([RUN_OVS_VSCTL(
172 [add-bond a bond0 a1 a2 a3],
173 [del-port a bond0])])
174 AT_CHECK([cat conf], [0], [dnl
177 CHECK_BRIDGES([a, a, 0])
181 dnl ----------------------------------------------------------------------
182 AT_BANNER([ovs-vsctl unit tests -- fake bridges])
184 m4_define([SIMPLE_FAKE_CONF], [dnl
185 bridge.xenbr0.port=eth0
186 bridge.xenbr0.port=eth0.9
187 bridge.xenbr0.port=xapi1
188 bridge.xenbr0.port=xenbr0
189 iface.xapi1.fake-bridge=true
190 iface.xapi1.internal=true
195 AT_SETUP([simple fake bridge])
196 AT_KEYWORDS([ovs-vsctl fake-bridge])
197 AT_CHECK([RUN_OVS_VSCTL(
199 [add-port xenbr0 eth0],
200 [add-br xapi1 xenbr0 9],
201 [add-port xapi1 eth0.9])])
202 AT_CHECK([cat conf], [0], [SIMPLE_FAKE_CONF])
203 CHECK_BRIDGES([xenbr0, xenbr0, 0], [xapi1, xenbr0, 9])
204 CHECK_PORTS([xenbr0], [eth0])
205 CHECK_IFACES([xenbr0], [eth0])
206 CHECK_PORTS([xapi1], [eth0.9])
207 CHECK_IFACES([xapi1], [eth0.9])
210 AT_SETUP([simple fake bridge + del-br fake bridge])
211 AT_KEYWORDS([ovs-vsctl fake-bridge])
212 AT_DATA([conf], [SIMPLE_FAKE_CONF])
213 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
214 AT_CHECK([cat conf], [0], [dnl
215 bridge.xenbr0.port=eth0
216 bridge.xenbr0.port=xenbr0
218 CHECK_BRIDGES([xenbr0, xenbr0, 0])
219 CHECK_PORTS([xenbr0], [eth0])
220 CHECK_IFACES([xenbr0], [eth0])
223 AT_SETUP([simple fake bridge + del-br real bridge])
224 AT_KEYWORDS([ovs-vsctl fake-bridge])
225 AT_DATA([conf], [SIMPLE_FAKE_CONF])
226 AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])])
227 AT_CHECK([cat conf], [0], [])
231 m4_define([BOND_FAKE_CONF], [dnl
232 bonding.bond0.slave=eth0
233 bonding.bond0.slave=eth1
234 bridge.xapi1.port=bond0
235 bridge.xapi1.port=bond0.11
236 bridge.xapi1.port=xapi1
237 bridge.xapi1.port=xapi2
238 iface.xapi2.fake-bridge=true
239 iface.xapi2.internal=true
244 AT_SETUP([fake bridge on bond])
245 AT_KEYWORDS([ovs-vsctl fake-bridge])
246 AT_CHECK([RUN_OVS_VSCTL(
248 [add-bond xapi1 bond0 eth0 eth1],
249 [add-br xapi2 xapi1 11],
250 [add-port xapi2 bond0.11])])
251 AT_CHECK([cat conf], [0], [BOND_FAKE_CONF])
252 CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
253 CHECK_PORTS([xapi1], [bond0])
254 CHECK_IFACES([xapi1], [eth0], [eth1])
255 CHECK_PORTS([xapi2], [bond0.11])
256 CHECK_IFACES([xapi2], [bond0.11])
259 AT_SETUP([fake bridge on bond + del-br fake bridge])
260 AT_KEYWORDS([ovs-vsctl fake-bridge])
261 AT_DATA([conf], [BOND_FAKE_CONF])
262 AT_CHECK([RUN_OVS_VSCTL([del-br xapi2])])
263 CHECK_BRIDGES([xapi1, xapi1, 0])
264 CHECK_PORTS([xapi1], [bond0])
265 CHECK_IFACES([xapi1], [eth0], [eth1])
268 AT_SETUP([fake bridge on bond + del-br real bridge])
269 AT_KEYWORDS([ovs-vsctl fake-bridge])
270 AT_DATA([conf], [BOND_FAKE_CONF])
271 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])