summaryrefslogtreecommitdiffstats
path: root/test/vpp_memif.py
diff options
context:
space:
mode:
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)