X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_l2xc.py;h=bc653f0b4fb833b57f74675f971a65ed6d5e4af0;hb=61717cc38;hp=3789304247e6b5271ce686e81e9b0780da01686e;hpb=7bb873a4cc068a6cc3c9d0e1d32987c5f8003904;p=vpp.git diff --git a/test/test_l2xc.py b/test/test_l2xc.py index 3789304247e..bc653f0b4fb 100644 --- a/test/test_l2xc.py +++ b/test/test_l2xc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest import random @@ -76,20 +76,22 @@ class TestL2xc(VppTestCase): super(TestL2xc, cls).tearDownClass() raise + @classmethod + def tearDownClass(cls): + super(TestL2xc, cls).tearDownClass() + def setUp(self): - """ - Clear trace and packet infos before running each test. - """ super(TestL2xc, self).setUp() - self.packet_infos = {} + self.reset_packet_infos() def tearDown(self): """ Show various debug prints after each test. """ super(TestL2xc, self).tearDown() - if not self.vpp_dead: - self.logger.info(self.vapi.ppcli("show l2patch")) + + def show_commands_at_teardown(self): + self.logger.info(self.vapi.ppcli("show l2patch")) @classmethod def create_host_lists(cls, count): @@ -123,8 +125,7 @@ class TestL2xc(VppTestCase): dst_if = self.flows[src_if][0] 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) / @@ -151,7 +152,7 @@ class TestL2xc(VppTestCase): try: ip = packet[IP] udp = packet[UDP] - payload_info = self.payload_to_info(str(packet[Raw])) + payload_info = self.payload_to_info(packet[Raw]) packet_index = payload_info.index self.assertEqual(payload_info.dst, dst_sw_if_index) self.logger.debug("Got packet on port %s: src=%u (id=%u)" %