Perl is unfashionable and Python is more widely available and understood,
so this commit converts one of the OVS uses of Perl into Python.

Signed-off-by: Ben Pfaff <b...@ovn.org>
---
 tests/atlocal.in |  8 +++-----
 tests/ofproto.at | 38 ++++++++++++++++++++------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/tests/atlocal.in b/tests/atlocal.in
index bdf5bd0ca97e..1ecabf03a261 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -108,11 +108,9 @@ FreeBSD|NetBSD)
 esac
 
 # Check whether to run IPv6 tests.
-if perl -e '
-    use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK);
-
-    socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1;
-    bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1;
+if $PYTHON -c '
+import socket
+socket.socket(family=socket.AF_INET6).bind(("::1", 0, 0, 0))
 '; then
     HAVE_IPV6=yes
 else
diff --git a/tests/ofproto.at b/tests/ofproto.at
index 9853a21db989..17ede5d4ab8d 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -4340,23 +4340,26 @@ 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);
+    $PYTHON -c '
+import sys
+
+buffer = []
+while True:
+    line = sys.stdin.readline()
+    if not line:
+        break
+    if line.startswith(" "):
+        buffer.append(line)
+    else:
+        sys.stdout.write("".join(sorted(buffer)))
+        sys.stdout.write(line)
+        buffer = []
+sys.stdout.write("".join(sorted(buffer)))
 '
 }
+]
 m4_divert_pop([PREPARE_TESTS])
 
 AT_SETUP([ofproto - flow monitoring])
@@ -4626,10 +4629,9 @@ ovs-appctl -t ovs-ofctl ofctl/block
 
 # Add $n_msgs flows.
 (echo "in_port=2,actions=output:2"
-${PERL} -e '
-    for ($i = 0; $i < '$n_msgs'; $i++) {
-        print "cookie=1,reg1=$i,actions=drop\n";
-    }
+$PYTHON -c '
+for i in range('$n_msgs'):
+    print("cookie=1,reg1=%d,actions=drop" % i)
 ') > flows.txt
 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
 # Check that multipart flow dumps work properly:
-- 
2.10.2

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to