[ovs-dev] [PATCH 2/3] ofproto: Break out perl code for sorting multiline messages

Simon Horman horms at verge.net.au
Fri Jun 6 10:54:17 UTC 2014


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 <horms at verge.net.au>
---
 tests/automake.mk       |  4 +++-
 tests/multiline-sort.pl | 18 ++++++++++++++++++
 tests/ofproto.at        | 19 +------------------
 3 files changed, 22 insertions(+), 19 deletions(-)
 create mode 100644 tests/multiline-sort.pl

diff --git a/tests/automake.mk b/tests/automake.mk
index 9354fad..803e08c 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -194,7 +194,9 @@ tests_test_ovsdb_SOURCES = \
 	tests/test-ovsdb.c \
 	tests/idltest.c \
 	tests/idltest.h
-EXTRA_DIST += tests/uuidfilt.pl tests/ovsdb-monitor-sort.pl
+EXTRA_DIST += tests/uuidfilt.pl \
+	tests/ovsdb-monitor-sort.pl \
+	tests/multiline-sort.pl
 tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
 
 # idltest schema and IDL
diff --git a/tests/multiline-sort.pl b/tests/multiline-sort.pl
new file mode 100644
index 0000000..65f7b77
--- /dev/null
+++ b/tests/multiline-sort.pl
@@ -0,0 +1,18 @@
+#! /usr/bin/perl
+
+# 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);
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 6f6160e..d65f276 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -2131,24 +2131,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 | ${PERL} $srcdir/multiline-sort.pl], [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):
-- 
2.0.0.rc2




More information about the dev mailing list