aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/memif/test
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2019-08-21 10:51:21 +0200
committerOle Trøan <otroan@employees.org>2019-09-09 14:29:48 +0000
commit546f955b3dad6c0866a8ba778d0cfe1ef43d81d4 (patch)
tree6113bab6ae3dec547b6cc6467b0fb8db114e7728 /src/plugins/memif/test
parentbdf3ebe358787ef240dc9fadc515dfd178dfef7b (diff)
memif: API cleanup
Use consistent API types. memif_create now enables zero-copy by default. Add no_zero_copy param to memif_create which if set, disables zero copy. Type: refactor Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: I11df8b9212c40de179ee71dc9da14039b982ede5 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src/plugins/memif/test')
-rw-r--r--src/plugins/memif/test/test_memif.py57
-rw-r--r--src/plugins/memif/test/vpp_memif.py14
2 files changed, 42 insertions, 29 deletions
diff --git a/src/plugins/memif/test/test_memif.py b/src/plugins/memif/test/test_memif.py
index 6413cfdbf20..8182a41a620 100644
--- a/src/plugins/memif/test/test_memif.py
+++ b/src/plugins/memif/test/test_memif.py
@@ -7,9 +7,10 @@ import six
from framework import VppTestCase, VppTestRunner, running_extended_tests
from remote_test import RemoteClass, RemoteVppTestCase
-from vpp_memif import MEMIF_MODE, MEMIF_ROLE, remove_all_memif_vpp_config, \
+from vpp_memif import remove_all_memif_vpp_config, \
VppSocketFilename, VppMemif
from vpp_ip_route import VppIpRoute, VppRoutePath
+from vpp_papi import VppEnum
class TestMemif(VppTestCase):
@@ -122,7 +123,7 @@ class TestMemif(VppTestCase):
self.assertTrue(memif.wait_for_link_up(5))
dump = memif.query_vpp_config()
- if memif.role == MEMIF_ROLE.SLAVE:
+ if memif.role == VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE:
self.assertEqual(dump.ring_size, memif.ring_size)
self.assertEqual(dump.buffer_size, memif.buffer_size)
else:
@@ -145,9 +146,12 @@ class TestMemif(VppTestCase):
def test_memif_create_delete(self):
""" Memif create/delete interface """
- memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
+ memif = VppMemif(
+ self,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET)
self._create_delete_test_one_interface(memif)
- memif.role = MEMIF_ROLE.MASTER
+ memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER
self._create_delete_test_one_interface(memif)
def test_memif_create_custom_socket(self):
@@ -174,34 +178,47 @@ class TestMemif(VppTestCase):
b"sock/memif3.sock",
add_default_folder=True))
- memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
+ memif = VppMemif(
+ self,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET)
for sock in memif_sockets:
sock.add_vpp_config()
memif.socket_id = sock.socket_id
- memif.role = MEMIF_ROLE.SLAVE
+ memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE
self._create_delete_test_one_interface(memif)
- memif.role = MEMIF_ROLE.MASTER
+ memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER
self._create_delete_test_one_interface(memif)
def test_memif_connect(self):
""" Memif connect """
- memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET,
- ring_size=1024, buffer_size=2048)
+ memif = VppMemif(
+ self,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
+ ring_size=1024,
+ buffer_size=2048,
+ secret="abc")
remote_socket = VppSocketFilename(self.remote_test, 1,
b"%s/memif.sock" % six.ensure_binary(
self.tempdir, encoding='utf-8'))
remote_socket.add_vpp_config()
- remote_memif = VppMemif(self.remote_test, MEMIF_ROLE.MASTER,
- MEMIF_MODE.ETHERNET, socket_id=1,
- ring_size=1024, buffer_size=2048)
+ remote_memif = VppMemif(
+ self.remote_test,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
+ socket_id=1,
+ ring_size=1024,
+ buffer_size=2048,
+ secret="abc")
self._connect_test_interface_pair(memif, remote_memif)
- memif.role = MEMIF_ROLE.MASTER
- remote_memif.role = MEMIF_ROLE.SLAVE
+ memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER
+ remote_memif.role = VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE
self._connect_test_interface_pair(memif, remote_memif)
@@ -227,15 +244,21 @@ class TestMemif(VppTestCase):
def test_memif_ping(self):
""" Memif ping """
- memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
+ memif = VppMemif(
+ self,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_SLAVE,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET)
remote_socket = VppSocketFilename(self.remote_test, 1,
b"%s/memif.sock" % six.ensure_binary(
self.tempdir, encoding='utf-8'))
remote_socket.add_vpp_config()
- remote_memif = VppMemif(self.remote_test, MEMIF_ROLE.MASTER,
- MEMIF_MODE.ETHERNET, socket_id=1)
+ remote_memif = VppMemif(
+ self.remote_test,
+ VppEnum.vl_api_memif_role_t.MEMIF_ROLE_API_MASTER,
+ VppEnum.vl_api_memif_mode_t.MEMIF_MODE_API_ETHERNET,
+ socket_id=1)
memif.add_vpp_config()
memif.config_ip4()
diff --git a/src/plugins/memif/test/vpp_memif.py b/src/plugins/memif/test/vpp_memif.py
index befcc2840c5..ba032c5fb6f 100644
--- a/src/plugins/memif/test/vpp_memif.py
+++ b/src/plugins/memif/test/vpp_memif.py
@@ -7,17 +7,6 @@ from vpp_ip import VppIpPrefix
from vpp_papi import VppEnum
-class MEMIF_ROLE:
- MASTER = 0
- SLAVE = 1
-
-
-class MEMIF_MODE:
- ETHERNET = 0
- IP = 1
- PUNT_INJECT = 2
-
-
def get_if_dump(dump, sw_if_index):
for d in dump:
if (d.sw_if_index == sw_if_index):
@@ -127,7 +116,8 @@ class VppMemif(VppObject):
return False
while True:
dump = self.query_vpp_config()
- if dump.link_up_down == 1:
+ f = VppEnum.vl_api_if_status_flags_t.IF_STATUS_API_FLAG_LINK_UP
+ if dump.flags & f:
return True
self._test.sleep(step)
timeout -= step