[ovs-dev] [PATCHv7 2/2] tests: Add tests using tap device.

William Tu u9012063 at gmail.com
Tue Mar 17 20:02:09 UTC 2020


Similar to using veth across namespaces, this patch creates
tap devices, assigns to namespaces, and allows traffic to
go through different test cases.

Signed-off-by: William Tu <u9012063 at gmail.com>
---
 tests/automake.mk             |  1 +
 tests/system-tap.at           | 34 ++++++++++++++++++++++++++++++++++
 tests/system-tso-testsuite.at |  1 +
 3 files changed, 36 insertions(+)
 create mode 100644 tests/system-tap.at

diff --git a/tests/automake.mk b/tests/automake.mk
index 66859d5377c3..cbba5b170427 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -158,6 +158,7 @@ SYSTEM_USERSPACE_TESTSUITE_AT = \
 
 SYSTEM_TSO_TESTSUITE_AT = \
 	tests/system-tso-testsuite.at \
+	tests/system-tap.at \
 	tests/system-tso-macros.at
 
 SYSTEM_AFXDP_TESTSUITE_AT = \
diff --git a/tests/system-tap.at b/tests/system-tap.at
new file mode 100644
index 000000000000..871a3bda4fcc
--- /dev/null
+++ b/tests/system-tap.at
@@ -0,0 +1,34 @@
+AT_SETUP([traffic between namespaces using tap])
+AT_KEYWORDS([http_tap])
+OVS_TRAFFIC_VSWITCHD_START()
+AT_SKIP_IF([test $HAVE_TUNCTL = no])
+
+AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"])
+
+ADD_NAMESPACES(at_ns0, at_ns1)
+
+AT_CHECK([ip tuntap add tap0 mode tap])
+on_exit 'ip tuntap del tap0 mode tap'
+AT_CHECK([ip tuntap add tap1 mode tap])
+on_exit 'ip tuntap del tap1 mode tap'
+
+AT_CHECK([ovs-vsctl add-port br0 tap0 -- set int tap0 type=tap])
+AT_CHECK([ovs-vsctl add-port br0 tap1 -- set int tap1 type=tap])
+AT_CHECK([ip link set tap0 netns at_ns0])
+AT_CHECK([ip link set tap1 netns at_ns1])
+
+AT_CHECK([ip netns exec at_ns0 ip link set dev tap0 up])
+AT_CHECK([ip netns exec at_ns1 ip link set dev tap1 up])
+AT_CHECK([ip netns exec at_ns0 ip addr add 10.1.1.1/24 dev tap0])
+AT_CHECK([ip netns exec at_ns1 ip addr add 10.1.1.2/24 dev tap1])
+
+NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl
+3 packets transmitted, 3 received, 0% packet loss, time 0ms
+])
+
+OVS_START_L7([at_ns1], [http])
+NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log])
+
+OVS_TRAFFIC_VSWITCHD_STOP(["/.*ethtool command ETHTOOL_G.*/d"])
+
+AT_CLEANUP
diff --git a/tests/system-tso-testsuite.at b/tests/system-tso-testsuite.at
index 99d748006a86..594d1a6fde85 100644
--- a/tests/system-tso-testsuite.at
+++ b/tests/system-tso-testsuite.at
@@ -23,4 +23,5 @@ m4_include([tests/system-common-macros.at])
 m4_include([tests/system-userspace-macros.at])
 m4_include([tests/system-tso-macros.at])
 
+m4_include([tests/system-tap.at])
 m4_include([tests/system-traffic.at])
-- 
2.7.4



More information about the dev mailing list