tests: Define new ADD_OF_PORTS macro for ofproto tests.
authorJustin Pettit <jpettit@nicira.com>
Thu, 4 Oct 2012 07:51:41 +0000 (00:51 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 2 Nov 2012 05:54:27 +0000 (22:54 -0700)
A future commit will break the relation between OpenFlow and datapath
port numbers.  The new ADD_OF_PORTS macro adds an interface to a bridge
and configures it such that both the OpenFlow and datapath port numbers
are the same.  This is important in tests that deal with both OpenFlow
and datapath port numbers (e.g., ones that use ofproto/trace).

Signed-off-by: Justin Pettit <jpettit@nicira.com>
tests/ofproto-dpif.at
tests/ofproto-macros.at

index 8920d6f..01132be 100644 (file)
@@ -2,6 +2,8 @@ AT_BANNER([ofproto-dpif])
 
 AT_SETUP([ofproto-dpif - resubmit])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [10], [11], [12], [13], [14], [15],
+                    [16], [17], [18], [19], [20], [21])
 AT_DATA([flows.txt], [dnl
 table=0 in_port=1 priority=1000 icmp actions=output(10),resubmit(2),output(19),resubmit(3),output(21)
 table=0 in_port=2 priority=1500 icmp actions=output(11),resubmit(,1),output(16),resubmit(2,1),output(18)
@@ -20,6 +22,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - registers])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [20], [21], [22], [33], [90])
 AT_DATA([flows.txt], [dnl
 in_port=90                 actions=resubmit:2,resubmit:3,resubmit:4,resubmit:91
 in_port=91                 actions=resubmit:5,resubmit:6,resubmit:7,resubmit:92
@@ -53,6 +56,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - output])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [9], [10], [11], [55], [66], [77], [88])
 AT_DATA([flows.txt], [dnl
 in_port=1 actions=resubmit:2,resubmit:3,resubmit:4,resubmit:5,resubmit:6,resubmit:7
 in_port=2 actions=output:9
@@ -72,6 +76,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - dec_ttl])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [4])
 AT_DATA([flows.txt], [dnl
 table=0 in_port=1 action=dec_ttl,output:2,resubmit(1,1),output:4
 table=1 in_port=1 action=dec_ttl,output:3
@@ -151,14 +156,8 @@ OVS_VSWITCHD_STOP
 AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - output/flood flags])
-OVS_VSWITCHD_START([dnl
-        add-port br0 p1 -- set Interface p1 type=dummy --\
-        add-port br0 p2 -- set Interface p2 type=dummy --\
-        add-port br0 p3 -- set Interface p3 type=dummy --\
-        add-port br0 p4 -- set Interface p4 type=dummy --\
-        add-port br0 p5 -- set Interface p5 type=dummy --\
-        add-port br0 p6 -- set Interface p6 type=dummy --\
-        add-port br0 p7 -- set Interface p7 type=dummy ])
+OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [4], [5], [6], [7])
 
 AT_DATA([flows.txt], [dnl
 in_port=local actions=local,flood
@@ -216,6 +215,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - set_tunnel])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [4], [5], [90])
 AT_DATA([flows.txt], [dnl
 in_port=90 actions=resubmit:1,resubmit:2,resubmit:3,resubmit:4,resubmit:5
 in_port=1 actions=set_tunnel:1,output:1
@@ -537,6 +537,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - fragment handling])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [4], [5], [6])
 AT_DATA([flows.txt], [dnl
 priority=75 tcp ip_frag=no    tp_dst=80 actions=output:1
 priority=75 tcp ip_frag=first tp_dst=80 actions=output:2
@@ -577,6 +578,7 @@ AT_CLEANUP
 
 AT_SETUP([ofproto-dpif - exit])
 OVS_VSWITCHD_START
+ADD_OF_PORTS([br0], [1], [2], [3], [10], [11], [12], [13], [14])
 AT_DATA([flows.txt], [dnl
 in_port=1 actions=output:10,exit,output:11
 in_port=2 actions=output:12,resubmit:1,output:12
index 52f19fc..8b8de15 100644 (file)
@@ -66,3 +66,14 @@ m4_define([OVS_VSWITCHD_START],
 m4_define([OVS_VSWITCHD_STOP],
   [AT_CHECK([ovs-appctl -t ovs-vswitchd exit])
    AT_CHECK([ovs-appctl -t ovsdb-server exit])])
+
+# ADD_OF_PORTS(BRIDGE, OF_PORT[, OF_PORT...])
+#
+# Creates a dummy interface with an OpenFlow port number of OF_PORT and
+# name of p{OF_PORT}.  The dummy implementation will treat the OF_PORT
+# as the datapath port number, which as the effect of making the
+# OpenFlow and datapath numbers the same.
+m4_define([ADD_OF_PORTS],
+ [ovs-vsctl m4_foreach([of_port], m4_cdr($@),
+    [ \
+    -- add-port $1 p[]of_port -- set Interface p[]of_port type=dummy ofport_request=of_port])])