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_ipip.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_ipip.py')
-rw-r--r-- | test/test_ipip.py | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/test/test_ipip.py b/test/test_ipip.py index 989330faa6f..e4a893bca51 100644 --- a/test/test_ipip.py +++ b/test/test_ipip.py @@ -8,7 +8,8 @@ from framework import VppTestCase, VppTestRunner from vpp_ip import DpoProto from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable from socket import AF_INET, AF_INET6, inet_pton -import StringIO +from util import reassemble4 + """ Testipip is a subclass of VPPTestCase classes. @@ -17,21 +18,6 @@ IPIP tests. """ -# Replace by deframent from scapy. -def reassemble(listoffragments): - buffer = StringIO.StringIO() - first = listoffragments[0] - buffer.seek(20) - for pkt in listoffragments: - 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 TestIPIP(VppTestCase): """ IPIP Test Case """ @@ -60,7 +46,7 @@ class TestIPIP(VppTestCase): i.admin_down() def validate(self, rx, expected): - self.assertEqual(rx, expected.__class__(str(expected))) + self.assertEqual(rx, expected.__class__(expected)) def generate_ip4_frags(self, payload_length, fragment_size): p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) @@ -214,7 +200,7 @@ class TestIPIP(VppTestCase): self.pg1.add_stream(frags) self.pg_start() rx = self.pg0.get_capture(6) - reass_pkt = reassemble(rx) + reass_pkt = reassemble4(rx) p4_reply.ttl -= 1 p4_reply.id = 256 self.validate(reass_pkt, p4_reply) @@ -225,7 +211,7 @@ class TestIPIP(VppTestCase): self.pg1.add_stream(frags) self.pg_start() rx = self.pg0.get_capture(2) - reass_pkt = reassemble(rx) + reass_pkt = reassemble4(rx) p4_reply.ttl -= 1 p4_reply.id = 512 self.validate(reass_pkt, p4_reply) @@ -320,7 +306,7 @@ class TestIPIP6(VppTestCase): rv = self.vapi.ipip_del_tunnel(sw_if_index=self.tunnel_if_index) def validate(self, rx, expected): - self.assertEqual(rx, expected.__class__(str(expected))) + self.assertEqual(rx, expected.__class__(expected)) def generate_ip6_frags(self, payload_length, fragment_size): p_ether = Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) |