On Fri, Jun 06, 2014 at 07:54:17PM +0900, Simon Horman wrote:
> The flow monitoring tests includes a perl script to sort
> multiline messages. Break it out into a separate file
> so it can be used by other tests. This is in preparation
> for doing so.
> 
> Signed-off-by: Simon Horman <ho...@verge.net.au>

I like to keep .at files more or less self-contained.  How about this
patch instead?

--8<--------------------------cut here-------------------------->8--

From: Simon Horman <ho...@verge.net.au>
Date: Thu, 12 Jun 2014 13:52:03 -0700
Subject: [PATCH] ofproto: Break out perl code for sorting multiline messages

The flow monitoring tests includes a perl script to sort multiline
messages.  This commit breaks it out of an individual test so that it can
be used elsewhere.

Signed-off-by: Simon Horman <ho...@verge.net.au>
[b...@nicira.com changed approach from a separate file to a shell function]
Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 tests/ofproto.at |   41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/tests/ofproto.at b/tests/ofproto.at
index 34cca37..48ed865 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -2097,6 +2097,28 @@ OFPT_BARRIER_REPLY (OF1.2):
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+m4_divert_push([PREPARE_TESTS])
+# Sorts groups of lines that start with a space, without moving them
+# past the nearest line that does not start with a space.
+multiline_sort () {
+    ${PERL} -e '
+        use warnings;
+        use strict;
+        my @buffer = ();
+        while (<STDIN>) {
+            if (/^ /) {
+                push(@buffer, $_);
+            } else {
+                print $_ foreach sort(@buffer);
+                print $_;
+                @buffer = ();
+            }
+        }
+        print $_ foreach sort(@buffer);
+'
+}
+m4_divert_pop([PREPARE_TESTS])
+
 AT_SETUP([ofproto - flow monitoring])
 AT_KEYWORDS([monitor])
 OVS_VSWITCHD_START
@@ -2140,24 +2162,7 @@ ovs-ofctl mod-flows br0 
cookie=5,dl_vlan=123,actions=output:3
 ovs-ofctl del-flows br0 dl_vlan=123
 ovs-ofctl del-flows br0
 ovs-appctl -t ovs-ofctl ofctl/barrier
-sort='
-    # Sorts groups of lines that start with a space, without moving them
-    # past the nearest line that does not start with a space.
-    use warnings;
-    use strict;
-    my @buffer = ();
-    while (<STDIN>) {
-        if (/^ /) {
-            push(@buffer, $_);
-        } else {
-            print $_ foreach sort(@buffer);
-            print $_;
-            @buffer = ();
-        }
-    }
-    print $_ foreach sort(@buffer);
-'
-AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | ${PERL} 
-e "$sort"], [0],
+AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | 
multiline_sort], [0],
 [NXST_FLOW_MONITOR reply (xid=0x0):
  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
 NXST_FLOW_MONITOR reply (xid=0x0):
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to