diff options
author | Ole Troan <ot@cisco.com> | 2018-12-06 17:35:12 +0100 |
---|---|---|
committer | Neale Ranns <nranns@cisco.com> | 2018-12-10 08:01:56 +0000 |
commit | 7f99183a20d60cd5c648cc23d7a2f30a594a215b (patch) | |
tree | bb3934aab296ce5fa531bfc5ab47921a113ffd26 /test/test_mtu.py | |
parent | 521a8d7df423a0b5aaf259d49ca9230705bc25ee (diff) |
Test framework: StringIO fixes for Python3
Add 2/3 support to binarytomac and mactobinary and move to vpp_mac.py
Change-Id: I3dc7e4a24486aee22140c781aae7e44e58935877
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'test/test_mtu.py')
-rw-r--r-- | test/test_mtu.py | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/test/test_mtu.py b/test/test_mtu.py index 57d56001ee2..3203e40e114 100644 --- a/test/test_mtu.py +++ b/test/test_mtu.py @@ -15,30 +15,17 @@ from framework import VppTestCase, VppTestRunner from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath from socket import AF_INET, AF_INET6, inet_pton -import StringIO +from util import reassemble4 + """ Test_mtu is a subclass of VPPTestCase classes. MTU tests. """ -def reassemble(listoffragments): - buffer = StringIO.StringIO() - first = listoffragments[0] - buffer.seek(20) - for pkt in listoffragments: - # pkt.show2() - buffer.seek(pkt[IP].frag*8) - buffer.write(pkt[IP].payload) - first.len = len(buffer.getvalue()) + 20 - first.flags = 0 - del(first.chksum) - header = str(first[IP])[:20] - return first[IP].__class__(header + buffer.getvalue()) - - class TestMTU(VppTestCase): """ MTU Test Case """ + maxDiff = None @classmethod def setUpClass(cls): @@ -65,7 +52,7 @@ class TestMTU(VppTestCase): i.admin_down() def validate(self, rx, expected): - self.assertEqual(rx, expected.__class__(str(expected))) + self.assertEqual(rx, expected.__class__(expected)) def validate_bytes(self, rx, expected): self.assertEqual(rx, expected) @@ -111,14 +98,14 @@ class TestMTU(VppTestCase): ttl=254, len=576, id=0) / p_icmp4 / p_ip4 / p_payload) icmp4_reply[1].ttl -= 1 - n = icmp4_reply.__class__(str(icmp4_reply)) - s = str(icmp4_reply) + n = icmp4_reply.__class__(icmp4_reply) + s = bytes(icmp4_reply) icmp4_reply = s[0:576] rx = self.send_and_expect(self.pg0, p4*11, self.pg0) for p in rx: # p.show2() # n.show2() - self.validate_bytes(str(p[1]), icmp4_reply) + self.validate_bytes(bytes(p[1]), icmp4_reply) # Now with DF off. Expect fragments. # First go with 1500 byte packets. @@ -134,7 +121,7 @@ class TestMTU(VppTestCase): self.pg0.add_stream(p4*1) self.pg_start() rx = self.pg1.get_capture(3) - reass_pkt = reassemble(rx) + reass_pkt = reassemble4(rx) self.validate(reass_pkt, p4_reply) ''' @@ -152,7 +139,7 @@ class TestMTU(VppTestCase): self.pg0.add_stream(p4*1) self.pg_start() rx = self.pg1.get_capture(16) - reass_pkt = reassemble(rx) + reass_pkt = reassemble4(rx) reass_pkt.show2() p4_reply.show2() self.validate(reass_pkt, p4_reply) @@ -191,13 +178,13 @@ class TestMTU(VppTestCase): hlim=255, plen=1240) / p_icmp6 / p_ip6 / p_payload) icmp6_reply[2].hlim -= 1 - n = icmp6_reply.__class__(str(icmp6_reply)) - s = str(icmp6_reply) + n = icmp6_reply.__class__(icmp6_reply) + s = bytes(icmp6_reply) icmp6_reply_str = s[0:1280] rx = self.send_and_expect(self.pg0, p6*9, self.pg0) for p in rx: - self.validate_bytes(str(p[1]), icmp6_reply_str) + self.validate_bytes(bytes(p[1]), icmp6_reply_str) # Reset MTU self.vapi.sw_interface_set_mtu(self.pg1.sw_if_index, |