kmod-macros: Move some code to traffic-common-macros.
authorDaniele Di Proietto <diproiettod@vmware.com>
Tue, 4 Aug 2015 18:00:16 +0000 (19:00 +0100)
committerJoe Stringer <joestringer@nicira.com>
Fri, 7 Aug 2015 18:09:57 +0000 (11:09 -0700)
These macros will also be used by userspace datapath testing in
following commits. No functional change in this commit.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Joe Stringer <joestringer@nicira.com>
tests/automake.mk
tests/kmod-macros.at
tests/kmod-testsuite.at
tests/traffic-common-macros.at [new file with mode: 0644]

index c2ef9a4..502bbd5 100644 (file)
@@ -88,6 +88,7 @@ TESTSUITE_AT = \
 KMOD_TESTSUITE_AT = \
        tests/kmod-testsuite.at \
        tests/kmod-macros.at \
+       tests/traffic-common-macros.at \
        tests/traffic.at
 
 TESTSUITE = $(srcdir)/tests/testsuite
index eef1263..902f8e1 100644 (file)
@@ -34,57 +34,3 @@ m4_define([OVS_KMOD_VSWITCHD_STOP],
    AT_CHECK([:; $2])
    AT_CHECK([modprobe -r openvswitch])
   ])
-
-# DEL_NAMESPACES(ns [, ns ... ])
-#
-# Delete namespaces from the running OS
-m4_define([DEL_NAMESPACES],
-   [m4_foreach([ns], [$@],
-               [ip netns del ns
-])
-   ]
-)
-#
-# ADD_NAMESPACES(ns [, ns ... ])
-#
-# Add new namespaces, if ns exists, the old one
-# will be remove before new ones are installed.
-m4_define([ADD_NAMESPACES],
-   [m4_foreach([ns], [$@],
-               [DEL_NAMESPACES(ns)
-                AT_CHECK([ip netns add ns])
-                ON_EXIT(DEL_NAMESPACES(ns))
-               ])
-   ]
-)
-
-# ADD_VETH([port], [namespace], [ovs-br], [ip_addr])
-#
-# Add a pair of veth ports. 'port' will be added to name space 'namespace',
-# and "ovs-'port'" will be added to ovs bridge 'ovs-br'.
-#
-# The 'port' in 'namespace' will be brought up with static IP address
-# with 'ip_addr' in CIDR notation.
-#
-# The existing 'port' or 'ovs-port' will be removed before new ones are added.
-#
-m4_define([ADD_VETH],
-    [ AT_CHECK([ip link add $1 type veth peer name ovs-$1])
-      AT_CHECK([ip link set $1 netns $2])
-      AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
-      AT_CHECK([ip link set dev ovs-$1 up])
-      AT_CHECK([ip netns exec $2 ip addr add $4 dev $1])
-      AT_CHECK([ip netns exec $2 ip link set dev $1 up])
-    ]
-)
-
-# ADD_VLAN([port], [namespace], [vlan-id], [ip-addr])
-#
-# Add a VLAN device named 'port' within 'namespace'. It will be configured
-# with the ID 'vlan-id' and the address 'ip-addr'.
-m4_define([ADD_VLAN],
-    [ AT_CHECK([ip netns exec $2 ip link add link $1 name $1.$3 type vlan id $3])
-      AT_CHECK([ip netns exec $2 ip link set dev $1.$3 up])
-      AT_CHECK([ip netns exec $2 ip addr add dev $1.$3 $4])
-    ]
-)
index bd59629..dd3018f 100644 (file)
@@ -18,5 +18,6 @@ m4_include([tests/ovs-macros.at])
 m4_include([tests/ovsdb-macros.at])
 m4_include([tests/ofproto-macros.at])
 m4_include([tests/kmod-macros.at])
+m4_include([tests/traffic-common-macros.at])
 
 m4_include([tests/traffic.at])
diff --git a/tests/traffic-common-macros.at b/tests/traffic-common-macros.at
new file mode 100644 (file)
index 0000000..bd622d2
--- /dev/null
@@ -0,0 +1,53 @@
+# DEL_NAMESPACES(ns [, ns ... ])
+#
+# Delete namespaces from the running OS
+m4_define([DEL_NAMESPACES],
+   [m4_foreach([ns], [$@],
+               [ip netns del ns
+])
+   ]
+)
+#
+# ADD_NAMESPACES(ns [, ns ... ])
+#
+# Add new namespaces, if ns exists, the old one
+# will be remove before new ones are installed.
+m4_define([ADD_NAMESPACES],
+   [m4_foreach([ns], [$@],
+               [DEL_NAMESPACES(ns)
+                AT_CHECK([ip netns add ns])
+                ON_EXIT(DEL_NAMESPACES(ns))
+               ])
+   ]
+)
+
+# ADD_VETH([port], [namespace], [ovs-br], [ip_addr])
+#
+# Add a pair of veth ports. 'port' will be added to name space 'namespace',
+# and "ovs-'port'" will be added to ovs bridge 'ovs-br'.
+#
+# The 'port' in 'namespace' will be brought up with static IP address
+# with 'ip_addr' in CIDR notation.
+#
+# The existing 'port' or 'ovs-port' will be removed before new ones are added.
+#
+m4_define([ADD_VETH],
+    [ AT_CHECK([ip link add $1 type veth peer name ovs-$1])
+      AT_CHECK([ip link set $1 netns $2])
+      AT_CHECK([ovs-vsctl add-port $3 ovs-$1])
+      AT_CHECK([ip link set dev ovs-$1 up])
+      AT_CHECK([ip netns exec $2 ip addr add $4 dev $1])
+      AT_CHECK([ip netns exec $2 ip link set dev $1 up])
+    ]
+)
+
+# ADD_VLAN([port], [namespace], [vlan-id], [ip-addr])
+#
+# Add a VLAN device named 'port' within 'namespace'. It will be configured
+# with the ID 'vlan-id' and the address 'ip-addr'.
+m4_define([ADD_VLAN],
+    [ AT_CHECK([ip netns exec $2 ip link add link $1 name $1.$3 type vlan id $3])
+      AT_CHECK([ip netns exec $2 ip link set dev $1.$3 up])
+      AT_CHECK([ip netns exec $2 ip addr add dev $1.$3 $4])
+    ]
+)