tests: Rename kmod-testsuite to system-kmod-testsuite.
[cascardo/ovs.git] / tests / system-common-macros.at
1 # DEL_NAMESPACES(ns [, ns ... ])
2 #
3 # Delete namespaces from the running OS
4 m4_define([DEL_NAMESPACES],
5    [m4_foreach([ns], [$@],
6                [ip netns del ns
7 ])
8    ]
9 )
10 #
11 # ADD_NAMESPACES(ns [, ns ... ])
12 #
13 # Add new namespaces, if ns exists, the old one
14 # will be remove before new ones are installed.
15 m4_define([ADD_NAMESPACES],
16    [m4_foreach([ns], [$@],
17                [DEL_NAMESPACES(ns)
18                 AT_CHECK([ip netns add ns])
19                 ON_EXIT(DEL_NAMESPACES(ns))
20                ])
21    ]
22 )
23
24 # ADD_VETH([port], [namespace], [ovs-br], [ip_addr])
25 #
26 # Add a pair of veth ports. 'port' will be added to name space 'namespace',
27 # and "ovs-'port'" will be added to ovs bridge 'ovs-br'.
28 #
29 # The 'port' in 'namespace' will be brought up with static IP address
30 # with 'ip_addr' in CIDR notation.
31 #
32 # The existing 'port' or 'ovs-port' will be removed before new ones are added.
33 #
34 m4_define([ADD_VETH],
35     [ AT_CHECK([ip link add $1 type veth peer name ovs-$1])
36       AT_CHECK([ip link set $1 netns $2])
37       AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
38       AT_CHECK([ip link set dev ovs-$1 up])
39       AT_CHECK([ip netns exec $2 ip addr add $4 dev $1])
40       AT_CHECK([ip netns exec $2 ip link set dev $1 up])
41     ]
42 )
43
44 # ADD_VLAN([port], [namespace], [vlan-id], [ip-addr])
45 #
46 # Add a VLAN device named 'port' within 'namespace'. It will be configured
47 # with the ID 'vlan-id' and the address 'ip-addr'.
48 m4_define([ADD_VLAN],
49     [ AT_CHECK([ip netns exec $2 ip link add link $1 name $1.$3 type vlan id $3])
50       AT_CHECK([ip netns exec $2 ip link set dev $1.$3 up])
51       AT_CHECK([ip netns exec $2 ip addr add dev $1.$3 $4])
52     ]
53 )