From patchwork Wed Nov 15 18:53:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYSh6YCGz9s74 for ; Thu, 16 Nov 2017 05:54:12 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 96B86B92; Wed, 15 Nov 2017 18:53:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 20A23AE0 for ; Wed, 15 Nov 2017 18:53:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3DC03113 for ; Wed, 15 Nov 2017 18:53:29 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 2426C41C091; Wed, 15 Nov 2017 19:53:25 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:10 -0800 Message-Id: <20171115185318.26841-1-blp@ovn.org> X-Mailer: git-send-email 2.10.2 X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 1/9] tests: Convert uuidfilt utility from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- tests/automake.mk | 5 +- tests/ofproto-macros.at | 4 +- tests/ofproto.at | 24 ++++----- tests/ovn-controller.at | 2 +- tests/ovn-nbctl.at | 102 +++++++++++++++++++-------------------- tests/ovs-macros.at | 4 ++ tests/ovs-vsctl.at | 16 +++--- tests/ovsdb-execution.at | 4 +- tests/ovsdb-idl.at | 30 ++++++------ tests/ovsdb-monitor.at | 4 +- tests/ovsdb-rbac.at | 28 +++++------ tests/ovsdb-server.at | 36 +++++++------- tests/ovsdb-tool.at | 18 +++---- tests/ovsdb-trigger.at | 2 +- tests/system-kmod-macros.at | 4 +- tests/system-userspace-macros.at | 4 +- tests/uuidfilt.pl | 33 ------------- tests/uuidfilt.py | 50 +++++++++++++++++++ 18 files changed, 196 insertions(+), 174 deletions(-) delete mode 100755 tests/uuidfilt.pl create mode 100755 tests/uuidfilt.py diff --git a/tests/automake.mk b/tests/automake.mk index 156b40f58d7c..3ca60e2ea450 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -290,7 +290,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac noinst_PROGRAMS += tests/test-ovsdb tests_test_ovsdb_SOURCES = tests/test-ovsdb.c nodist_tests_test_ovsdb_SOURCES = tests/idltest.c tests/idltest.h -EXTRA_DIST += tests/uuidfilt.pl tests/ovsdb-monitor-sort.pl +EXTRA_DIST += tests/ovsdb-monitor-sort.pl tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la noinst_PROGRAMS += tests/test-lib @@ -389,7 +389,8 @@ CHECK_PYFILES = \ tests/MockXenAPI.py \ tests/test-unix-socket.py \ tests/test-unixctl.py \ - tests/test-vlog.py + tests/test-vlog.py \ + tests/uuidfilt.py EXTRA_DIST += $(CHECK_PYFILES) PYCOV_CLEAN_FILES += $(CHECK_PYFILES:.py=.py,cover) .coverage diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 38449db32ee0..4fbb10070342 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -353,7 +353,7 @@ m4_define([_OVS_VSWITCHD_START], # br0 with predictable settings, passing 'vsctl-args' as additional # commands to ovs-vsctl. If 'vsctl-args' causes ovs-vsctl to provide # output (e.g. because it includes "create" commands) then 'vsctl-output' -# specifies the expected output after filtering through uuidfilt.pl. +# specifies the expected output after filtering through uuidfilt. # # If a test needs to use "system" devices (as dummies), then specify # =override (literally) as the third argument. Otherwise, system devices @@ -364,7 +364,7 @@ m4_define([_OVS_VSWITCHD_START], # to ovs-vswitchd m4_define([OVS_VSWITCHD_START], [_OVS_VSWITCHD_START([--enable-dummy$3 --disable-system $4]) - AT_CHECK([add_of_br 0 $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) + AT_CHECK([add_of_br 0 $1 m4_if([$2], [], [], [| uuidfilt])], [0], [$2]) ]) # check_logs scans through all *.log files (except '*.log' and testsuite.log) diff --git a/tests/ofproto.at b/tests/ofproto.at index 31cb5208fc1c..9853a21db989 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -2196,7 +2196,7 @@ AT_CHECK( -- --id=@t0 create Flow_Table name=main \ -- --id=@t1 create Flow_Table flow-limit=1024 \ -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> <1> ]) @@ -2348,7 +2348,7 @@ AT_CHECK( -- --id=@t0 create Flow_Table name=main \ -- --id=@t1 create Flow_Table flow-limit=1024 \ -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> <1> ]) @@ -2603,7 +2603,7 @@ AT_CHECK( -- --id=@t0 create Flow_Table name=main \ -- --id=@t1 create Flow_Table flow-limit=1024 \ -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> <1> ]) @@ -2655,7 +2655,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -2699,7 +2699,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -2738,7 +2738,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -2796,7 +2796,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -2855,7 +2855,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table name=evict flow-limit=4 \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Use mod-table to turn on eviction just to demonstrate that it works. @@ -2921,7 +2921,7 @@ AT_CHECK( overflow-policy=evict \ groups='"NXM_OF_IN_PORT[[]]"' \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -3003,7 +3003,7 @@ AT_CHECK( overflow-policy=evict \ groups='"NXM_OF_IN_PORT[[]]"' \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. @@ -3083,7 +3083,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) ovs-appctl time/stop @@ -3127,7 +3127,7 @@ AT_CHECK( [ovs-vsctl \ -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \ -- set bridge br0 flow_tables:0=@t0 \ - | ${PERL} $srcdir/uuidfilt.pl], + | uuidfilt], [0], [<0> ]) # Add 4 flows. diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 2b28279c18da..3244707f6032 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -96,7 +96,7 @@ AT_CHECK([ovn-sbctl \ -- create Port_Binding datapath=@dp1 logical_port=foo tunnel_key=1 type=patch options:peer=bar \ -- create Port_Binding datapath=@dp2 logical_port=bar tunnel_key=2 type=patch options:peer=foo \ -- create Port_Binding datapath=@dp1 logical_port=dp1vif tunnel_key=3 \ -| ${PERL} $srcdir/uuidfilt.pl], [0], [<0> +| uuidfilt], [0], [<0> <1> <2> <3> diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 26b3ee9d8dda..bcc627e98de4 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -38,31 +38,31 @@ AT_SETUP([ovn-nbctl - basic switch commands]) OVN_NBCTL_TEST_START AT_CHECK([ovn-nbctl ls-add ls0]) -AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl <0> (ls0) ]) AT_CHECK([ovn-nbctl ls-add ls1]) -AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl <0> (ls0) <1> (ls1) ]) AT_CHECK([ovn-nbctl ls-del ls0]) -AT_CHECK([ovn-nbctl ls-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-list | uuidfilt], [0], [dnl <0> (ls1) ]) AT_CHECK([ovn-nbctl show ls0]) AT_CHECK([ovn-nbctl ls-add ls0]) -AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], +AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], [switch <0> (ls0) ]) AT_CHECK([ovn-nbctl ls-add ls0], [1], [], [ovn-nbctl: ls0: a switch with this name already exists ]) AT_CHECK([ovn-nbctl --may-exist ls-add ls0]) -AT_CHECK([ovn-nbctl show ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], +AT_CHECK([ovn-nbctl show ls0 | uuidfilt], [0], [switch <0> (ls0) ]) AT_CHECK([ovn-nbctl --add-duplicate ls-add ls0]) @@ -101,12 +101,12 @@ AT_CHECK([ovn-nbctl lsp-add ls0 lp0], [1], [], [ovn-nbctl: lp0: a port with this name already exists ]) AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp0]) -AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl <0> (lp0) ]) AT_CHECK([ovn-nbctl lsp-add ls0 lp1]) -AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl <0> (lp0) <1> (lp1) ]) @@ -123,7 +123,7 @@ AT_CHECK([ovn-nbctl --may-exist lsp-add ls0 lp1 lp0 5], [1], [], ]) AT_CHECK([ovn-nbctl lsp-del lp1]) -AT_CHECK([ovn-nbctl lsp-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lsp-list ls0 | uuidfilt], [0], [dnl <0> (lp0) ]) @@ -449,7 +449,7 @@ AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10 192.168.10.10:900 tcp], [1], [], dnl Add ips to lb AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 ,,,192.168.10.10:80,,,,,]) AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 ,,,192.168.10.10:80,,,,192.168.10.20:80,,,,]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 @@ -459,7 +459,7 @@ AT_CHECK([ovn-nbctl lb-del lb1]) AT_CHECK([ovn-nbctl lb-add lb0 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80]) AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 tcp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 @@ -467,14 +467,14 @@ UUID LB PROTO VIP dnl Update the VIP of the lb1. AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 ]) AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 udp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 @@ -482,7 +482,7 @@ UUID LB PROTO VIP dnl Config lb1 with another VIP. AT_CHECK([ovn-nbctl lb-add lb1 30.0.0.20:80 192.168.10.10:80 udp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 @@ -490,7 +490,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl lb-del lb1 30.0.0.20:80]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 @@ -499,7 +499,7 @@ UUID LB PROTO VIP dnl Add LBs whose vip is just an IP address. AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.30 192.168.10.10]) AT_CHECK([ovn-nbctl lb-add lb3 30.0.0.30 192.168.10.10]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 @@ -511,7 +511,7 @@ AT_CHECK([ovn-nbctl lb-del lb3 30.0.0.30]) AT_CHECK([ovn-nbctl lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp]) AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 tcp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:8080 @@ -533,7 +533,7 @@ AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:8080 192.168.10.10:8080,192 AT_CHECK([ovn-nbctl --may-exist lb-add lb1 30.0.0.10:9090 192.168.10.10:8080,192.168.10.20:8080 udp]) AT_CHECK([ovn-nbctl lb-del lb0 30.0.0.10:80]) AT_CHECK([ovn-nbctl lb-del lb1]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 <1> lb2 tcp 30.0.0.10:8080 192.168.10.10:80,192.168.10.20:80 @@ -552,7 +552,7 @@ AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [], ]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 @@ -560,7 +560,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20 @@ -568,7 +568,7 @@ UUID LB PROTO VIP AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1]) AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], []) AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1]) dnl Remove all load balancers from logical switch. @@ -576,7 +576,7 @@ AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3]) AT_CHECK([ovn-nbctl ls-lb-del ls0]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], []) dnl Add load balancer to logical router. AT_CHECK([ovn-nbctl lr-add lr0]) @@ -588,7 +588,7 @@ AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [], ]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 @@ -596,7 +596,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb1 udp 30.0.0.10:80 192.168.10.10:80,192.168.10.20:80 <1> lb3 tcp/udp 30.0.0.10 192.168.10.10,192.168.10.20 @@ -604,7 +604,7 @@ UUID LB PROTO VIP AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1]) AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], []) AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1]) dnl Remove all load balancers from logical router. @@ -612,7 +612,7 @@ AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3]) AT_CHECK([ovn-nbctl lr-lb-del lr0]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], []) OVN_NBCTL_TEST_STOP AT_CLEANUP @@ -712,7 +712,7 @@ AT_CHECK([ovn-nbctl lb-del lb0]) dnl Add ips to lb AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,,]) AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 ,,,[[fd0f::10]]:80,,,,[[fd0f::20]]:80,,,,]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 @@ -723,7 +723,7 @@ AT_CHECK([ovn-nbctl lb-del lb1]) AT_CHECK([ovn-nbctl lb-add lb0 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80]) AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 @@ -731,14 +731,14 @@ UUID LB PROTO VIP dnl Update the VIP of the lb1. AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 ]) AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 udp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 @@ -746,7 +746,7 @@ UUID LB PROTO VIP dnl Config lb1 with another VIP. AT_CHECK([ovn-nbctl lb-add lb1 [[ae0f::20]]:80 [[fd0f::10]]:80 udp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 @@ -754,7 +754,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl lb-del lb1 [[ae0f::20]]:80]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 @@ -763,7 +763,7 @@ UUID LB PROTO VIP dnl Add LBs whose vip is just an IP address. AT_CHECK([ovn-nbctl lb-add lb2 ae0f::30 fd0f::10]) AT_CHECK([ovn-nbctl lb-add lb3 ae0f::30 fd0f::10]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 @@ -775,7 +775,7 @@ AT_CHECK([ovn-nbctl lb-del lb3 ae0f::30]) AT_CHECK([ovn-nbctl lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp]) AT_CHECK([ovn-nbctl --add-duplicate lb-add lb2 [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 tcp]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:8080 @@ -797,7 +797,7 @@ AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:8080 [[fd0f::10]]:8080,[ AT_CHECK([ovn-nbctl --may-exist lb-add lb1 [[ae0f::10]]:9090 [[fd0f::10]]:8080,[[fd0f::20]]:8080 udp]) AT_CHECK([ovn-nbctl lb-del lb0 [[ae0f::10]]:80]) AT_CHECK([ovn-nbctl lb-del lb1]) -AT_CHECK([ovn-nbctl lb-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lb-list | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb2 tcp [[ae0f::10]]:8080 [[fd0f::10]]:80,[[fd0f::20]]:80 @@ -816,7 +816,7 @@ AT_CHECK([ovn-nbctl ls-lb-add ls0 lb2], [1], [], ]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 @@ -824,7 +824,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl ls-lb-del ls0 lb0]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20 @@ -832,7 +832,7 @@ UUID LB PROTO VIP AT_CHECK([ovn-nbctl ls-lb-del ls0 lb1]) AT_CHECK([ovn-nbctl ls-lb-del ls0 lb3]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], []) AT_CHECK([ovn-nbctl --if-exists ls-lb-del ls0 lb1]) dnl Remove all load balancers from logical switch. @@ -840,7 +840,7 @@ AT_CHECK([ovn-nbctl ls-lb-add ls0 lb0]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb1]) AT_CHECK([ovn-nbctl ls-lb-add ls0 lb3]) AT_CHECK([ovn-nbctl ls-lb-del ls0]) -AT_CHECK([ovn-nbctl ls-lb-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl ls-lb-list ls0 | uuidfilt], [0], []) dnl Add load balancer to logical router. AT_CHECK([ovn-nbctl lr-add lr0]) @@ -852,7 +852,7 @@ AT_CHECK([ovn-nbctl lr-lb-add lr0 lb2], [1], [], ]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb0 tcp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 @@ -860,7 +860,7 @@ UUID LB PROTO VIP ]) AT_CHECK([ovn-nbctl lr-lb-del lr0 lb0]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], [dnl UUID LB PROTO VIP IPs <0> lb1 udp [[ae0f::10]]:80 [[fd0f::10]]:80,[[fd0f::20]]:80 <1> lb3 tcp/udp ae0f::10 fd0f::10,fd0f::20 @@ -868,7 +868,7 @@ UUID LB PROTO VIP AT_CHECK([ovn-nbctl lr-lb-del lr0 lb1]) AT_CHECK([ovn-nbctl lr-lb-del lr0 lb3]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], []) AT_CHECK([ovn-nbctl --if-exists lr-lb-del lr0 lb1]) dnl Remove all load balancers from logical router. @@ -876,7 +876,7 @@ AT_CHECK([ovn-nbctl lr-lb-add lr0 lb0]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb1]) AT_CHECK([ovn-nbctl lr-lb-add lr0 lb3]) AT_CHECK([ovn-nbctl lr-lb-del lr0]) -AT_CHECK([ovn-nbctl lr-lb-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], []) +AT_CHECK([ovn-nbctl lr-lb-list lr0 | uuidfilt], [0], []) OVN_NBCTL_TEST_STOP AT_CLEANUP @@ -886,31 +886,31 @@ AT_SETUP([ovn-nbctl - basic logical router commands]) OVN_NBCTL_TEST_START AT_CHECK([ovn-nbctl lr-add lr0]) -AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl <0> (lr0) ]) AT_CHECK([ovn-nbctl lr-add lr1]) -AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl <0> (lr0) <1> (lr1) ]) AT_CHECK([ovn-nbctl lr-del lr0]) -AT_CHECK([ovn-nbctl lr-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lr-list | uuidfilt], [0], [dnl <0> (lr1) ]) AT_CHECK([ovn-nbctl show lr0]) AT_CHECK([ovn-nbctl lr-add lr0]) -AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], +AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0], [router <0> (lr0) ]) AT_CHECK([ovn-nbctl lr-add lr0], [1], [], [ovn-nbctl: lr0: a router with this name already exists ]) AT_CHECK([ovn-nbctl --may-exist lr-add lr0]) -AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], +AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0], [router <0> (lr0) ]) AT_CHECK([ovn-nbctl --add-duplicate lr-add lr0]) @@ -953,7 +953,7 @@ AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03:04 192.168.1.1/24], [1], AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24]) -AT_CHECK([ovn-nbctl show lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl show lr0 | uuidfilt], [0], [dnl router <0> (lr0) port lrp0 mac: "00:00:00:01:02:03" @@ -964,12 +964,12 @@ AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24], [1], [], [ovn-nbctl: lrp0: a port with this name already exists ]) AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24]) -AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl <0> (lrp0) ]) AT_CHECK([ovn-nbctl lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer]) -AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl <0> (lrp0) <1> (lrp1) ]) @@ -998,7 +998,7 @@ AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 10.0.0.1/24 p AT_CHECK([ovn-nbctl --may-exist lrp-add lr0 lrp1 00:00:00:01:02:03 192.168.1.1/24 peer=lrp1-peer]) AT_CHECK([ovn-nbctl lrp-del lrp1]) -AT_CHECK([ovn-nbctl lrp-list lr0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl +AT_CHECK([ovn-nbctl lrp-list lr0 | uuidfilt], [0], [dnl <0> (lrp0) ]) diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 7c57ca1bcad2..08d3d5a020f5 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -197,6 +197,10 @@ kill_ovs_vswitchd () { wc () { command wc "$@" | tr -s ' ' ' ' | sed 's/^ *//' } + +uuidfilt () { + $PYTHON "$top_srcdir"/tests/uuidfilt.py "$@" +} ] m4_divert_pop([PREPARE_TESTS]) diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 8861a4aad3b1..d54188976ad9 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -654,7 +654,7 @@ cp stdout out1 AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) cp stdout out2 -AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0], +AT_CHECK([uuidfilt out1 out2], [0], [[<0> @@ -785,7 +785,7 @@ AT_CHECK([ cp stdout netflow-uuid AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl netflow-uuid stdout], [0], +AT_CHECK([uuidfilt netflow-uuid stdout], [0], [[<0> _uuid : <0> @@ -1084,7 +1084,7 @@ AT_CHECK( [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) AT_CHECK( - [${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl + [uuidfilt stdout], [0], [dnl @@ -1098,7 +1098,7 @@ AT_CHECK( [list bridge br0])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) AT_CHECK( - [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl + [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | uuidfilt], [0], [dnl [_uuid : <0> name : "eth0" _uuid : <1> @@ -1124,13 +1124,13 @@ AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \ - -- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl], + -- create Bridge name=br0 | uuidfilt], [0], [<0> ], [db_ctl_base|WARN|applying "create" command to table Bridge without --id option will have no effect ], [OVS_VSCTL_CLEANUP]) AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \ - -- --id=@br0 create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl], + -- --id=@br0 create Bridge name=br0 | uuidfilt], [0], [<0> ], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database ], [OVS_VSCTL_CLEANUP]) @@ -1140,7 +1140,7 @@ AT_CHECK( -- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \ -- --id=@m0 create Mirror name=m0 output_port=@eth0 \ -- --id=@br0 create Bridge name=br0 mirrors=@m0 \ - -- set Open_vSwitch . bridges=@br0 | ${PERL} $srcdir/uuidfilt.pl], + -- set Open_vSwitch . bridges=@br0 | uuidfilt], [0], [<0> <1> <2> @@ -1158,7 +1158,7 @@ AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], +AT_CHECK([uuidfilt stdout], [0], [[<0> _uuid : <1> auto_attach : [] diff --git a/tests/ovsdb-execution.at b/tests/ovsdb-execution.at index 311f44abc527..3129e73f4a09 100644 --- a/tests/ovsdb-execution.at +++ b/tests/ovsdb-execution.at @@ -141,7 +141,7 @@ m4_define([OVSDB_CHECK_EXECUTION_RO], AT_KEYWORDS([ovsdb execute execution positive $5]) AT_CHECK([test-ovsdb execute-readonly "`$2`" m4_foreach([txn], [$3], [ 'txn'])], [0], [stdout], []) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [$4]) + AT_CHECK([uuidfilt stdout], [0], [$4]) AT_CLEANUP]) OVSDB_CHECK_EXECUTION_RO([block insert on read only DB], @@ -179,7 +179,7 @@ m4_define([OVSDB_CHECK_EXECUTION], AT_KEYWORDS([ovsdb execute execution positive $5]) AT_CHECK([test-ovsdb execute "`$2`" m4_foreach([txn], [$3], [ 'txn'])], [0], [stdout], []) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [$4]) + AT_CHECK([uuidfilt stdout], [0], [$4]) AT_CLEANUP]) OVSDB_CHECK_EXECUTION([uuid-name must be ], diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 21745eacbb5c..59b2c1991bde 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -37,7 +37,7 @@ m4_define([OVSDB_CHECK_IDL_C], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -52,7 +52,7 @@ m4_define([OVSDB_CHECK_IDL_PYN], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -72,7 +72,7 @@ m4_define([OVSDB_CHECK_IDL_REGISTER_COLUMNS_PYN], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket ?simple:b,ba,i,ia,r,ra,s,sa,u,ua?link1:i,k,ka,l2?link2:i,l1 $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -95,7 +95,7 @@ m4_define([OVSDB_CHECK_IDL_TCP_PYN], [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])]) AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:127.0.0.1:$TCP_PORT $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -121,7 +121,7 @@ m4_define([OVSDB_CHECK_IDL_TCP6_PYN], [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])]) AT_CHECK([$8 $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:[[::1]]:$TCP_PORT $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -154,7 +154,7 @@ m4_define([OVSDB_CHECK_IDL_PASSIVE_TCP_PY], AT_CHECK([ovsdb_start_idltest "tcp:127.0.0.1:$TCP_PORT"]) AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl_passive $srcdir/idltest.ovsschema ptcp:127.0.0.1:$TCP_PORT $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP @@ -764,7 +764,7 @@ AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 idl uni "where": [], "row": {"k": ["uuid", "#0#"]}}]']], [0], [stdout], [stderr]) -AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl], [0], +AT_CHECK([sort stdout | uuidfilt], [0], [[000: empty 001: {"error":null,"result":[{"uuid":["uuid","<0>"]}]} 002: i=0 k=0 ka=[] l2= uuid=<0> @@ -812,7 +812,7 @@ m4_define([OVSDB_CHECK_IDL_FETCH_COLUMNS_PY], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket [$3] $4], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$7],,, [[| $7]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$7],,, [[| $7]]), [0], [$5]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -856,7 +856,7 @@ m4_define([OVSDB_CHECK_IDL_WO_MONITOR_COND_PY], AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/disable-monitor-cond]) AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2], [0], [stdout], [ignore], [kill `cat pid`]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$5],,, [[| $5]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]), [0], [$3], [], [kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -951,7 +951,7 @@ m4_define([OVSDB_CHECK_IDL_TRACK_C], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1080,7 +1080,7 @@ m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_MAP_COLUMN], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-map-column unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1129,7 +1129,7 @@ m4_define([OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-partial-update-set-column unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1188,7 +1188,7 @@ m4_define([OVSDB_CHECK_IDL_NOTIFY_PY], AT_CHECK([ovsdb_start_idltest]) AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema unix:socket $2], [0], [stdout], [ignore], [kill `cat pid`]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$5],,, [[| $5]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]), [0], [$3], [], [kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1217,7 +1217,7 @@ m4_define([OVSDB_CHECK_IDL_NOTIFY_SSL_PY], ssl:127.0.0.1:$TCP_PORT $PKIDIR/testpki-privkey.pem \ $PKIDIR/testpki-cert.pem $PKIDIR/testpki-cacert.pem $2], [0], [stdout], [ignore], [kill `cat pid`]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$5],,, [[| $5]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$5],,, [[| $5]]), [0], [$3], [], [kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1605,7 +1605,7 @@ m4_define([OVSDB_CHECK_IDL_COMPOUND_INDEX_WITH_REF], [AT_CHECK([ovsdb-client transact unix:socket $2], [0], [ignore], [ignore])]) AT_CHECK([test-ovsdb '-vPATTERN:console:test-ovsdb|%c|%m' -vjsonrpc -t10 -c idl-compound-index-with-ref unix:socket $3], [0], [stdout], [ignore]) - AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + AT_CHECK([sort stdout | uuidfilt]m4_if([$6],,, [[| $6]]), [0], [$4]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) diff --git a/tests/ovsdb-monitor.at b/tests/ovsdb-monitor.at index 256868b0248f..65c595645b14 100644 --- a/tests/ovsdb-monitor.at +++ b/tests/ovsdb-monitor.at @@ -44,7 +44,7 @@ m4_define([OVSDB_CHECK_MONITOR], [ignore], [ignore]) OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid]) OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid]) - AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore]) + AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | uuidfilt], [0], [$7], [ignore]) AT_CLEANUP]) # OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE, @@ -86,7 +86,7 @@ m4_define([OVSDB_CHECK_MONITOR_COND], [ignore], [ignore]) AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore]) OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid]) - AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | ${PERL} $srcdir/uuidfilt.pl], [0], [$7], [ignore]) + AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | uuidfilt], [0], [$7], [ignore]) AT_CLEANUP]) OVSDB_CHECK_MONITOR([monitor insert into empty table], diff --git a/tests/ovsdb-rbac.at b/tests/ovsdb-rbac.at index 351eab9637c7..adefee4dfa27 100644 --- a/tests/ovsdb-rbac.at +++ b/tests/ovsdb-rbac.at @@ -135,7 +135,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"name": "chartreuse", "value": '8388352'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"fixed_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"fixed_colors\".","error":"permission error"}]] ], [ignore]) # Test 2: @@ -152,7 +152,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"creator": "client-2", "name": "chartreuse", "value": '8388352'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"user_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-1\" role \"testrole\" prohibit row insertion into table \"user_colors\".","error":"permission error"}]] ], [ignore]) # Test 3: @@ -169,7 +169,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"creator": "client-1", "name": "chartreuse", "value": '8388352'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"uuid":["uuid","<0>"]}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"uuid":["uuid","<0>"]}]] ], [ignore]) # Test 4: @@ -188,7 +188,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"value": '8388353'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]] ], [ignore]) # Test 5: @@ -207,7 +207,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"value": '8388354'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"user_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"user_colors\".","error":"permission error"}]] ], [ignore]) # Test 6: @@ -226,7 +226,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "mutations": [["value", "+=", '10']]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]] ], [ignore]) # Test 7: @@ -245,7 +245,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "mutations": [["value", "+=", '10']]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit mutate operation on table \"user_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit mutate operation on table \"user_colors\".","error":"permission error"}]] ], [ignore]) # Test 8: @@ -262,7 +262,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "where": [["name", "==", "chartreuse"]]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"user_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"user_colors\".","error":"permission error"}]] ], [ignore]) # Test 9: @@ -279,7 +279,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "where": [["name", "==", "chartreuse"]]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]] ], [ignore]) # Test 10: @@ -296,7 +296,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"creator": ["map",[["chassis", "client-1"]]], "name": "seafoam", "value": '7466680'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"uuid":["uuid","<0>"]}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"uuid":["uuid","<0>"]}]] ], [ignore]) # Test 11: @@ -315,7 +315,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"value": '8388353'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]] ], [ignore]) # Test 12: @@ -334,7 +334,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "row": {"value": '8388354'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"other_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit modification of table \"other_colors\".","error":"permission error"}]] ], [ignore]) # Test 13: @@ -351,7 +351,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "where": [["name", "==", "seafoam"]]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"other_colors\".","error":"permission error"}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"details":"RBAC rules for client \"client-2\" role \"testrole\" prohibit row deletion from table \"other_colors\".","error":"permission error"}]] ], [ignore]) # Test 14: @@ -368,7 +368,7 @@ AT_CHECK([ovsdb-client transact ssl:127.0.0.1:$SSL_PORT \ "where": [["name", "==", "seafoam"]]} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[[{"count":1}]] +AT_CHECK([uuidfilt stdout], [0], [[[{"count":1}]] ], [ignore]) OVSDB_SERVER_SHUTDOWN diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 0f8c791128b1..bcc1bc8f7d39 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -33,7 +33,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [test ! -e pid || kill `cat pid`]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + AT_CHECK([uuidfilt output], [0], [$4], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -81,7 +81,7 @@ AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ ]]) AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], []) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], +AT_CHECK([uuidfilt output], [0], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] @@ -129,7 +129,7 @@ AT_DATA([txnfile], [[ovsdb-client transact unix:socket \ ]]) AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], []) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], +AT_CHECK([uuidfilt output], [0], [[[{"uuid":["uuid","<0>"]}] [{"uuid":["uuid","<1>"]}] [{"rows":[{"_uuid":["uuid","<0>"],"_version":["uuid","<2>"],"name":"zero","number":0},{"_uuid":["uuid","<1>"],"_version":["uuid","<3>"],"name":"one","number":1}]}] @@ -370,7 +370,7 @@ AT_CHECK( "columns": ["target", "is_connected"]}]']], [0], [stdout], [ignore]) AT_CHECK( - [${PERL} $srcdir/uuidfilt.pl stdout], + [uuidfilt stdout], [0], [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}] ]], @@ -661,7 +661,7 @@ AT_CHECK( done]], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) dnl Check that all the crap is in fact in the database log. -AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], +AT_CHECK([[uuidfilt db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} @@ -685,7 +685,7 @@ AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9 dnl Dump out and check the actual database contents. AT_CHECK([[ovsdb-client dump unix:socket ordinals]], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -716,7 +716,7 @@ AT_CHECK([test `wc -l < db` -eq 4], [0], [], [], dnl And check that the dumped data is the same too: AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -746,7 +746,7 @@ OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket --log-file="`pwd`"/ovsdb-server.log db], [0], [ignore], [ignore]) AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -885,7 +885,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [test ! -e pid || kill `cat pid`]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + AT_CHECK([uuidfilt output], [0], [$4], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -923,7 +923,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [test ! -e pid || kill `cat pid`]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + AT_CHECK([uuidfilt output], [0], [$4], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -970,7 +970,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [test ! -e pid || kill `cat pid`]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + AT_CHECK([uuidfilt output], [0], [$4], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1007,7 +1007,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [test ! -e pid || kill `cat pid`]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + AT_CHECK([uuidfilt output], [0], [$4], [ignore], [test ! -e pid || kill `cat pid`]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) @@ -1045,7 +1045,7 @@ m4_define([OVSDB_CHECK_EXECUTION], AT_CHECK([ovsdb-server --remote=punix:socket db --run="sh txnfile"], [0], [stdout], [ignore]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) + AT_CHECK([uuidfilt output], [0], [$4], [ignore]) AT_CLEANUP]) EXECUTION_EXAMPLES @@ -1135,7 +1135,7 @@ m4_define([OVSDB_CHECK_REPLICATION], AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) cat stdout > output - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore]) + AT_CHECK([uuidfilt output], [0], [$4], [ignore]) OVSDB_SERVER_SHUTDOWN OVSDB_SERVER_SHUTDOWN2 @@ -1220,7 +1220,7 @@ cat stdout > dump2 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) cat stdout > output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8 +AT_CHECK([uuidfilt output], [0], [7,9c7,8 < _uuid name number < ------------------------------------ ---- ------ < <0> one 1 @@ -1322,7 +1322,7 @@ cat stdout > dump2 AT_CHECK([diff dump1 dump2], [1], [stdout], [ignore]) cat stdout > output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [7,9c7,8 +AT_CHECK([uuidfilt output], [0], [7,9c7,8 < _uuid name number < ------------------------------------ ---- ------ < <0> one 1 @@ -1341,7 +1341,7 @@ AT_CHECK([ovsdb-client transact unix:db2.sock \ AT_CHECK([ovsdb-client dump unix:db2.sock], [0], [stdout]) cat stdout > output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [a table +AT_CHECK([uuidfilt output], [0], [a table _uuid name number ------------------------------------ ---- ------ <0> zero 0 @@ -1534,7 +1534,7 @@ AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT \ "row": {"name": "two", "number": '2'}} ]']], [0], [stdout], [ignore]) cat stdout >> output -AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] +AT_CHECK([uuidfilt output], [0], [[[{"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}]] ], [ignore]) OVSDB_SERVER_SHUTDOWN AT_CLEANUP diff --git a/tests/ovsdb-tool.at b/tests/ovsdb-tool.at index f782952a3d7f..2ce0f3571165 100644 --- a/tests/ovsdb-tool.at +++ b/tests/ovsdb-tool.at @@ -23,7 +23,7 @@ m4_define([OVSDB_CHECK_EXECUTION], [AT_CHECK([ovsdb-tool transact db 'txn'], [0], [stdout], [ignore]) cat stdout >> output ]) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4]) + AT_CHECK([uuidfilt output], [0], [$4]) AT_CLEANUP]) EXECUTION_EXAMPLES @@ -40,7 +40,7 @@ AT_CHECK([[ovsdb-tool transact db ' "row": {"name": "five", "number": 5}}, {"op": "comment", "comment": "add row for 5"}]']], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], +AT_CHECK([uuidfilt stdout], [0], [[[{"uuid":["uuid","<0>"]},{}] ]]) AT_CHECK([grep "add row for 5" db], [0], [ignore]) @@ -93,7 +93,7 @@ AT_CHECK( done]], [0], [stdout], [ignore]) dnl Check that all the crap is in fact in the database log. -AT_CHECK([[${PERL} $srcdir/uuidfilt.pl db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], +AT_CHECK([[uuidfilt db | grep -v ^OVSDB | sed 's/"_date":[0-9]*/"_date":0/' | ovstest test-json --multiple -]], [0], [[{"cksum":"12345678 9","name":"ordinals","tables":{"ordinals":{"columns":{"name":{"type":"string"},"number":{"type":"integer"}},"indexes":[["number"]]}},"version":"5.1.3"} {"_comment":"add row for zero 0","_date":0,"ordinals":{"<0>":{"name":"zero"}}} {"_comment":"delete row for 0","_date":0,"ordinals":{"<0>":null}} @@ -123,7 +123,7 @@ AT_CHECK([[ovsdb-client dump unix:socket ordinals]], [0], [stdout], [ignore]) OVS_APP_EXIT_AND_WAIT([ovsdb-server]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -156,7 +156,7 @@ AT_CHECK([[ovsdb-client dump unix:socket ordinals]], [0], [stdout], [ignore]) OVS_APP_EXIT_AND_WAIT([ovsdb-server]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -198,7 +198,7 @@ dnl Dump out and check the actual database contents. AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], [0]) AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ----- ------ @@ -222,7 +222,7 @@ dnl And check that the dumped data is the same except for the removed column: AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], [0]) AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid number ------------------------------------ ------ @@ -264,7 +264,7 @@ dnl Dump out and check the actual database contents. AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], [0]) AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid number ------------------------------------ ------ @@ -288,7 +288,7 @@ dnl And check that the dumped data is the same except for the added column: AT_CHECK([[ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db]], [0]) AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore]) -AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl +AT_CHECK([uuidfilt stdout], [0], [dnl ordinals table _uuid name number ------------------------------------ ---- ------ diff --git a/tests/ovsdb-trigger.at b/tests/ovsdb-trigger.at index 1da63364858f..7ba6cb326c31 100644 --- a/tests/ovsdb-trigger.at +++ b/tests/ovsdb-trigger.at @@ -9,7 +9,7 @@ m4_define([OVSDB_CHECK_TRIGGER], [AT_SETUP([$1]) AT_KEYWORDS([ovsdb execute execution trigger positive $4]) AT_CHECK([test-ovsdb trigger $2], [0], [stdout], []) - AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [$3]) + AT_CHECK([uuidfilt stdout], [0], [$3]) AT_CLEANUP]) OVSDB_CHECK_TRIGGER([trigger fires immediately], diff --git a/tests/system-kmod-macros.at b/tests/system-kmod-macros.at index 27498341a9f8..a7c6808ad1b4 100644 --- a/tests/system-kmod-macros.at +++ b/tests/system-kmod-macros.at @@ -11,7 +11,7 @@ m4_define([_ADD_BR], [[add-br $1 -- set Bridge $1 protocols=OpenFlow10,OpenFlow1 # br0 with predictable settings, passing 'vsctl-args' as additional # commands to ovs-vsctl. If 'vsctl-args' causes ovs-vsctl to provide # output (e.g. because it includes "create" commands) then 'vsctl-output' -# specifies the expected output after filtering through uuidfilt.pl. +# specifies the expected output after filtering through uuidfilt. # # Best-effort loading of all available vport modules is performed. # @@ -25,7 +25,7 @@ m4_define([OVS_TRAFFIC_VSWITCHD_START], on_exit 'ovs-dpctl del-dp ovs-system' _OVS_VSWITCHD_START([]) dnl Add bridges, ports, etc. - AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) + AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], [| uuidfilt])], [0], [$2]) ]) # OVS_TRAFFIC_VSWITCHD_STOP([WHITELIST], [extra_cmds]) diff --git a/tests/system-userspace-macros.at b/tests/system-userspace-macros.at index f3337f04499a..d3d27bb2b8f2 100644 --- a/tests/system-userspace-macros.at +++ b/tests/system-userspace-macros.at @@ -11,14 +11,14 @@ m4_define([_ADD_BR], [[add-br $1 -- set Bridge $1 datapath_type="netdev" protoco # br0 with predictable settings, passing 'vsctl-args' as additional # commands to ovs-vsctl. If 'vsctl-args' causes ovs-vsctl to provide # output (e.g. because it includes "create" commands) then 'vsctl-output' -# specifies the expected output after filtering through uuidfilt.pl. +# specifies the expected output after filtering through uuidfilt. m4_define([OVS_TRAFFIC_VSWITCHD_START], [ OVS_WAIT_WHILE([ip link show ovs-netdev]) _OVS_VSWITCHD_START([--disable-system]) dnl Add bridges, ports, etc. OVS_WAIT_WHILE([ip link show br0]) - AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) + AT_CHECK([ovs-vsctl -- _ADD_BR([br0]) -- $1 m4_if([$2], [], [], [| uuidfilt])], [0], [$2]) ]) # OVS_TRAFFIC_VSWITCHD_STOP([WHITELIST], [extra_cmds]) diff --git a/tests/uuidfilt.pl b/tests/uuidfilt.pl deleted file mode 100755 index 835f13b5344e..000000000000 --- a/tests/uuidfilt.pl +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -our %uuids; -our $n_uuids = 0; -sub lookup_uuid { - my ($uuid) = @_; - if (!exists($uuids{$uuid})) { - $uuids{$uuid} = $n_uuids++; - } - return "<$uuids{$uuid}>"; -} - -sub sort_set { - my ($s) = @_; - my (@uuids) = sort { $a <=> $b } (grep(/\d+/, split(/(\d+)/, $s))); - return '["set",[' . join(',', map('["uuid","<' . $_ . '>"]', @uuids)) . ']]'; -} - -my $u = '[0-9a-fA-F]'; -my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}"; -while (<>) { - s/($uuid_re)/lookup_uuid($1)/eg; - - # Sort sets like this: - # [["uuid","<1>"],["uuid","<0>"]] - # to look like this: - # [["uuid","<0>"],["uuid","<1>"]] - s/(\["set",\[(,?\["uuid","<\d+>"\])+\]\])/sort_set($1)/ge; - print $_; -} diff --git a/tests/uuidfilt.py b/tests/uuidfilt.py new file mode 100755 index 000000000000..ea7281296e22 --- /dev/null +++ b/tests/uuidfilt.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import re +import sys + + +def lookup_uuid(uuids, match): + return "<%s>" % uuids.setdefault(match.group(0), len(uuids)) + + +int_re = re.compile(r'\d+') + + +def sort_set(match): + s = match.group(0) + uuids = sorted([int(x) for x in int_re.findall(s)]) + return '["set",[' + ','.join('["uuid","<%s>"]' % x for x in uuids) + ']]' + + +u = '[0-9a-fA-F]' +uuid_re = re.compile(r'%s{8}-%s{4}-%s{4}-%s{4}-%s{12}' % ((u,) * 5)) +set_re = re.compile(r'(\["set",\[(,?\["uuid","<\d+>"\])+\]\])') + + +def filter_uuids(src, dst): + uuids = {} + + def lf(match): + return lookup_uuid(uuids, match) + + while True: + line = src.readline() + if not line: + break + line = uuid_re.sub(lf, line) + + # Sort sets like this: + # [["uuid","<1>"],["uuid","<0>"]] + # to look like this: + # [["uuid","<0>"],["uuid","<1>"]] + line = set_re.sub(sort_set, line) + dst.write(line) + + +if __name__ == '__main__': + if len(sys.argv) > 1: + for src in sys.argv[1:]: + filter_uuids(open(src), sys.stdout) + else: + filter_uuids(sys.stdin, sys.stdout) From patchwork Wed Nov 15 18:53:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYS11bLmz9s74 for ; Thu, 16 Nov 2017 05:53:37 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 910A0B0B; Wed, 15 Nov 2017 18:53:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 096A8AE0 for ; Wed, 15 Nov 2017 18:53:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3E8E4136 for ; Wed, 15 Nov 2017 18:53:31 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 96EF941C07E; Wed, 15 Nov 2017 19:53:28 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:11 -0800 Message-Id: <20171115185318.26841-2-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 2/9] tests: Convert ovsdb-monitor-sort utility from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- tests/automake.mk | 2 +- tests/ovsdb-monitor-sort.pl | 52 --------------------------- tests/ovsdb-monitor-sort.py | 85 +++++++++++++++++++++++++++++++++++++++++++++ tests/ovsdb-monitor.at | 4 +-- 4 files changed, 88 insertions(+), 55 deletions(-) delete mode 100755 tests/ovsdb-monitor-sort.pl create mode 100755 tests/ovsdb-monitor-sort.py diff --git a/tests/automake.mk b/tests/automake.mk index 3ca60e2ea450..1ea08fef850d 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -290,7 +290,6 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac noinst_PROGRAMS += tests/test-ovsdb tests_test_ovsdb_SOURCES = tests/test-ovsdb.c nodist_tests_test_ovsdb_SOURCES = tests/idltest.c tests/idltest.h -EXTRA_DIST += tests/ovsdb-monitor-sort.pl tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la noinst_PROGRAMS += tests/test-lib @@ -380,6 +379,7 @@ tests_test_type_props_SOURCES = tests/test-type-props.c # Python tests. CHECK_PYFILES = \ tests/appctl.py \ + tests/ovsdb-monitor-sort.py \ tests/test-daemon.py \ tests/test-json.py \ tests/test-jsonrpc.py \ diff --git a/tests/ovsdb-monitor-sort.pl b/tests/ovsdb-monitor-sort.pl deleted file mode 100755 index 24f3ffcd6162..000000000000 --- a/tests/ovsdb-monitor-sort.pl +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/perl - -use strict; -use warnings; - -# Breaks lines read from into groups using blank lines as -# group separators, then sorts lines within the groups for -# reproducibility. - -sub compare_lines { - my ($a, $b) = @_; - - my $u = '[0-9a-fA-F]'; - my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}"; - if ($a =~ /^$uuid_re/) { - if ($b =~ /^$uuid_re/) { - return substr($a, 36) cmp substr($b, 36); - } else { - return 1; - } - } elsif ($b =~ /^$uuid_re/) { - return -1; - } else { - return $a cmp $b; - } -} - -sub output_group { - my (@group) = @_; - print "$_\n" foreach sort { compare_lines($a, $b) } @group; -} - -if ("$^O" eq "msys") { - $/ = "\r\n"; -} -my @group = (); -while () { - chomp; - if ($_ eq '') { - output_group(@group); - @group = (); - print "\n"; - } else { - if (/^,/ && @group) { - $group[$#group] .= "\n" . $_; - } else { - push(@group, $_); - } - } -} - -output_group(@group) if @group; diff --git a/tests/ovsdb-monitor-sort.py b/tests/ovsdb-monitor-sort.py new file mode 100755 index 000000000000..c538d9d6b573 --- /dev/null +++ b/tests/ovsdb-monitor-sort.py @@ -0,0 +1,85 @@ +#! /usr/bin/env python + +# Breaks lines read from stdin into groups using blank lines as +# group separators, then sorts lines within the groups for +# reproducibility. + +import re +import sys + + +# This is copied out of the Python Sorting HOWTO at +# https://docs.python.org/3/howto/sorting.html#sortinghowto +def cmp_to_key(mycmp): + 'Convert a cmp= function into a key= function' + class K: + + def __init__(self, obj, *args): + self.obj = obj + + def __lt__(self, other): + return mycmp(self.obj, other.obj) < 0 + + def __gt__(self, other): + return mycmp(self.obj, other.obj) > 0 + + def __eq__(self, other): + return mycmp(self.obj, other.obj) == 0 + + def __le__(self, other): + return mycmp(self.obj, other.obj) <= 0 + + def __ge__(self, other): + return mycmp(self.obj, other.obj) >= 0 + + def __ne__(self, other): + return mycmp(self.obj, other.obj) != 0 + + return K + + +u = '[0-9a-fA-F]' +uuid_re = re.compile(r'%s{8}-%s{4}-%s{4}-%s{4}-%s{12}' % ((u,) * 5)) + + +def cmp(a, b): + return (a > b) - (a < b) + + +def compare_lines(a, b): + if uuid_re.match(a): + if uuid_re.match(b): + return cmp(a[36:], b[36:]) + else: + return 1 + elif uuid_re.match(b): + return -1 + else: + return cmp(a, b) + + +def output_group(group, dst): + for x in sorted(group, key=cmp_to_key(compare_lines)): + dst.write(x) + + +def ovsdb_monitor_sort(src, dst): + group = [] + while True: + line = src.readline() + if not line: + break + if line.rstrip() == '': + output_group(group, dst) + group = [] + dst.write(line) + elif line.startswith(',') and group: + group[len(group) - 1] += line + else: + group.append(line) + if group: + output_group(group, dst) + + +if __name__ == '__main__': + ovsdb_monitor_sort(sys.stdin, sys.stdout) diff --git a/tests/ovsdb-monitor.at b/tests/ovsdb-monitor.at index 65c595645b14..2434f43cb761 100644 --- a/tests/ovsdb-monitor.at +++ b/tests/ovsdb-monitor.at @@ -44,7 +44,7 @@ m4_define([OVSDB_CHECK_MONITOR], [ignore], [ignore]) OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid]) OVS_WAIT_UNTIL([test ! -e ovsdb-client.pid]) - AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | uuidfilt], [0], [$7], [ignore]) + AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore]) AT_CLEANUP]) # OVSDB_CHECK_MONITOR_COND(TITLE, SCHEMA, [PRE-MONITOR-TXN], DB, TABLE, @@ -86,7 +86,7 @@ m4_define([OVSDB_CHECK_MONITOR_COND], [ignore], [ignore]) AT_CHECK([ovs-appctl -t ovsdb-server -e exit], [0], [ignore], [ignore]) OVS_WAIT_UNTIL([test ! -e ovsdb-server.pid && test ! -e ovsdb-client.pid]) - AT_CHECK([${PERL} $srcdir/ovsdb-monitor-sort.pl < output | uuidfilt], [0], [$7], [ignore]) + AT_CHECK([$PYTHON $srcdir/ovsdb-monitor-sort.py < output | uuidfilt], [0], [$7], [ignore]) AT_CLEANUP]) OVSDB_CHECK_MONITOR([monitor insert into empty table], From patchwork Wed Nov 15 18:53:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838299 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYTY4tRNz9s82 for ; Thu, 16 Nov 2017 05:54:57 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 909E3BBC; Wed, 15 Nov 2017 18:53:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0CA82B92 for ; Wed, 15 Nov 2017 18:53:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AA657136 for ; Wed, 15 Nov 2017 18:53:32 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id A5B7941C095; Wed, 15 Nov 2017 19:53:30 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:12 -0800 Message-Id: <20171115185318.26841-3-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 3/9] tests: Convert flowgen utility from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- tests/automake.mk | 2 +- tests/flowgen.pl | 253 ------------------------------------------------------ tests/flowgen.py | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/library.at | 2 +- 4 files changed, 242 insertions(+), 255 deletions(-) delete mode 100755 tests/flowgen.pl create mode 100755 tests/flowgen.py diff --git a/tests/automake.mk b/tests/automake.mk index 1ea08fef850d..7eed1064e82b 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -368,7 +368,6 @@ tests_ovstest_SOURCES += \ endif tests_ovstest_LDADD = lib/libopenvswitch.la ovn/lib/libovn.la -dist_check_SCRIPTS = tests/flowgen.pl noinst_PROGRAMS += tests/test-strtok_r tests_test_strtok_r_SOURCES = tests/test-strtok_r.c @@ -379,6 +378,7 @@ tests_test_type_props_SOURCES = tests/test-type-props.c # Python tests. CHECK_PYFILES = \ tests/appctl.py \ + tests/flowgen.py \ tests/ovsdb-monitor-sort.py \ tests/test-daemon.py \ tests/test-json.py \ diff --git a/tests/flowgen.pl b/tests/flowgen.pl deleted file mode 100755 index a0fc345e7251..000000000000 --- a/tests/flowgen.pl +++ /dev/null @@ -1,253 +0,0 @@ -#! /usr/bin/perl - -# Copyright (c) 2009, 2010, 2011, 2012, 2015 Nicira, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; - -open(FLOWS, ">&=3");# or die "failed to open fd 3 for writing: $!\n"; -open(PACKETS, ">&=4");# or die "failed to open fd 4 for writing: $!\n"; - -# Print pcap file header. -print PACKETS pack('NnnNNNN', - 0xa1b2c3d4, # magic number - 2, # major version - 4, # minor version - 0, # time zone offset - 0, # time stamp accuracy - 1518, # snaplen - 1); # Ethernet - -output(DL_HEADER => '802.2'); - -for my $dl_header (qw(802.2+SNAP Ethernet)) { - my %a = (DL_HEADER => $dl_header); - for my $dl_vlan (qw(none zero nonzero)) { - my %b = (%a, DL_VLAN => $dl_vlan); - - # Non-IP case. - output(%b, DL_TYPE => 'non-ip'); - - for my $ip_options (qw(no yes)) { - my %c = (%b, DL_TYPE => 'ip', IP_OPTIONS => $ip_options); - for my $ip_fragment (qw(no first middle last)) { - my %d = (%c, IP_FRAGMENT => $ip_fragment); - for my $tp_proto (qw(TCP TCP+options UDP ICMP other)) { - output(%d, TP_PROTO => $tp_proto); - } - } - } - } -} - -sub output { - my (%attrs) = @_; - - # Compose flow. - my (%flow); - $flow{DL_SRC} = "00:02:e3:0f:80:a4"; - $flow{DL_DST} = "00:1a:92:40:ac:05"; - $flow{NW_PROTO} = 0; - $flow{NW_TOS} = 0; - $flow{NW_SRC} = '0.0.0.0'; - $flow{NW_DST} = '0.0.0.0'; - $flow{TP_SRC} = 0; - $flow{TP_DST} = 0; - if (defined($attrs{DL_VLAN})) { - my (%vlan_map) = ('none' => 0xffff, - 'zero' => 0, - 'nonzero' => 0x0123); - $flow{DL_VLAN} = $vlan_map{$attrs{DL_VLAN}}; - } else { - $flow{DL_VLAN} = 0xffff; # OFP_VLAN_NONE - } - if ($attrs{DL_HEADER} eq '802.2') { - $flow{DL_TYPE} = 0x5ff; # OFP_DL_TYPE_NOT_ETH_TYPE - } elsif ($attrs{DL_TYPE} eq 'ip') { - $flow{DL_TYPE} = 0x0800; # ETH_TYPE_IP - $flow{NW_SRC} = '10.0.2.15'; - $flow{NW_DST} = '192.168.1.20'; - $flow{NW_TOS} = 44; - if ($attrs{TP_PROTO} eq 'other') { - $flow{NW_PROTO} = 42; - } elsif ($attrs{TP_PROTO} eq 'TCP' || - $attrs{TP_PROTO} eq 'TCP+options') { - $flow{NW_PROTO} = 6; # IPPROTO_TCP - $flow{TP_SRC} = 6667; - $flow{TP_DST} = 9998; - } elsif ($attrs{TP_PROTO} eq 'UDP') { - $flow{NW_PROTO} = 17; # IPPROTO_UDP - $flow{TP_SRC} = 1112; - $flow{TP_DST} = 2223; - } elsif ($attrs{TP_PROTO} eq 'ICMP') { - $flow{NW_PROTO} = 1; # IPPROTO_ICMP - $flow{TP_SRC} = 8; # echo request - $flow{TP_DST} = 0; # code - } else { - die; - } - if ($attrs{IP_FRAGMENT} ne 'no' && $attrs{IP_FRAGMENT} ne 'first') { - $flow{TP_SRC} = $flow{TP_DST} = 0; - } - } elsif ($attrs{DL_TYPE} eq 'non-ip') { - $flow{DL_TYPE} = 0x5678; - } else { - die; - } - - # Compose packet. - my $packet = ''; - my $wildcards = 1 << 5 | 1 << 6 | 1 << 7 | 32 << 8 | 32 << 14 | 1 << 21; - - $packet .= pack_ethaddr($flow{DL_DST}); - $packet .= pack_ethaddr($flow{DL_SRC}); - if ($flow{DL_VLAN} != 0xffff) { - $packet .= pack('nn', 0x8100, $flow{DL_VLAN}); - } - my $len_ofs = length($packet); - $packet .= pack('n', 0) if $attrs{DL_HEADER} =~ /^802.2/; - if ($attrs{DL_HEADER} eq '802.2') { - $packet .= pack('CCC', 0x42, 0x42, 0x03); # LLC for 802.1D STP. - } else { - if ($attrs{DL_HEADER} eq '802.2+SNAP') { - $packet .= pack('CCC', 0xaa, 0xaa, 0x03); # LLC for SNAP. - $packet .= pack('CCC', 0, 0, 0); # SNAP OUI. - } - $packet .= pack('n', $flow{DL_TYPE}); - if ($attrs{DL_TYPE} eq 'ip') { - my $ip = pack('CCnnnCCnNN', - (4 << 4) | 5, # version, hdrlen - $flow{NW_TOS}, # type of service - 0, # total length (filled in later) - 65432, # id - 0, # frag offset - 64, # ttl - $flow{NW_PROTO}, # protocol - 0, # checksum - 0x0a00020f, # source - 0xc0a80114); # dest - $wildcards &= ~( 1 << 5 | 63 << 8 | 63 << 14 | 1 << 21); - if ($attrs{IP_OPTIONS} eq 'yes') { - substr($ip, 0, 1) = pack('C', (4 << 4) | 8); - $ip .= pack('CCnnnCCCx', - 130, # type - 11, # length - 0x6bc5, # top secret - 0xabcd, - 0x1234, - 1, - 2, - 3); - } - - if ($attrs{IP_FRAGMENT} ne 'no') { - my (%frag_map) = ('first' => 0x2000, # more frags, ofs 0 - 'middle' => 0x2111, # more frags, ofs 0x888 - 'last' => 0x0222); # last frag, ofs 0x1110 - substr($ip, 6, 2) - = pack('n', $frag_map{$attrs{IP_FRAGMENT}}); - } - if ($attrs{IP_FRAGMENT} eq 'no' || $attrs{IP_FRAGMENT} eq 'first') { - if ($attrs{TP_PROTO} =~ '^TCP') { - my $tcp = pack('nnNNnnnn', - $flow{TP_SRC}, # source port - $flow{TP_DST}, # dest port - 87123455, # seqno - 712378912, # ackno - (5 << 12) | 0x02 | 0x10, # hdrlen, SYN, ACK - 5823, # window size - 18923, # checksum - 12893); # urgent pointer - if ($attrs{TP_PROTO} eq 'TCP+options') { - substr($tcp, 12, 2) = pack('n', (6 << 12) | 0x02 | 0x10); - $tcp .= pack('CCn', 2, 4, 1975); # MSS option - } - $tcp .= 'payload'; - $ip .= $tcp; - $wildcards &= ~(1 << 6 | 1 << 7); - } elsif ($attrs{TP_PROTO} eq 'UDP') { - my $len = 15; - my $udp = pack('nnnn', $flow{TP_SRC}, $flow{TP_DST}, $len, 0); - $udp .= chr($len) while length($udp) < $len; - $ip .= $udp; - $wildcards &= ~(1 << 6 | 1 << 7); - } elsif ($attrs{TP_PROTO} eq 'ICMP') { - $ip .= pack('CCnnn', - 8, # echo request - 0, # code - 0, # checksum - 736, # identifier - 931); # sequence number - $wildcards &= ~(1 << 6 | 1 << 7); - } elsif ($attrs{TP_PROTO} eq 'other') { - $ip .= 'other header'; - } else { - die; - } - } - substr($ip, 2, 2) = pack('n', length($ip)); - $packet .= $ip; - } - } - if ($attrs{DL_HEADER} =~ /^802.2/) { - my $len = length ($packet); - $len -= 4 if $flow{DL_VLAN} != 0xffff; - substr($packet, $len_ofs, 2) = pack('n', $len); - } - - print join(' ', map("$_=$attrs{$_}", keys(%attrs))), "\n"; - print join(' ', map("$_=$flow{$_}", keys(%flow))), "\n"; - print "\n"; - - print FLOWS pack('Nn', - $wildcards, # wildcards - 1); # in_port - print FLOWS pack_ethaddr($flow{DL_SRC}); - print FLOWS pack_ethaddr($flow{DL_DST}); - print FLOWS pack('nCxnCCxxNNnn', - $flow{DL_VLAN}, - 0, # DL_VLAN_PCP - $flow{DL_TYPE}, - $flow{NW_TOS}, - $flow{NW_PROTO}, - inet_aton($flow{NW_SRC}), - inet_aton($flow{NW_DST}), - $flow{TP_SRC}, - $flow{TP_DST}); - - print PACKETS pack('NNNN', - 0, # timestamp seconds - 0, # timestamp microseconds - length($packet), # bytes saved - length($packet)), # total length - $packet; -} - -sub pack_ethaddr { - local ($_) = @_; - my $xx = '([0-9a-fA-F][0-9a-fA-F])'; - my (@octets) = /$xx:$xx:$xx:$xx:$xx:$xx/; - @octets == 6 or die $_; - my ($out) = ''; - $out .= pack('C', hex($_)) foreach @octets; - return $out; -} - -sub inet_aton { - local ($_) = @_; - my ($a, $b, $c, $d) = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; - defined $d or die $_; - return ($a << 24) | ($b << 16) | ($c << 8) | $d; -} diff --git a/tests/flowgen.py b/tests/flowgen.py new file mode 100755 index 000000000000..221a8f2bccc4 --- /dev/null +++ b/tests/flowgen.py @@ -0,0 +1,240 @@ +#! /usr/bin/env python + +# Copyright (c) 2009, 2010, 2011, 2012, 2015, 2017 Nicira, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import socket +import struct + + +def pack_ethaddr(ea): + octets = ea.split(':') + assert len(octets) == 6 + return b''.join([struct.pack('B', int(octet, 16)) for octet in octets]) + + +def output(attrs): + # Compose flow. + + flow = {} + flow['DL_SRC'] = "00:02:e3:0f:80:a4" + flow['DL_DST'] = "00:1a:92:40:ac:05" + flow['NW_PROTO'] = 0 + flow['NW_TOS'] = 0 + flow['NW_SRC'] = '0.0.0.0' + flow['NW_DST'] = '0.0.0.0' + flow['TP_SRC'] = 0 + flow['TP_DST'] = 0 + if 'DL_VLAN' in attrs: + flow['DL_VLAN'] = {'none': 0xffff, + 'zero': 0, + 'nonzero': 0x0123}[attrs['DL_VLAN']] + else: + flow['DL_VLAN'] = 0xffff # OFP_VLAN_NONE + if attrs['DL_HEADER'] == '802.2': + flow['DL_TYPE'] = 0x5ff # OFP_DL_TYPE_NOT_ETH_TYPE + elif attrs['DL_TYPE'] == 'ip': + flow['DL_TYPE'] = 0x0800 # ETH_TYPE_IP + flow['NW_SRC'] = '10.0.2.15' + flow['NW_DST'] = '192.168.1.20' + flow['NW_TOS'] = 44 + if attrs['TP_PROTO'] == 'other': + flow['NW_PROTO'] = 42 + elif attrs['TP_PROTO'] in ('TCP', 'TCP+options'): + flow['NW_PROTO'] = 6 # IPPROTO_TCP + flow['TP_SRC'] = 6667 + flow['TP_DST'] = 9998 + elif attrs['TP_PROTO'] == 'UDP': + flow['NW_PROTO'] = 17 # IPPROTO_UDP + flow['TP_SRC'] = 1112 + flow['TP_DST'] = 2223 + elif attrs['TP_PROTO'] == 'ICMP': + flow['NW_PROTO'] = 1 # IPPROTO_ICMP + flow['TP_SRC'] = 8 # echo request + flow['TP_DST'] = 0 # code + else: + assert False + if attrs['IP_FRAGMENT'] not in ('no', 'first'): + flow['TP_SRC'] = flow['TP_DST'] = 0 + elif attrs['DL_TYPE'] == 'non-ip': + flow['DL_TYPE'] = 0x5678 + else: + assert False + + # Compose packet + packet = b'' + wildcards = 1 << 5 | 1 << 6 | 1 << 7 | 32 << 8 | 32 << 14 | 1 << 21 + + packet += pack_ethaddr(flow['DL_DST']) + packet += pack_ethaddr(flow['DL_SRC']) + if flow['DL_VLAN'] != 0xffff: + packet += struct.pack('>HH', 0x8100, flow['DL_VLAN']) + len_ofs = len(packet) + if attrs['DL_HEADER'].startswith('802.2'): + packet += struct.pack('>H', 0) + if attrs['DL_HEADER'] == '802.2': + packet += struct.pack('BBB', 0x42, 0x42, 0x03) # LLC for 802.1D STP + else: + if attrs['DL_HEADER'] == '802.2+SNAP': + packet += struct.pack('BBB', 0xaa, 0xaa, 0x03) # LLC for SNAP + packet += struct.pack('BBB', 0, 0, 0) # SNAP OUI + packet += struct.pack('>H', flow['DL_TYPE']) + if attrs['DL_TYPE'] == 'ip': + ip = struct.pack('>BBHHHBBHLL', + (4 << 4) | 5, # version, hdrlen + flow['NW_TOS'], # type of service + 0, # total length, filled in later + 65432, # id + 0, # frag offset + 64, # ttl + flow['NW_PROTO'], # protocol + 0, # checksum + 0x0a00020f, # source + 0xc0a80114) # dest + wildcards &= ~(1 << 5 | 63 << 8 | 63 << 14 | 1 << 21) + if attrs['IP_OPTIONS'] == 'yes': + ip = struct.pack('B', (4 << 4) | 8) + ip[1:] + ip += struct.pack('>BBHHHBBBx', + 130, # type + 11, # length + 0x6bc5, # top secret + 0xabcd, + 0x1234, + 1, + 2, + 3) + if attrs['IP_FRAGMENT'] != 'no': + frag_map = {'first': 0x2000, # more frags, ofs 0 + 'middle': 0x2111, # more frags, ofs 0x888 + 'last': 0x0222} # last frag, ofs 0x1110 + ip = (ip[:6] + + struct.pack('>H', frag_map[attrs['IP_FRAGMENT']]) + + ip[8:]) + if attrs['IP_FRAGMENT'] in ('no', 'first'): + if attrs['TP_PROTO'].startswith('TCP'): + tcp = struct.pack('>HHLLHHHH', + flow['TP_SRC'], # source port + flow['TP_DST'], # dest port + 87123455, # seqno + 712378912, # ackno + (5 << 12) | 0x02 | 0x10, + # hdrlen, SYN, ACK + 5823, # window size + 18923, # checksum + 12893) # urgent pointer + if attrs['TP_PROTO'] == 'TCP+options': + tcp = (tcp[:12] + + struct.pack('H', (6 << 12) | 0x02 | 0x10) + + tcp[14:]) + tcp += struct.pack('>BBH', 2, 4, 1975) # MSS option + tcp += b'payload' + ip += tcp + wildcards &= ~(1 << 6 | 1 << 7) + elif attrs['TP_PROTO'] == 'UDP': + udp_len = 15 + udp = struct.pack('>HHHH', + flow['TP_SRC'], + flow['TP_DST'], + udp_len, 0) + while len(udp) < udp_len: + udp += struct.pack('B', udp_len) + ip += udp + wildcards &= ~(1 << 6 | 1 << 7) + elif attrs['TP_PROTO'] == 'ICMP': + ip += struct.pack('>BBHHH', + 8, # echo request + 0, # code + 0, # checksum + 736, # identifier + 931) # sequence number + wildcards &= ~(1 << 6 | 1 << 7) + elif attrs['TP_PROTO'] == 'other': + ip += b'other header' + else: + assert False + ip = ip[:2] + struct.pack('>H', len(ip)) + ip[4:] + packet += ip + if attrs['DL_HEADER'].startswith('802.2'): + packet_len = len(packet) + if flow['DL_VLAN'] != 0xffff: + packet_len -= 4 + packet = (packet[:len_ofs] + + struct.pack('>H', packet_len) + + packet[len_ofs + 2:]) + + print(' '.join(['%s=%s' for k, v in attrs.items()])) + print(' '.join(['%s=%s' for k, v in flow.items()])) + print() + + flows.write(struct.pack('>LH', + wildcards, # wildcards + 1)) # in_port + flows.write(pack_ethaddr(flow['DL_SRC'])) + flows.write(pack_ethaddr(flow['DL_DST'])) + flows.write(struct.pack('>HBxHBBxx', + flow['DL_VLAN'], + 0, # DL_VLAN_PCP + flow['DL_TYPE'], + flow['NW_TOS'], + flow['NW_PROTO'])) + flows.write(socket.inet_aton(flow['NW_SRC'])) + flows.write(socket.inet_aton(flow['NW_DST'])) + flows.write(struct.pack('>HH', flow['TP_SRC'], flow['TP_DST'])) + + packets.write(struct.pack('>LLLL', + 0, # timestamp seconds + 0, # timestamp microseconds + len(packet), # bytes saved + len(packet))) # total length + packets.write(packet) + + +flows = os.fdopen(3, 'wb') +packets = os.fdopen(4, 'wb') + +# Print pcap file header. +packets.write(struct.pack('>LHHLLLL', + 0xa1b2c3d4, # magic number + 2, # major version + 4, # minor version + 0, # time zone offset + 0, # time stamp accuracy + 1518, # snaplen + 1)) # Ethernet + +output({'DL_HEADER': '802.2'}) + +for dl_header in ('802.2+SNAP', 'Ethernet'): + a = {'DL_HEADER': dl_header} + for dl_vlan in ('none', 'zero', 'nonzero'): + b = a.copy() + b['DL_VLAN'] = dl_vlan + + # Non-IP case. + c = b.copy() + c['DL_TYPE'] = 'non-ip' + output(c) + + for ip_options in ('no', 'yes'): + c = b.copy() + c['DL_TYPE'] = 'ip' + c['IP_OPTIONS'] = ip_options + for ip_fragment in ('no', 'first', 'middle', 'last'): + d = c.copy() + d['IP_FRAGMENT'] = ip_fragment + for tp_proto in ('TCP', 'TCP+options', 'UDP', 'ICMP', 'other'): + e = d.copy() + e['TP_PROTO'] = tp_proto + output(e) diff --git a/tests/library.at b/tests/library.at index 6073abfbd6e7..5efbfbb7c02a 100644 --- a/tests/library.at +++ b/tests/library.at @@ -1,7 +1,7 @@ AT_BANNER([library unit tests]) AT_SETUP([flow extractor]) -AT_CHECK([$PERL `which flowgen.pl` >/dev/null 3>flows 4>pcap]) +AT_CHECK([$PYTHON $srcdir/flowgen.py >/dev/null 3>flows 4>pcap]) AT_CHECK([ovstest test-flows flows pcap], [0], [checked 247 packets, 0 errors ]) AT_CLEANUP From patchwork Wed Nov 15 18:53:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYVD3Bfqz9s82 for ; Thu, 16 Nov 2017 05:55:32 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8244DC01; Wed, 15 Nov 2017 18:53:37 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E0186B00 for ; Wed, 15 Nov 2017 18:53:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 39601113 for ; Wed, 15 Nov 2017 18:53:34 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 1D35141C096; Wed, 15 Nov 2017 19:53:31 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:13 -0800 Message-Id: <20171115185318.26841-4-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.2 required=5.0 tests=RCVD_IN_DNSWL_LOW, URI_NOVOWEL autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 4/9] tests: Convert dpdkstrip utility from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- Makefile.am | 4 ++-- build-aux/automake.mk | 3 ++- build-aux/dpdkstrip.pl | 35 ------------------------------ build-aux/dpdkstrip.py | 48 +++++++++++++++++++++++++++++++++++++++++ rhel/openvswitch-fedora.spec.in | 2 +- 5 files changed, 53 insertions(+), 39 deletions(-) delete mode 100644 build-aux/dpdkstrip.pl create mode 100755 build-aux/dpdkstrip.py diff --git a/Makefile.am b/Makefile.am index 5d19f0833afc..c82a9e21ec36 100644 --- a/Makefile.am +++ b/Makefile.am @@ -86,7 +86,7 @@ EXTRA_DIST = \ build-aux/cksum-schema-check \ build-aux/calculate-schema-cksum \ build-aux/dist-docs \ - build-aux/dpdkstrip.pl \ + build-aux/dpdkstrip.py \ build-aux/sodepends.pl \ build-aux/soexpand.pl \ build-aux/xml2nroff \ @@ -145,7 +145,7 @@ ro_shell = printf '\043 Generated automatically -- do not modify! -*- buffer- SUFFIXES += .in .in: $(AM_V_GEN)$(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \ - $(PERL) $(srcdir)/build-aux/dpdkstrip.pl $(DPDKSTRIP_FLAGS) | \ + $(PYTHON) $(srcdir)/build-aux/dpdkstrip.py $(DPDKSTRIP_FLAGS) | \ sed \ -e 's,[@]PKIDIR[@],$(PKIDIR),g' \ -e 's,[@]LOGDIR[@],$(LOGDIR),g' \ diff --git a/build-aux/automake.mk b/build-aux/automake.mk index 9500e3a69402..c0553e6edffb 100644 --- a/build-aux/automake.mk +++ b/build-aux/automake.mk @@ -1,3 +1,4 @@ # This file is purely used for checking the style of the python build tools. FLAKE8_PYFILES += \ - $(srcdir)/build-aux/xml2nroff + $(srcdir)/build-aux/xml2nroff \ + build-aux/dpdkstrip.py diff --git a/build-aux/dpdkstrip.pl b/build-aux/dpdkstrip.pl deleted file mode 100644 index 98539cce8241..000000000000 --- a/build-aux/dpdkstrip.pl +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2017 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; -use Getopt::Long; - -my ($check_dpdk) = 0; -my ($disabled_print) = 0; - -Getopt::Long::Configure ("bundling"); -GetOptions("dpdk!" => \$check_dpdk) or exit(1); - -OUTER: while () { - if (/@(begin|end)_dpdk@/) { - if (!$check_dpdk) { - $disabled_print = ! $disabled_print; - } - next; - } - - print $_ unless $disabled_print; -} -exit 0; diff --git a/build-aux/dpdkstrip.py b/build-aux/dpdkstrip.py new file mode 100755 index 000000000000..48c7f06934ef --- /dev/null +++ b/build-aux/dpdkstrip.py @@ -0,0 +1,48 @@ +#! /usr/bin/env python +# Copyright (c) 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import getopt +import sys + + +def strip_dpdk(check_dpdk, src, dst): + disabled_print = False + while True: + line = src.readline() + if not line: + break + if '@begin_dpdk@' in line or '@end_dpdk@' in line: + if not check_dpdk: + disabled_print = not disabled_print + continue + if not disabled_print: + dst.write(line) + + +if __name__ == '__main__': + check_dpdk = False + options, args = getopt.gnu_getopt(sys.argv[1:], '', ['dpdk', 'nodpdk']) + for key, value in options: + if key == '--dpdk': + check_dpdk = True + elif key == '--nodpdk': + check_dpdk = False + else: + assert False + if args: + for arg in args: + strip_dpdk(check_dpdk, open(arg), sys.stdout) + else: + strip_dpdk(check_dpdk, sys.stdin, sys.stdout) diff --git a/rhel/openvswitch-fedora.spec.in b/rhel/openvswitch-fedora.spec.in index b45e018f5ee9..e600a943cde6 100644 --- a/rhel/openvswitch-fedora.spec.in +++ b/rhel/openvswitch-fedora.spec.in @@ -229,7 +229,7 @@ Docker network plugins for OVN. --enable-ssl \ --with-pkidir=%{_sharedstatedir}/openvswitch/pki -/usr/bin/perl build-aux/dpdkstrip.pl \ +build-aux/dpdkstrip.py \ %if %{with dpdk} --dpdk \ %else From patchwork Wed Nov 15 18:53:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838301 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYW70RBgz9s74 for ; Thu, 16 Nov 2017 05:56:19 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2B931C27; Wed, 15 Nov 2017 18:53:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 1C8C5BD7 for ; Wed, 15 Nov 2017 18:53:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 910CA113 for ; Wed, 15 Nov 2017 18:53:35 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9322341C091; Wed, 15 Nov 2017 19:53:33 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:14 -0800 Message-Id: <20171115185318.26841-5-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.2 required=5.0 tests=RCVD_IN_DNSWL_LOW, URI_NOVOWEL autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 5/9] tests: Convert soexpand build tool from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- Makefile.am | 4 +-- build-aux/automake.mk | 3 +- build-aux/soexpand.pl | 40 --------------------- build-aux/soexpand.py | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 43 deletions(-) delete mode 100644 build-aux/soexpand.pl create mode 100755 build-aux/soexpand.py diff --git a/Makefile.am b/Makefile.am index c82a9e21ec36..11e2e6d21005 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,7 +88,7 @@ EXTRA_DIST = \ build-aux/dist-docs \ build-aux/dpdkstrip.py \ build-aux/sodepends.pl \ - build-aux/soexpand.pl \ + build-aux/soexpand.py \ build-aux/xml2nroff \ $(MAN_FRAGMENTS) \ $(MAN_ROOTS) \ @@ -144,7 +144,7 @@ ro_shell = printf '\043 Generated automatically -- do not modify! -*- buffer- SUFFIXES += .in .in: - $(AM_V_GEN)$(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \ + $(AM_V_GEN)$(PYTHON) $(srcdir)/build-aux/soexpand.py -I$(srcdir) < $< | \ $(PYTHON) $(srcdir)/build-aux/dpdkstrip.py $(DPDKSTRIP_FLAGS) | \ sed \ -e 's,[@]PKIDIR[@],$(PKIDIR),g' \ diff --git a/build-aux/automake.mk b/build-aux/automake.mk index c0553e6edffb..1003144fd664 100644 --- a/build-aux/automake.mk +++ b/build-aux/automake.mk @@ -1,4 +1,5 @@ # This file is purely used for checking the style of the python build tools. FLAKE8_PYFILES += \ $(srcdir)/build-aux/xml2nroff \ - build-aux/dpdkstrip.py + build-aux/dpdkstrip.py \ + build-aux/soexpand.py diff --git a/build-aux/soexpand.pl b/build-aux/soexpand.pl deleted file mode 100644 index 216256451a4d..000000000000 --- a/build-aux/soexpand.pl +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) 2008 Nicira, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; -use Getopt::Long; - -my ($exit_code) = 0; -my (@include_dirs); -Getopt::Long::Configure ("bundling"); -GetOptions("I|include=s" => \@include_dirs) or exit(1); -@include_dirs = ('.') if !@include_dirs; -OUTER: while () { - if (my ($name) = /^\.so (\S+)$/) { - foreach my $dir (@include_dirs, '.') { - if (open(INNER, "$dir/$name")) { - while () { - print $_; - } - close(INNER); - next OUTER; - } - } - print STDERR "$name not found in: ", join(' ', @include_dirs), "\n"; - $exit_code = 1; - } - print $_; -} -exit $exit_code; diff --git a/build-aux/soexpand.py b/build-aux/soexpand.py new file mode 100755 index 000000000000..fe99b461f980 --- /dev/null +++ b/build-aux/soexpand.py @@ -0,0 +1,97 @@ +#! /usr/bin/env python + +# Copyright (c) 2008, 2017 Nicira, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import getopt +import os +import re +import sys + + +def parse_include_dirs(): + include_dirs = [] + options, args = getopt.gnu_getopt(sys.argv[1:], 'I:', ['include=']) + for key, value in options: + if key in ['-I', '--include']: + include_dirs.append(value) + else: + assert False + + include_dirs.append('.') + return include_dirs, args + + +def find_file(include_dirs, name): + for dir in include_dirs: + file = "%s/%s" % (dir, name) + try: + os.stat(file) + return file + except IOError as e: + pass + sys.stderr.write("%s not found in: %s\n" % (name, ' '.join(include_dirs))) + return None + + +so_re = re.compile(r'^\.so (\S+)$') + + +def extract_include_directive(line): + m = so_re.match(line) + if m: + return m.group(1) + else: + return None + + +def soexpand(include_dirs, src, dst): + ok = True + while True: + line = src.readline() + if not line: + break + + name = extract_include_directive(line) + if name: + fn = find_file(include_dirs, name) + if fn: + try: + f = open(fn) + while True: + inner = f.readline() + if not inner: + break + dst.write(inner) + except IOError as e: + sys.stderr.write("%s: open: %s\n" % (fn, e.strerror)) + ok = False + continue + else: + ok = False + + dst.write(line) + return ok + + +if __name__ == '__main__': + include_dirs, args = parse_include_dirs() + if args: + error = False + for arg in args: + if not soexpand(include_dirs, open(arg), sys.stdout): + error = True + else: + error = not soexpand(include_dirs, sys.stdin, sys.stdout) + sys.exit(1 if error else 0) From patchwork Wed Nov 15 18:53:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838302 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYWg3VR6z9s74 for ; Thu, 16 Nov 2017 05:56:47 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 095C6C49; Wed, 15 Nov 2017 18:53:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9422DC09 for ; Wed, 15 Nov 2017 18:53:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 06E24113 for ; Wed, 15 Nov 2017 18:53:37 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 0C3B941C093; Wed, 15 Nov 2017 19:53:34 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:15 -0800 Message-Id: <20171115185318.26841-6-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.2 required=5.0 tests=RCVD_IN_DNSWL_LOW, URI_NOVOWEL autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 6/9] tests: Convert sodepends build tool from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- Makefile.am | 6 +-- build-aux/automake.mk | 1 + build-aux/sodepends.pl | 70 --------------------------------- build-aux/sodepends.py | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 73 deletions(-) delete mode 100644 build-aux/sodepends.pl create mode 100755 build-aux/sodepends.py diff --git a/Makefile.am b/Makefile.am index 11e2e6d21005..5bcd2919c1b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -87,7 +87,7 @@ EXTRA_DIST = \ build-aux/calculate-schema-cksum \ build-aux/dist-docs \ build-aux/dpdkstrip.py \ - build-aux/sodepends.pl \ + build-aux/sodepends.py \ build-aux/soexpand.py \ build-aux/xml2nroff \ $(MAN_FRAGMENTS) \ @@ -394,8 +394,8 @@ endif CLEANFILES += flake8-check include $(srcdir)/manpages.mk -$(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl - @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp +$(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.py + @$(PYTHON) $(srcdir)/build-aux/sodepends.py -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp @if cmp -s $(@F).tmp $@; then \ touch $@; \ rm -f $(@F).tmp; \ diff --git a/build-aux/automake.mk b/build-aux/automake.mk index 1003144fd664..6baafab0e867 100644 --- a/build-aux/automake.mk +++ b/build-aux/automake.mk @@ -2,4 +2,5 @@ FLAKE8_PYFILES += \ $(srcdir)/build-aux/xml2nroff \ build-aux/dpdkstrip.py \ + build-aux/sodepends.py \ build-aux/soexpand.py diff --git a/build-aux/sodepends.pl b/build-aux/sodepends.pl deleted file mode 100644 index 333d037f2dcf..000000000000 --- a/build-aux/sodepends.pl +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (c) 2008, 2011 Nicira, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at: -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; -use Getopt::Long; - -our ($exit_code) = 0; - -our (@include_dirs); -Getopt::Long::Configure ("bundling"); -GetOptions("I|include=s" => \@include_dirs) or exit(1); -@include_dirs = ('.') if !@include_dirs; - -sub find_file { - my ($name) = @_; - foreach my $dir (@include_dirs, '.') { - my $file = "$dir/$name"; - if (stat($file)) { - return $file; - } - } - print STDERR "$name not found in: ", join(' ', @include_dirs), "\n"; - $exit_code = 1; - return; -} - -print "# Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n"; -for my $toplevel (sort(@ARGV)) { - # Skip names that don't end in .in. - next if $toplevel !~ /\.in$/; - - # Open file. - my ($fn) = find_file($toplevel); - next if !defined($fn); - if (!open(OUTER, '<', $fn)) { - print "$fn: open: $!\n"; - $exit_code = 1; - next; - } - - my (@dependencies); - OUTER: - while () { - if (my ($name) = /^\.so (\S+)$/) { - push(@dependencies, $name) if find_file($name); - } - } - close(OUTER); - - my ($output) = $toplevel; - $output =~ s/\.in//; - - print "\n$output:"; - print " \\\n\t$_" foreach $toplevel, sort(@dependencies); - print "\n"; - print "$_:\n" foreach $toplevel, sort(@dependencies); -} -exit $exit_code; diff --git a/build-aux/sodepends.py b/build-aux/sodepends.py new file mode 100755 index 000000000000..fafe900b9965 --- /dev/null +++ b/build-aux/sodepends.py @@ -0,0 +1,105 @@ +#! /usr/bin/env python + +# Copyright (c) 2008, 2011, 2017 Nicira, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re +import sys +import getopt + + +def parse_include_dirs(): + include_dirs = [] + options, args = getopt.gnu_getopt(sys.argv[1:], 'I:', ['include=']) + for key, value in options: + if key in ['-I', '--include']: + include_dirs.append(value) + else: + assert False + + include_dirs.append('.') + return include_dirs, args + + +def find_file(include_dirs, name): + for dir in include_dirs: + file = "%s/%s" % (dir, name) + try: + os.stat(file) + return file + except OSError as e: + pass + sys.stderr.write("%s not found in: %s\n" % (name, ' '.join(include_dirs))) + return None + + +so_re = re.compile(r'^\.so (\S+)$') + + +def extract_include_directive(line): + m = so_re.match(line) + if m: + return m.group(1) + else: + return None + + +def sodepends(include_dirs, filenames, dst): + ok = True + print("# Generated automatically -- do not modify! " + "-*- buffer-read-only: t -*-") + for toplevel in sorted(filenames): + # Skip names that don't end in .in. + if not toplevel.endswith('.in'): + continue + + # Open file. + fn = find_file(include_dirs, toplevel) + if not fn: + ok = False + continue + try: + outer = open(fn) + except IOError as e: + sys.stderr.write("%s: open: %s\n" % (fn, e.strerror)) + ok = False + continue + + dependencies = [] + while True: + line = outer.readline() + if not line: + break + + name = extract_include_directive(line) + if name: + if find_file(include_dirs, name): + dependencies.append(name) + else: + ok = False + + dst.write("\n%s:" % toplevel[:-3]) + for s in [toplevel] + sorted(dependencies): + dst.write(' \\\n\t%s' % s) + dst.write('\n') + for s in [toplevel] + sorted(dependencies): + dst.write('%s:\n' % s) + return ok + + +if __name__ == '__main__': + include_dirs, args = parse_include_dirs() + error = not sodepends(include_dirs, args, sys.stdout) + sys.exit(1 if error else 0) From patchwork Wed Nov 15 18:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYXJ3zwlz9s74 for ; Thu, 16 Nov 2017 05:57:20 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 24F48BE8; Wed, 15 Nov 2017 18:53:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 10CF0C24 for ; Wed, 15 Nov 2017 18:53:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6E993136 for ; Wed, 15 Nov 2017 18:53:38 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 7A2A841C07E; Wed, 15 Nov 2017 19:53:36 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:16 -0800 Message-Id: <20171115185318.26841-7-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 7/9] tests: Convert dot2pic build tool from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- ovn/automake.mk | 4 +- ovsdb/dot2pic | 155 +++++++++++++++++++++++++++++++-------------------- vswitchd/automake.mk | 2 +- vtep/automake.mk | 2 +- 4 files changed, 100 insertions(+), 63 deletions(-) diff --git a/ovn/automake.mk b/ovn/automake.mk index c5925e9285ac..b33112ef14e5 100644 --- a/ovn/automake.mk +++ b/ovn/automake.mk @@ -11,7 +11,7 @@ if HAVE_DOT ovn/ovn-sb.gv: ovsdb/ovsdb-dot.in ovn/ovn-sb.ovsschema $(AM_V_GEN)$(OVSDB_DOT) --no-arrows $(srcdir)/ovn/ovn-sb.ovsschema > $@ ovn/ovn-sb.pic: ovn/ovn-sb.gv ovsdb/dot2pic - $(AM_V_GEN)(dot -T plain < ovn/ovn-sb.gv | $(PERL) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ + $(AM_V_GEN)(dot -T plain < ovn/ovn-sb.gv | $(PYTHON) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ mv $@.tmp $@ OVN_SB_PIC = ovn/ovn-sb.pic OVN_SB_DOT_DIAGRAM_ARG = --er-diagram=$(OVN_SB_PIC) @@ -45,7 +45,7 @@ if HAVE_DOT ovn/ovn-nb.gv: ovsdb/ovsdb-dot.in ovn/ovn-nb.ovsschema $(AM_V_GEN)$(OVSDB_DOT) --no-arrows $(srcdir)/ovn/ovn-nb.ovsschema > $@ ovn/ovn-nb.pic: ovn/ovn-nb.gv ovsdb/dot2pic - $(AM_V_GEN)(dot -T plain < ovn/ovn-nb.gv | $(PERL) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ + $(AM_V_GEN)(dot -T plain < ovn/ovn-nb.gv | $(PYTHON) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ mv $@.tmp $@ OVN_NB_PIC = ovn/ovn-nb.pic OVN_NB_DOT_DIAGRAM_ARG = --er-diagram=$(OVN_NB_PIC) diff --git a/ovsdb/dot2pic b/ovsdb/dot2pic index d682be5f9610..51d454b62e18 100755 --- a/ovsdb/dot2pic +++ b/ovsdb/dot2pic @@ -1,6 +1,6 @@ -#! /usr/bin/perl +#! /usr/bin/env python -# Copyright (c) 2009, 2010, 2011, 2013 Nicira, Inc. +# Copyright (c) 2009, 2010, 2011, 2013, 2017 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,67 +14,104 @@ # See the License for the specific language governing permissions and # limitations under the License. -use strict; -use warnings; +import getopt +import sys -use Getopt::Long; +def dot2pic(src, dst): + scale = 1.0 + while True: + line = src.readline() + if not line: + break -my $font_scale = 0; -GetOptions("f=i" => \$font_scale) || exit 1; + words = line.split() + command = words[0] + if command == 'graph': + scale = float(words[1]) + elif command == 'node': + name = words[1] + x = float(words[2]) + y = float(words[3]) + width = float(words[4]) + height = float(words[5]) + label, style, shape, color, fillcolor = words[6:11] + x *= scale + y *= scale + width *= scale + height *= scale + dst.write("linethick = %f;\n" % (0.5 if style == 'bold' else 1.0)) + dst.write('box at %f,%f wid %f height %f "%s"\n' + % (x, y, width, height, name)) + if style == 'bold': + inset = 2.0 / 72.0 + width -= inset * 2 + height -= inset * 2 + dst.write("box at %f,%f wid %f height %f\n" + % (x, y, width, height)) + elif command == 'edge': + tail = words[1] + head = words[2] + n = int(words[3]) -my ($scale) = 1; -printf ".ps %+d\n", -$font_scale if $font_scale; -print ".PS\n"; -print "linethick = 1;\n"; -while (<>) { - if (/^graph/) { - (undef, $scale) = split; - } elsif (/^node/) { - my (undef, $name, $x, $y, $width, $height, $label, $style, $shape, $color, $fillcolor) = split; - $x *= $scale; - $y *= $scale; - $width *= $scale; - $height *= $scale; - print "linethick = ", ($style eq 'bold' ? 0.5 : 1.0), ";\n"; - print "box at $x,$y wid $width height $height \"$name\"\n"; - if ($style eq 'bold') { - my $inset = 2.0 / 72.0; - $width -= $inset * 2; - $height -= $inset * 2; - print "box at $x,$y wid $width height $height\n"; - } - } elsif (/edge/) { - my (undef, $tail, $head, $n, $rest) = split(' ', $_, 5); - my @xy; - for (1...$n) { - my ($x, $y); - ($x, $y, $rest) = split(' ', $rest, 3); - push(@xy, [$x * $scale, $y * $scale]); - } - my ($label, $xl, $yl); - if (scalar(my @junk = split(' ', $rest)) > 2) { - if ($rest =~ s/^"([^"]*)"\s+//) { - $label = $1; - } else { - ($label, $rest) = split(' ', $rest, 2); - } - ($xl, $yl, $rest) = split(' ', $rest, 3); - $xl *= $scale; - $yl *= $scale; - } - my ($style, $color) = split(' ', $rest); + # Extract x,y coordinates. + words = words[4:] + xy = [] + for i in range(n): + x = float(words[0]) * scale + y = float(words[1]) * scale + words = words[2:] + xy.append((x, y)) - print "linethick = ", ($style eq 'dotted' ? 0.5 : 1), ";\n"; + # Extract style and color from end of words. + style, color = words[-2:] + words = words[:-2] - print "spline -> from $xy[0][0],$xy[0][1]"; - for (my ($i) = 0; $i <= $#xy; $i++) { - print " to $xy[$i][0],$xy[$i][1]"; - } - print "\n"; + # If there's anything left, that's the label. + if words: + xl = float(words[-2]) * scale + yl = float(words[-1]) * scale + label = ' '.join(words[:-2]) + if label.startswith('"') and label.endswith('"'): + label = label[1:-1] + else: + label = None + + dst.write("linethick = %f;\n" + % (0.5 if style == 'dotted' else 1.0)) + dst.write("spline -> from %f,%f" % xy[0]) + for x, y in xy: + dst.write(" to %f,%f" % (x, y)) + dst.write('\n') - print "\"$label\" at $xl,$yl\n" if defined($label); - } + if label: + dst.write('"%s" at %f,%f\n' % (label, xl, yl)) + elif command == 'stop': + break + else: + sys.stderr.write("%s\n" % command) + assert False + + +options, args = getopt.gnu_getopt(sys.argv[1:], 'f:', []) + +font_scale = 0 +for key, value in options: + if key == '-f': + font_scale = int(value) + else: + raise False + +if font_scale: + print(".ps %+d" % -font_scale) + +print(".PS") +print("linethick = 1;") +if args: + for arg in args: + dot2pic(open(arg), sys.stdout) +else: + dot2pic(sys.stdin, sys.stdout) +if font_scale: + print(".ps %+d" % font_scale) +print(".PE") -} -printf ".ps %+d\n", $font_scale if $font_scale; -print ".PE\n"; diff --git a/vswitchd/automake.mk b/vswitchd/automake.mk index aa4224561f3d..abdbcc698ba7 100644 --- a/vswitchd/automake.mk +++ b/vswitchd/automake.mk @@ -31,7 +31,7 @@ if HAVE_DOT vswitchd/vswitch.gv: ovsdb/ovsdb-dot.in vswitchd/vswitch.ovsschema $(AM_V_GEN)$(OVSDB_DOT) --no-arrows $(srcdir)/vswitchd/vswitch.ovsschema > $@ vswitchd/vswitch.pic: vswitchd/vswitch.gv ovsdb/dot2pic - $(AM_V_GEN)(dot -T plain < vswitchd/vswitch.gv | $(PERL) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ + $(AM_V_GEN)(dot -T plain < vswitchd/vswitch.gv | $(PYTHON) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ mv $@.tmp $@ VSWITCH_PIC = vswitchd/vswitch.pic VSWITCH_DOT_DIAGRAM_ARG = --er-diagram=$(VSWITCH_PIC) diff --git a/vtep/automake.mk b/vtep/automake.mk index 069e1906c565..0f313dce3efc 100644 --- a/vtep/automake.mk +++ b/vtep/automake.mk @@ -58,7 +58,7 @@ if HAVE_DOT vtep/vtep.gv: ovsdb/ovsdb-dot.in vtep/vtep.ovsschema $(AM_V_GEN)$(OVSDB_DOT) --no-arrows $(srcdir)/vtep/vtep.ovsschema > $@ vtep/vtep.pic: vtep/vtep.gv ovsdb/dot2pic - $(AM_V_GEN)(dot -T plain < vtep/vtep.gv | $(PERL) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ + $(AM_V_GEN)(dot -T plain < vtep/vtep.gv | $(PYTHON) $(srcdir)/ovsdb/dot2pic -f 3) > $@.tmp && \ mv $@.tmp $@ VTEP_PIC = vtep/vtep.pic VTEP_DOT_DIAGRAM_ARG = --er-diagram=$(VTEP_PIC) From patchwork Wed Nov 15 18:53:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838304 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYXx1yk2z9s74 for ; Thu, 16 Nov 2017 05:57:53 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 29FCCC46; Wed, 15 Nov 2017 18:53:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 65B63C0D for ; Wed, 15 Nov 2017 18:53:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 010A0136 for ; Wed, 15 Nov 2017 18:53:39 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id E2C3941C08F; Wed, 15 Nov 2017 19:53:37 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:17 -0800 Message-Id: <20171115185318.26841-8-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 8/9] tests: Convert miscellaneous test code from Perl to Python. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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 () { - 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: From patchwork Wed Nov 15 18:53:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 838305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycYYY2H5Yz9s74 for ; Thu, 16 Nov 2017 05:58:25 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 16879C8B; Wed, 15 Nov 2017 18:53:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 6D07BC7C for ; Wed, 15 Nov 2017 18:53:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B11591AE for ; Wed, 15 Nov 2017 18:53:41 +0000 (UTC) X-Originating-IP: 208.91.3.26 Received: from sigabrt.benpfaff.org (unknown [208.91.3.26]) (Authenticated sender: blp@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 7665D41C07C; Wed, 15 Nov 2017 19:53:39 +0100 (CET) From: Ben Pfaff To: dev@openvswitch.org Date: Wed, 15 Nov 2017 10:53:18 -0800 Message-Id: <20171115185318.26841-9-blp@ovn.org> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20171115185318.26841-1-blp@ovn.org> References: <20171115185318.26841-1-blp@ovn.org> X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 9/9] Remove Perl dependency. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Nothing in the OVS tree uses Perl any longer, so remove the dependency. Signed-off-by: Ben Pfaff --- Documentation/intro/install/general.rst | 8 -------- Makefile.am | 2 -- configure.ac | 6 ------ tests/atlocal.in | 1 - tests/ovs-macros.at | 1 - 5 files changed, 18 deletions(-) diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst index e5ec155b94af..1485bdc19980 100644 --- a/Documentation/intro/install/general.rst +++ b/Documentation/intro/install/general.rst @@ -138,11 +138,6 @@ schema, you will also need the following software: - libtool version 2.4 or later. (Older versions might work too.) -To run the unit tests, you also need: - -- Perl. Version 5.10.1 is known to work. Earlier versions should also - work. - The datapath tests for userspace and Linux datapaths also rely upon: - pyftpdlib. Version 1.2.0 is known to work. Earlier versions should @@ -162,9 +157,6 @@ other than plain text, only if you have the following: - dot from graphviz (http://www.graphviz.org/). -- Perl. Version 5.10.1 is known to work. Earlier versions should also - work. - If you are going to extensively modify Open vSwitch, consider installing the following to obtain better warnings: diff --git a/Makefile.am b/Makefile.am index 5bcd2919c1b4..ba62e781ffdb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -150,7 +150,6 @@ SUFFIXES += .in -e 's,[@]PKIDIR[@],$(PKIDIR),g' \ -e 's,[@]LOGDIR[@],$(LOGDIR),g' \ -e 's,[@]DBDIR[@],$(DBDIR),g' \ - -e 's,[@]PERL[@],$(PERL),g' \ -e 's,[@]PYTHON[@],$(PYTHON),g' \ -e 's,[@]RUNDIR[@],$(RUNDIR),g' \ -e 's,[@]VERSION[@],$(VERSION),g' \ @@ -175,7 +174,6 @@ SUFFIXES += .xml PKIDIR='$(PKIDIR)' \ LOGDIR='$(LOGDIR)' \ DBDIR='$(DBDIR)' \ - PERL='$(PERL)' \ PYTHON='$(PYTHON)' \ RUNDIR='$(RUNDIR)' \ VERSION='$(VERSION)' \ diff --git a/configure.ac b/configure.ac index 9e00818327a9..6a8113a5c58c 100644 --- a/configure.ac +++ b/configure.ac @@ -30,12 +30,6 @@ AC_PROG_FGREP AC_PROG_EGREP PKG_PROG_PKG_CONFIG -AC_ARG_VAR([PERL], [path to Perl interpreter]) -AC_PATH_PROG([PERL], perl, no) -if test "$PERL" = no; then - AC_MSG_ERROR([Perl interpreter not found in $PATH or $PERL.]) -fi - AM_MISSING_PROG([AUTOM4TE], [autom4te]) AC_USE_SYSTEM_EXTENSIONS diff --git a/tests/atlocal.in b/tests/atlocal.in index 1ecabf03a261..55f9333eee08 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -3,7 +3,6 @@ HAVE_OPENSSL='@HAVE_OPENSSL@' HAVE_PYTHON='@HAVE_PYTHON@' HAVE_PYTHON3='@HAVE_PYTHON3@' EGREP='@EGREP@' -PERL='@PERL@' if test x"$PYTHON" = x; then PYTHON='@PYTHON@' diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 08d3d5a020f5..56d0a3bca86d 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -1,6 +1,5 @@ AT_TESTED([ovs-vswitchd]) AT_TESTED([ovs-vsctl]) -AT_TESTED([perl]) m4_include([m4/compat.m4])