Tests: Refactor tearDown show command logging, add lifecycle markers.
[vpp.git] / test / test_ip4_vrf_multi_instance.py
index 71532ad..38604a5 100644 (file)
@@ -66,6 +66,7 @@ import unittest
 import random
 import socket
 
+import scapy.compat
 from scapy.packet import Raw
 from scapy.layers.l2 import Ether
 from scapy.layers.inet import IP, UDP, ARP
@@ -147,6 +148,10 @@ class TestIp4VrfMultiInst(VppTestCase):
             super(TestIp4VrfMultiInst, cls).tearDownClass()
             raise
 
+    @classmethod
+    def tearDownClass(cls):
+        super(TestIp4VrfMultiInst, cls).tearDownClass()
+
     def setUp(self):
         """
         Clear trace and packet infos before running each test.
@@ -159,9 +164,10 @@ class TestIp4VrfMultiInst(VppTestCase):
         Show various debug prints after each test.
         """
         super(TestIp4VrfMultiInst, self).tearDown()
-        if not self.vpp_dead:
-            self.logger.info(self.vapi.ppcli("show ip fib"))
-            self.logger.info(self.vapi.ppcli("show ip arp"))
+
+    def show_commands_at_teardown(self):
+        self.logger.info(self.vapi.ppcli("show ip fib"))
+        self.logger.info(self.vapi.ppcli("show ip arp"))
 
     def create_vrf_and_assign_interfaces(self, count, start=1):
         """
@@ -344,7 +350,8 @@ class TestIp4VrfMultiInst(VppTestCase):
                     if found:
                         break
                     for host in pg_if.remote_hosts:
-                        if str(addr) == str(host.ip4):
+                        if scapy.compat.raw(addr) == \
+                                scapy.compat.raw(host.ip4):
                             vrf_count += 1
                             found = True
                             break