Skip to content

Commit

Permalink
tests: Convert miscellaneous test code from Perl to Python.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Aaron Conole <[email protected]>
  • Loading branch information
blp committed Nov 27, 2017
1 parent ddd7d38 commit 719dcfd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
8 changes: 3 additions & 5 deletions tests/atlocal.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 20 additions & 18 deletions tests/ofproto.at
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 719dcfd

Please sign in to comment.