test-ovsdb: Fix memory leak reported by valgrind.
[cascardo/ovs.git] / tests / ofproto-macros.at
index 9b52cae..c6c3321 100644 (file)
@@ -225,17 +225,29 @@ ovn_populate_arp() {
         for e2 in $arp_table; do
             set `echo $e2 | sed 's/,/ /g'`; sb2=$1 br2=$2
             if test $sb1,$br1 != $sb2,$br2; then
-                as $sb2 ovs-appctl tnl/arp/set $br2 $ip $mac
+                as $sb2 ovs-appctl tnl/neigh/set $br2 $ip $mac
             fi
         done
     done
 }
+
+# Strips 'xid=0x1234' from ovs-ofctl output.
+strip_xids () {
+    sed 's/ (xid=0x[[0-9a-fA-F]]*)//'
+}
+
+# Changes all 'used:...' to say 'used:0.0', to make output easier to compare.
+strip_used () {
+    sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/'
+}
+
+# Strips 'ufid:...' from output, to make it easier to compare.
+# (ufids are random.)
+strip_ufid () {
+    sed 's/ufid:[[-0-9a-f]]* //'
+}
 m4_divert_pop([PREPARE_TESTS])
 
-m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']])
-m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']])
-m4_define([STRIP_USED], [[sed 's/used:[0-9]\.[0-9]*/used:0.0/']])
-m4_define([STRIP_UFID], [[sed 's/ufid:[-0-9a-f]* //']])
 m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m'])
 
 # _OVS_VSWITCHD_START([vswitchd-aux-args])
@@ -316,6 +328,21 @@ check_logs () {
 /|ERR|/p
 /|EMER|/p" ${logs}
 }
+
+# add_of_ports BRIDGE PNUM...
+#
+# Creates dummy interfaces in BRIDGE named pPNUM, OpenFlow port number
+# PNUM, and datapath port number PNUM (the latter is a consequence of
+# the dummy implementation, which tries to assign datapath port
+# numbers based on port names).
+add_of_ports () {
+    local args
+    local br=$1; shift
+    for pnum; do
+        AS_VAR_APPEND([args], [" -- add-port $br p$pnum -- set Interface p$pnum type=dummy ofport_request=$pnum"])
+    done
+    ovs-vsctl $args
+}
 m4_divert_pop([PREPARE_TESTS])
 
 # OVS_VSWITCHD_STOP([WHITELIST])
@@ -336,17 +363,6 @@ m4_define([OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP],
 Tunnel push-pop off
 ])])
 
-# 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])])
-
 # WAIT_FOR_DUMMY_PORTS(NETDEV_DUMMY_PORT[, NETDEV_DUMMY_PORT...])
 #
 # Wait until the netdev dummy ports are connected to each other