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
@ -56,10 +56,7 @@ class BridgeDomain(object):
|
||||
self.pg_start()
|
||||
|
||||
# Pick first received frame and check if it's the non-encapsulated frame
|
||||
out = self.pg1.get_capture()
|
||||
self.assertEqual(len(out), 1,
|
||||
'Invalid number of packets on '
|
||||
'output: {}'.format(len(out)))
|
||||
out = self.pg1.get_capture(1)
|
||||
pkt = out[0]
|
||||
|
||||
# TODO: add error messages
|
||||
@ -83,10 +80,7 @@ class BridgeDomain(object):
|
||||
self.pg_start()
|
||||
|
||||
# Pick first received frame and check if it's corectly encapsulated.
|
||||
out = self.pg0.get_capture()
|
||||
self.assertEqual(len(out), 1,
|
||||
'Invalid number of packets on '
|
||||
'output: {}'.format(len(out)))
|
||||
out = self.pg0.get_capture(1)
|
||||
pkt = out[0]
|
||||
self.check_encapsulation(pkt)
|
||||
|
||||
|
Reference in New Issue
Block a user