tests: cli wrapper should return string

Python3 fixes.

Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I648b2142d45dfab9146a02eeb1b12de11103ff9f
Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
Ole Troan
2019-10-15 19:31:55 +02:00
committed by Neale Ranns
parent d6df3acf5c
commit 6ed154f779
5 changed files with 12 additions and 12 deletions
+4 -2
View File
@@ -175,14 +175,16 @@ def pump_output(testclass):
if testclass.vpp.stderr.fileno() in readable:
read = os.read(testclass.vpp.stderr.fileno(), 102400)
if len(read) > 0:
split = read.splitlines(True)
split = read.decode('ascii',
errors='backslashreplace').splitlines(True)
if len(stderr_fragment) > 0:
split[0] = "%s%s" % (stderr_fragment, split[0])
if len(split) > 0 and split[-1].endswith(b"\n"):
if len(split) > 0 and split[-1].endswith("\n"):
limit = None
else:
limit = -1
stderr_fragment = split[-1]
testclass.vpp_stderr_deque.extend(split[:limit])
if not testclass.cache_vpp_output:
for line in split[:limit]:
+3 -3
View File
@@ -100,7 +100,7 @@ class TestIPv4(VppTestCase):
:param int packet_size: Required packet size.
:param Scapy pkt: Packet to be modified.
"""
dst_if_idx = packet_size / 10 % 2
dst_if_idx = int(packet_size / 10 % 2)
dst_if = self.flows[src_if][dst_if_idx]
info = self.create_packet_info(src_if, dst_if)
payload = self.info_to_payload(info)
@@ -377,7 +377,7 @@ class TestICMPEcho(VppTestCase):
icmp_id = 0xb
icmp_seq = 5
icmp_load = '\x0a' * 18
icmp_load = b'\x0a' * 18
p_echo_request = (Ether(src=self.pg0.remote_mac,
dst=self.pg0.local_mac) /
IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) /
@@ -1938,7 +1938,7 @@ class TestIPv4Frag(VppTestCase):
packets = self.dst_if.get_capture(3)
# Assume VPP sends the fragments in order
payload = ''
payload = b''
for p in packets:
payload_offset = p.frag * 8
if payload_offset > 0:
+1 -1
View File
@@ -58,7 +58,7 @@ def ip4n_range(ip4n, s, e):
# wrapper around scapy library function.
def mk_ll_addr(mac):
euid = in6_mactoifaceid(mac)
euid = in6_mactoifaceid(str(mac))
addr = "fe80::" + euid
return addr
+3 -4
View File
@@ -33,7 +33,7 @@ class VppInterface(object):
@property
def local_mac(self):
"""MAC-address of the VPP interface."""
return self._local_mac
return str(self._local_mac)
@property
def local_addr(self):
@@ -260,9 +260,8 @@ class VppInterface(object):
r = self.test.vapi.sw_interface_dump(sw_if_index=self.sw_if_index)
for intf in r:
if intf.sw_if_index == self.sw_if_index:
self._name = intf.interface_name.split(b'\0',
1)[0].decode('utf8')
self._local_mac = bytes(intf.l2_address)
self._name = intf.interface_name
self._local_mac = intf.l2_address
self._dump = intf
break
else:
+1 -2
View File
@@ -369,8 +369,7 @@ class VppPapiProvider(object):
:param cli: CLI to execute
:returns: CLI output
"""
return cli + "\n" + self.cli(cli).encode('ascii',
errors='backslashreplace')
return cli + "\n" + self.cli(cli)
def want_ip4_arp_events(self, enable_disable=1, ip="0.0.0.0"):
return self.api(self.papi.want_ip4_arp_events,