make test: improve handling of packet captures
Perform accounting of expected packets based on created packet infos. Use this accounting info to automatically expect (and verify) the correct number of packets to be captured. Automatically retry the read of the capture file if scapy raises an exception while doing so to handle rare cases when capture file is read while only partially written during busy wait. Don't fail assert_nothing_captured if only junk packets arrived. Change-Id: I16ec2e9410ef510d313ec16b7e13c57d0b2a63f5 Signed-off-by: Klement Sekera <ksekera@cisco.com>
This commit is contained in:

committed by
Damjan Marion

parent
fc262a0cf7
commit
dab231a11e
@ -130,11 +130,8 @@ class TestL2fib(VppTestCase):
|
||||
raise
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Clear trace and packet infos before running each test.
|
||||
"""
|
||||
super(TestL2fib, self).setUp()
|
||||
self.packet_infos = {}
|
||||
self.reset_packet_infos()
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
@ -236,8 +233,7 @@ class TestL2fib(VppTestCase):
|
||||
for i in range(0, n_int):
|
||||
dst_host = dst_hosts[i]
|
||||
src_host = random.choice(src_hosts)
|
||||
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) /
|
||||
@ -314,7 +310,7 @@ class TestL2fib(VppTestCase):
|
||||
# Test
|
||||
# Create incoming packet streams for packet-generator interfaces for
|
||||
# deleted MAC addresses
|
||||
self.packet_infos = {}
|
||||
self.reset_packet_infos()
|
||||
for i in self.pg_interfaces:
|
||||
pkts = self.create_stream(i, self.pg_if_packet_sizes, deleted=True)
|
||||
i.add_stream(pkts)
|
||||
|
Reference in New Issue
Block a user