VPP-1508: Tests: Fix vpp_api struct.error under py3.
Fix struct.error: expected bytes object got <class 'str'>
Change-Id: I837ae6e97e44c789a9372677151b157956525334
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/test/test_memif.py b/test/test_memif.py
index 6da8bf5..1f98e3f 100644
--- a/test/test_memif.py
+++ b/test/test_memif.py
@@ -3,6 +3,7 @@
from scapy.layers.l2 import Ether
from scapy.layers.inet import IP, ICMP
+import six
from framework import VppTestCase, VppTestRunner, running_extended_tests
from remote_test import RemoteClass, RemoteVppTestCase
@@ -45,7 +46,7 @@
def _check_socket_filename(self, dump, socket_id, filename):
for d in dump:
if (d.socket_id == socket_id) and (
- d.socket_filename.rstrip("\0") == filename):
+ d.socket_filename.rstrip(b"\0") == filename):
return True
return False
@@ -56,26 +57,28 @@
dump = self.vapi.memif_socket_filename_dump()
self.assertTrue(
self._check_socket_filename(
- dump, 0, self.tempdir + "/memif.sock"))
+ dump, 0, b"%s/memif.sock" % six.ensure_binary(
+ self.tempdir, encoding='utf-8')))
memif_sockets = []
# existing path
memif_sockets.append(
VppSocketFilename(
- self, 1, self.tempdir + "/memif1.sock"))
+ self, 1, b"%s/memif1.sock" % six.ensure_binary(
+ self.tempdir, encoding='utf-8')))
# default path (test tempdir)
memif_sockets.append(
VppSocketFilename(
self,
2,
- "memif2.sock",
+ b"memif2.sock",
add_default_folder=True))
# create new folder in default folder
memif_sockets.append(
VppSocketFilename(
self,
3,
- "sock/memif3.sock",
+ b"sock/memif3.sock",
add_default_folder=True))
for sock in memif_sockets:
@@ -93,7 +96,8 @@
dump = self.vapi.memif_socket_filename_dump()
self.assertTrue(
self._check_socket_filename(
- dump, 0, self.tempdir + "/memif.sock"))
+ dump, 0, b"%s/memif.sock" % six.ensure_binary(
+ self.tempdir, encoding='utf-8')))
def _create_delete_test_one_interface(self, memif):
memif.add_vpp_config()
@@ -146,26 +150,27 @@
self._create_delete_test_one_interface(memif)
def test_memif_create_custom_socket(self):
- """ Memif create with non-default socket filname """
+ """ Memif create with non-default socket filename """
memif_sockets = []
# existing path
memif_sockets.append(
VppSocketFilename(
- self, 1, self.tempdir + "/memif1.sock"))
+ self, 1, b"%s/memif1.sock" % six.ensure_binary(
+ self.tempdir, encoding='utf-8')))
# default path (test tempdir)
memif_sockets.append(
VppSocketFilename(
self,
2,
- "memif2.sock",
+ b"memif2.sock",
add_default_folder=True))
# create new folder in default folder
memif_sockets.append(
VppSocketFilename(
self,
3,
- "sock/memif3.sock",
+ b"sock/memif3.sock",
add_default_folder=True))
memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
@@ -184,7 +189,8 @@
ring_size=1024, buffer_size=2048)
remote_socket = VppSocketFilename(self.remote_test, 1,
- self.tempdir + "/memif.sock")
+ 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,
@@ -222,7 +228,8 @@
memif = VppMemif(self, MEMIF_ROLE.SLAVE, MEMIF_MODE.ETHERNET)
remote_socket = VppSocketFilename(self.remote_test, 1,
- self.tempdir + "/memif.sock")
+ 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,