diff options
author | Klement Sekera <ksekera@cisco.com> | 2016-12-12 08:36:58 +0100 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2016-12-16 08:09:40 +0000 |
commit | 9225dee9655ce607130f9bab5472441b72e25858 (patch) | |
tree | 6438ea39bf2b14eeca70770890165497ee146d30 /test/test_l2_fib.py | |
parent | cc53285baf2c3a45b95e22dd66c8592d634568ee (diff) |
make test: improve robustness and performance
Introduce an API which asserts empty capture for interface.
Throw exception in old API if the capture does not exist, thus
making it clear if the test expects packets to arrive or not.
Improve performance by not doing sleeps after starting the packet
generator, rather lazily deleting captures when needed.
Fix wrong usage of packet.show() in various tests.
Change-Id: I456cb23316eef99b3f35f80344fe595c4db9a21c
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/test_l2_fib.py')
-rw-r--r-- | test/test_l2_fib.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/test/test_l2_fib.py b/test/test_l2_fib.py index eb4f4e32d1b..4855a3ea383 100644 --- a/test/test_l2_fib.py +++ b/test/test_l2_fib.py @@ -68,7 +68,7 @@ from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP from framework import VppTestCase, VppTestRunner -from util import Host +from util import Host, ppp class TestL2fib(VppTestCase): @@ -282,8 +282,7 @@ class TestL2fib(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( @@ -327,14 +326,7 @@ class TestL2fib(VppTestCase): # Verify # Verify outgoing packet streams per packet-generator interface for i in self.pg_interfaces: - capture = i.get_capture() - self.logger.info("Verifying capture on interface %s" % i.name) - try: - self.assertEqual(len(capture), 0) - except AssertionError: - self.logger.error("The capture on interface %s is not empty!" - % i.name) - raise AssertionError("%d != 0" % len(capture)) + i.assert_nothing_captured(remark="outgoing interface") def test_l2_fib_01(self): """ L2 FIB test 1 - program 100 MAC addresses |