make test: add checkstyle target 34/4734/2
authorKlement Sekera <ksekera@cisco.com>
Tue, 17 Jan 2017 09:37:05 +0000 (10:37 +0100)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 17 Jan 2017 18:35:21 +0000 (18:35 +0000)
Change-Id: I59d3c3bc77474c96e1d6fa51811c1b13fb9a6c5b
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Makefile
test/Makefile
test/test_bfd.py
test/util.py

index 12f4048..f1813a3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -96,6 +96,7 @@ help:
        @echo " test-wipe-doc       - wipe documentation for test framework"
        @echo " test-cov            - generate code coverage report for test framework"
        @echo " test-wipe-cov       - wipe code coverage report for test framework"
+       @echo " test-checkstyle     - check PEP8 compliance for test framework"
        @echo ""
        @echo "Make Arguments:"
        @echo " V=[0|1]             - set build verbosity level"
@@ -239,6 +240,9 @@ test-cov: bootstrap
 test-wipe-cov:
        @make -C test wipe-cov
 
+test-checkstyle:
+       @make -C test checkstyle
+
 retest:
        $(call test,vpp_lite,vpp_lite,retest)
 
index 543fe91..db64ad9 100644 (file)
@@ -77,6 +77,20 @@ cov: wipe-cov reset verify-python-path $(PAPI_INSTALL_DONE)
 wipe-cov: wipe
        @rm -rf $(BUILD_COV_DIR)
 
+.PHONY: checkstyle
+checkstyle: verify-python-path
+       @virtualenv $(PYTHON_VENV_PATH) -p python2.7
+       @bash -c "source $(PYTHON_VENV_PATH)/bin/activate && pip install $(PYTHON_DEPENDS) pep8"
+       @bash -c "source $(PYTHON_VENV_PATH)/bin/activate &&\
+               pep8 --show-source -v $(WS_ROOT)/test/*.py ||\
+               (echo \"*******************************************************************\" &&\
+                echo \"* Test framework PEP8 compliance check FAILED \" &&\
+                echo \"*******************************************************************\" &&\
+                false)"
+       @echo "*******************************************************************"
+       @echo "* Test framework PEP8 compliance check passed"
+       @echo "*******************************************************************"
+
 help:
        @echo "Running tests:"
        @echo ""
@@ -106,3 +120,6 @@ help:
        @echo " test-cov            - generate code coverage report for test framework"
        @echo " test-wipe-cov       - wipe code coverage report for test framework"
        @echo ""
+       @echo "Verifying code-style"
+       @echo " test-checkstyle     - check PEP8 compliance"
+       @echo ""
index b622252..b783224 100644 (file)
@@ -27,8 +27,6 @@ class BFDAPITestCase(VppTestCase):
             super(BFDAPITestCase, cls).tearDownClass()
             raise
 
-
-
     def test_add_bfd(self):
         """ create a BFD session """
         session = VppBFDUDPSession(self, self.pg0, self.pg0.remote_ip4)
index ae887a5..7989360 100644 (file)
@@ -41,7 +41,8 @@ def ip4_range(ip4, s, e):
 
 def ip4n_range(ip4n, s, e):
     ip4 = socket.inet_ntop(socket.AF_INET, ip4n)
-    return (socket.inet_pton(socket.AF_INET, ip) for ip in ip4_range(ip4, s, e))
+    return (socket.inet_pton(socket.AF_INET, ip)
+            for ip in ip4_range(ip4, s, e))
 
 
 class NumericConstant(object):