API: Use string type instead of u8.
[vpp.git] / test / test_cdp.py
index 3eec4a7..e8ced7c 100644 (file)
@@ -86,14 +86,21 @@ class TestCDP(VppTestCase):
         self.assertTrue(neighbors, "CDP didn't register neighbor")
 
         port, system = neighbors[0]
+        length = min(len(system), len(self.device_id))
 
         self.assert_equal(port, self.port_id, "CDP received invalid port id")
-        self.assert_equal(system, self.device_id,
+        self.assert_equal(system[:length], self.device_id[:length],
                           "CDP received invalid device id")
 
-    def test_send_cdp_bad_packet(self):
+    def test_cdp_underflow_tlv(self):
+        self.send_bad_packet(3, ".")
+
+    def test_cdp_overflow_tlv(self):
+        self.send_bad_packet(8, ".")
+
+    def send_bad_packet(self, l, v):
         self.logger.info(self.vapi.cli("cdp enable"))
-        self.send_packet(self.create_bad_packet(8, "."))
+        self.send_packet(self.create_bad_packet(l, v))
 
         errors = list(self.show_errors())
         self.assertTrue(errors)
@@ -102,7 +109,7 @@ class TestCDP(VppTestCase):
         for count, node, reason in errors:
             if (node == u'cdp-input' and
                     reason == u'cdp packets with bad TLVs' and
-                    int(count) == 1):
+                    int(count) >= 1):
 
                 expected_errors = True
                 break