From patchwork Wed Jul 27 07:03:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 653123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rzmDY3WF3z9sCy for ; Wed, 27 Jul 2016 17:03:41 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id D432110CA0; Wed, 27 Jul 2016 00:03:39 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id A44F610C95 for ; Wed, 27 Jul 2016 00:03:38 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id EC9181614ED for ; Wed, 27 Jul 2016 01:03:37 -0600 (MDT) X-ASG-Debug-ID: 1469603016-0b32374773ab160001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id bx8XKig9u6wToBb2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 27 Jul 2016 01:03:36 -0600 (MDT) X-Barracuda-Envelope-From: blp@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO relay3-d.mail.gandi.net) (217.70.183.195) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 27 Jul 2016 07:03:36 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.195 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.195 X-Barracuda-RBL-IP: 217.70.183.195 Received: from mfilter41-d.gandi.net (mfilter41-d.gandi.net [217.70.178.173]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 5FBC7A80F2; Wed, 27 Jul 2016 09:03:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter41-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter41-d.gandi.net (mfilter41-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 2IKOzEIuMoOI; Wed, 27 Jul 2016 09:03:32 +0200 (CEST) X-Originating-IP: 173.228.112.241 Received: from sigabrt.gateway.sonic.net (173-228-112-241.dsl.dynamic.fusionbroadband.com [173.228.112.241]) (Authenticated sender: blp@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 12774A80CF; Wed, 27 Jul 2016 09:03:31 +0200 (CEST) X-CudaMail-Envelope-Sender: blp@ovn.org From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-726000897 X-CudaMail-DTE: 072716 X-CudaMail-Originating-IP: 217.70.183.195 Date: Wed, 27 Jul 2016 00:03:21 -0700 X-ASG-Orig-Subj: [##CM-E1-726000897##][PATCH 1/5] tests: Define trim_zeros in only one place. Message-Id: <1469603005-5992-2-git-send-email-blp@ovn.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1469603005-5992-1-git-send-email-blp@ovn.org> References: <1469603005-5992-1-git-send-email-blp@ovn.org> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1469603016 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/5] tests: Define trim_zeros in only one place. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Defining trim_zeros in a common place allows us to skip defining it in every test that needs it. Signed-off-by: Ben Pfaff Acked-by: Ryan Moats Acked-by: Flavio Fernandes --- tests/ovn.at | 61 +++++++++++------------------------------------------------- 1 file changed, 11 insertions(+), 50 deletions(-) diff --git a/tests/ovn.at b/tests/ovn.at index 86efcf5..0fe2527 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1,3 +1,14 @@ +# trim_zeros() +# +# Removes pairs of trailing zeros from lines of text. Useful for +# fairly comparing Ethernet packets that might have been padded out to +# a minimum (e.g. 64-byte) length. +m4_divert_text([PREPARE_TESTS], + [trim_zeros() { + sed 's/\(00\)\{1,\}$//' "$@" + } +]) + AT_BANNER([OVN components]) AT_SETUP([ovn -- lexer]) @@ -737,9 +748,6 @@ vif_to_hv() { # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or # more) list the VIFs on which the packet should be received. INPORT and the # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2 3; do for j in 1 2 3; do : > $i$j.expected @@ -1038,9 +1046,6 @@ vif_to_hv() { # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or # more) list the VIFs on which the packet should be received. INPORT and the # OUTPORTs are specified as logical switch port numbers, e.g. 11 for vif11. -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2; do for j in 1 2 3 4 5; do : > $i$j.expected @@ -1223,9 +1228,6 @@ sleep 1 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or # more) list the VIFs on which the packet should be received. INPORT and the # OUTPORTs are specified as logical switch port numbers, e.g. 1 for vif1. -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2 3; do : > $i.expected done @@ -1384,9 +1386,6 @@ sleep 1 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or # more) list the VIFs on which the packet should be received. INPORT and the # OUTPORTs are specified as lport numbers, e.g. 1 for vif1. -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2 3; do : > $i.expected done @@ -1593,9 +1592,6 @@ sleep 1 # digits) and Ethernet type ETHTYPE (4 hex digits). The OUTPORTs (zero or # more) list the VIFs on which the packet should be received. INPORT and the # OUTPORTs are specified as logical switch port numbers, e.g. 123 for vif123. -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2 3; do for j in 1 2 3; do for k in 1 2 3; do @@ -1951,10 +1947,6 @@ vif_to_hv() { echo hv${1%?} } - -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2 3; do for j in 1 2 3; do : > $i$j.expected @@ -2372,9 +2364,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Packet to send. src_mac="f00000010203" @@ -2474,9 +2463,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Packet to send. src_mac="f00000010203" @@ -2610,9 +2596,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Packet to send. src_mac="f00000010203" @@ -2768,9 +2751,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Send ip packets between foo1 and alice1 src_mac="f00000010203" @@ -2865,9 +2845,6 @@ AT_CHECK([ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 externa # Wait for packet to be received. OVS_WAIT_UNTIL([test `wc -c < "hv/snoopvif-tx.pcap"` -ge 50]) -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv/snoopvif-tx.pcap | trim_zeros > packets expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80102000000000000c0a80102" echo $expected > expout @@ -2996,9 +2973,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Send ip packets between foo1 and alice1 src_mac="f00000010203" @@ -3138,10 +3112,6 @@ sleep 2 as hv1 ovs-vsctl show -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} - # This shell function sends a DHCP request packet # test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ... test_dhcp() { @@ -3443,9 +3413,6 @@ sleep 2 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} # Send ip packets between foo1 and alice1 src_mac="f00000010203" @@ -3590,9 +3557,6 @@ sleep 1 ip_to_hex() { printf "%02x%02x%02x%02x" "$@" } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2; do : > vif$i.expected done @@ -3756,9 +3720,6 @@ sleep 1 vif_to_hv() { echo hv1${1%?} } -trim_zeros() { - sed 's/\(00\)\{1,\}$//' -} for i in 1 2; do : > $i.expected done