GBP: redirect contracts
[vpp.git] / test / test_l2bd.py
index 46ba2e4..30708a4 100644 (file)
@@ -8,7 +8,7 @@ from scapy.layers.l2 import Ether, Dot1Q
 from scapy.layers.inet import IP, UDP
 
 from framework import VppTestCase, VppTestRunner
-from util import Host
+from util import Host, ppp
 from vpp_sub_interface import VppDot1QSubint, VppDot1ADSubint
 
 
@@ -99,7 +99,7 @@ class TestL2bd(VppTestCase):
         Clear trace and packet infos before running each test.
         """
         super(TestL2bd, self).setUp()
-        self.packet_infos = {}
+        self.reset_packet_infos()
 
     def tearDown(self):
         """
@@ -109,7 +109,7 @@ class TestL2bd(VppTestCase):
         if not self.vpp_dead:
             self.logger.info(self.vapi.ppcli("show l2fib verbose"))
             self.logger.info(self.vapi.ppcli("show bridge-domain %s detail" %
-                                           self.bd_id))
+                                             self.bd_id))
 
     @classmethod
     def create_hosts_and_learn(cls, count):
@@ -158,8 +158,7 @@ class TestL2bd(VppTestCase):
             dst_if = self.flows[src_if][i % 2]
             dst_host = random.choice(self.hosts_by_pg_idx[dst_if.sw_if_index])
             src_host = random.choice(self.hosts_by_pg_idx[src_if.sw_if_index])
-            pkt_info = self.create_packet_info(
-                src_if.sw_if_index, dst_if.sw_if_index)
+            pkt_info = self.create_packet_info(src_if, dst_if)
             payload = self.info_to_payload(pkt_info)
             p = (Ether(dst=dst_host.mac, src=src_host.mac) /
                  IP(src=src_host.ip4, dst=dst_host.ip4) /
@@ -217,8 +216,7 @@ class TestL2bd(VppTestCase):
                 self.assertEqual(udp.sport, saved_packet[UDP].sport)
                 self.assertEqual(udp.dport, saved_packet[UDP].dport)
             except:
-                self.logger.error("Unexpected or invalid packet:")
-                self.logger.error(packet.show())
+                self.logger.error(ppp("Unexpected or invalid packet:", packet))
                 raise
         for i in self.pg_interfaces:
             remaining_packet = self.get_next_packet_info_for_interface2(