]> git.proxmox.com Git - mirror_ovs.git/commitdiff
tests: Convert dpdkstrip utility from Perl to Python.
authorBen Pfaff <blp@ovn.org>
Wed, 15 Nov 2017 06:58:06 +0000 (22:58 -0800)
committerBen Pfaff <blp@ovn.org>
Mon, 27 Nov 2017 00:08:04 +0000 (16:08 -0800)
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 <blp@ovn.org>
Acked-by: Aaron Conole <aconole@redhat.com>
Makefile.am
build-aux/automake.mk
build-aux/dpdkstrip.pl [deleted file]
build-aux/dpdkstrip.py [new file with mode: 0755]
rhel/openvswitch-fedora.spec.in

index 5d19f0833afc905b58e3aeb95a796805d040e31a..c82a9e21ec36398c8313e2f73b9bd8934e728b65 100644 (file)
@@ -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' \
index 9500e3a6940243cbbc2c410f339c4ca8d7066150..c0553e6edffbeaf6b27ab0058d6ebd185123ad9c 100644 (file)
@@ -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 (file)
index 98539cc..0000000
+++ /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 (<STDIN>) {
-    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 (executable)
index 0000000..48c7f06
--- /dev/null
@@ -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)
index b45e018f5ee94599e3abcd7c83c1f3267e3db1fa..e600a943cde6c11a5785c914c750d4a33b8d1ab8 100644 (file)
@@ -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