summaryrefslogtreecommitdiffstats
path: root/test/vpp_memif.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /test/vpp_memif.py
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/vpp_memif.py')
-rw-r--r--test/vpp_memif.py52
1 files changed, 33 insertions, 19 deletions
diff --git a/test/vpp_memif.py b/test/vpp_memif.py
index 226f8af72b5..6a97c2b9884 100644
--- a/test/vpp_memif.py
+++ b/test/vpp_memif.py
@@ -7,7 +7,7 @@ from vpp_papi import VppEnum
def get_if_dump(dump, sw_if_index):
for d in dump:
- if (d.sw_if_index == sw_if_index):
+ if d.sw_if_index == sw_if_index:
return d
@@ -22,13 +22,11 @@ def remove_all_memif_vpp_config(_test):
dump = _test.vapi.memif_socket_filename_dump()
for d in dump:
if d.socket_id != 0:
- _test.vapi.memif_socket_filename_add_del(
- 0, d.socket_id, d.socket_filename)
+ _test.vapi.memif_socket_filename_add_del(0, d.socket_id, d.socket_filename)
class VppSocketFilename(VppObject):
- def __init__(self, test, socket_id, socket_filename,
- add_default_folder=False):
+ def __init__(self, test, socket_id, socket_filename, add_default_folder=False):
self._test = test
self.socket_id = socket_id
self.socket_filename = socket_filename
@@ -39,15 +37,16 @@ class VppSocketFilename(VppObject):
def add_vpp_config(self):
rv = self._test.vapi.memif_socket_filename_add_del(
- 1, self.socket_id, self.socket_filename)
+ 1, self.socket_id, self.socket_filename
+ )
if self.add_default_folder:
- self.socket_filename = "%s/%s" % (self._test.tempdir,
- self.socket_filename)
+ self.socket_filename = "%s/%s" % (self._test.tempdir, self.socket_filename)
return rv
def remove_vpp_config(self):
return self._test.vapi.memif_socket_filename_add_del(
- 0, self.socket_id, self.socket_filename)
+ 0, self.socket_id, self.socket_filename
+ )
def query_vpp_config(self):
return self._test.vapi.memif_socket_filename_dump()
@@ -57,9 +56,20 @@ class VppSocketFilename(VppObject):
class VppMemif(VppObject):
- def __init__(self, test, role, mode, rx_queues=0, tx_queues=0, if_id=0,
- socket_id=0, secret="", ring_size=0, buffer_size=0,
- hw_addr=""):
+ def __init__(
+ self,
+ test,
+ role,
+ mode,
+ rx_queues=0,
+ tx_queues=0,
+ if_id=0,
+ socket_id=0,
+ secret="",
+ ring_size=0,
+ buffer_size=0,
+ hw_addr="",
+ ):
self._test = test
self.role = role
self.mode = mode
@@ -72,9 +82,9 @@ class VppMemif(VppObject):
self.buffer_size = buffer_size
self.hw_addr = hw_addr
self.sw_if_index = None
- self.ip_prefix = IPv4Network("192.168.%d.%d/24" %
- (self.if_id + 1, self.role + 1),
- strict=False)
+ self.ip_prefix = IPv4Network(
+ "192.168.%d.%d/24" % (self.if_id + 1, self.role + 1), strict=False
+ )
def add_vpp_config(self):
rv = self._test.vapi.memif_create(
@@ -87,7 +97,8 @@ class VppMemif(VppObject):
secret=self.secret,
ring_size=self.ring_size,
buffer_size=self.buffer_size,
- hw_addr=self.hw_addr)
+ hw_addr=self.hw_addr,
+ )
try:
self.sw_if_index = rv.sw_if_index
except AttributeError:
@@ -99,12 +110,14 @@ class VppMemif(VppObject):
def admin_up(self):
if self.sw_if_index:
return self._test.vapi.sw_interface_set_flags(
- sw_if_index=self.sw_if_index, flags=1)
+ sw_if_index=self.sw_if_index, flags=1
+ )
def admin_down(self):
if self.sw_if_index:
return self._test.vapi.sw_interface_set_flags(
- sw_if_index=self.sw_if_index, flags=0)
+ sw_if_index=self.sw_if_index, flags=0
+ )
def wait_for_link_up(self, timeout, step=1):
if not self.sw_if_index:
@@ -121,7 +134,8 @@ class VppMemif(VppObject):
def config_ip4(self):
return self._test.vapi.sw_interface_add_del_address(
- sw_if_index=self.sw_if_index, prefix=self.ip_prefix)
+ sw_if_index=self.sw_if_index, prefix=self.ip_prefix
+ )
def remove_vpp_config(self):
self._test.vapi.memif_delete(self.sw_if_index)