summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-10-23 11:24:23 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-10-23 12:19:37 +0000
commit2a884db1d10656d2df759a23366dabd4b72bf37c (patch)
treed6f823e24270e5ad623779a770493d6e573a8914
parent1a7bb281f5e986cad792cf906643120488034db3 (diff)
cdp: re-enable skipped tests for python3
CDP uses the running sytems host name, which caused different failures on different systems. The root cause was an python3 specific error in checksum calculation. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I205436682d46e7e8cbb8c057c03a76dbbcab4d72
-rw-r--r--src/plugins/cdp/test/test_cdp.py4
-rw-r--r--test/patches/scapy-2.4/cdp.patch13
2 files changed, 10 insertions, 7 deletions
diff --git a/src/plugins/cdp/test/test_cdp.py b/src/plugins/cdp/test/test_cdp.py
index c0e52876752..27f35c2937d 100644
--- a/src/plugins/cdp/test/test_cdp.py
+++ b/src/plugins/cdp/test/test_cdp.py
@@ -98,13 +98,9 @@ class TestCDP(VppTestCase):
self.assert_equal(system[:length], self.device_id[:length],
"CDP received invalid device id")
- @unittest.skipIf(sys.version_info[0] > 2,
- "not supported in python3/scapy")
def test_cdp_underflow_tlv(self):
self.send_bad_packet(3, ".")
- @unittest.skipIf(sys.version_info[0] > 2,
- "not supported in python3/scapy")
def test_cdp_overflow_tlv(self):
self.send_bad_packet(8, ".")
diff --git a/test/patches/scapy-2.4/cdp.patch b/test/patches/scapy-2.4/cdp.patch
index 324891500d5..de16f5d5079 100644
--- a/test/patches/scapy-2.4/cdp.patch
+++ b/test/patches/scapy-2.4/cdp.patch
@@ -12,7 +12,7 @@ index c8b7f106..7b1ff64d 100644
StrLenField("val", "", length_from=lambda x:x.len - 4) ]
-@@ -178,7 +179,8 @@ class CDPMsgAddr(CDPMsgGeneric):
+@@ -178,5 +179,6 @@ class CDPMsgAddr(CDPMsgGeneric):
class CDPMsgPortID(CDPMsgGeneric):
name = "Port ID"
fields_desc = [ XShortEnumField("type", 0x0003, _cdp_tlv_types),
@@ -20,5 +20,12 @@ index c8b7f106..7b1ff64d 100644
+ FieldLenField("len", None, "iface", "!H",
+ adjust=lambda pkt, x: x + 4),
StrLenField("iface", "Port 1", length_from=lambda x:x.len - 4) ]
-
-
+@@ -319,7 +319,7 @@ class _CDPChecksum:
+ This padding is only used for checksum computation. The original
+ packet should not be altered."""
+ if len(pkt) % 2:
+- last_chr = pkt[-1]
++ last_chr = pkt[len(pkt)-1:]
+ if last_chr <= b'\x80':
+ return pkt[:-1] + b'\x00' + last_chr
+ else: