X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Fofproto-macros.at;h=1b22c44521cdbb3859e389cea000373f03988879;hb=7ae1f322d7794dc5c0528ef1a01154cbc58684d0;hp=bace0f51801f370f86710ed086ac97238d292f96;hpb=53902038abe62c45ff46d7de9dcec30c3d1d861e;p=cascardo%2Fovs.git diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index bace0f518..1b22c4452 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -230,12 +230,24 @@ ovn_populate_arp() { 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]) @@ -288,9 +300,7 @@ m4_define([_OVS_VSWITCHD_START], # system's real Ethernet devices). m4_define([OVS_VSWITCHD_START], [_OVS_VSWITCHD_START([--enable-dummy$3 --disable-system]) - - dnl Add bridges, ports, etc. - AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) + AT_CHECK([add_of_br 0 $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) ]) # check_logs scans through all *.log files (except '*.log' and testsuite.log) @@ -316,6 +326,50 @@ check_logs () { /|ERR|/p /|EMER|/p" ${logs} } + +# add_of_br BRNUM [ARG...] +add_of_br () { + local brnum=$1; shift + local br=br$brnum + local dpid=fedcba987654321$brnum + local mac=aa:55:aa:55:00:0$brnum + ovs-vsctl --timeout=20 \ + -- add-br $br \ + -- set bridge $br datapath-type=dummy \ + fail-mode=secure \ + other-config:datapath-id=$dpid \ + other-config:hwaddr=$mac \ + protocols="[[OpenFlow10,OpenFlow11,OpenFlow12,\ + OpenFlow13,OpenFlow14,OpenFlow15]]" \ + -- "$@" +} + +# add_of_ports [--pcap] 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). +# +# If --pcap is supplied then packets received from the interface will +# be written to $port-rx.pcap and those sent to it to $port-tx.pcap. +add_of_ports () { + local args + local pcap=false + if test "$1" = --pcap; then + pcap=: + shift + fi + 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"]) + if $pcap; then + AS_VAR_APPEND([args], [" -- set Interface p$pnum options:rxq_pcap=p$pnum-rx.pcap options:tx_pcap=p$pnum-tx.pcap"]) + fi + done + echo ovs-vsctl $args + ovs-vsctl $args +} m4_divert_pop([PREPARE_TESTS]) # OVS_VSWITCHD_STOP([WHITELIST]) @@ -336,17 +390,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