X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_pg_interface.py;h=8792e6c3767793261e2186829e96c090407d81ea;hb=5e06257cb892b7dc784025fe7d84c50882425831;hp=4707f0b7fdf0dc298d97fefd26b9337f8f628c49;hpb=acb9b8e8c3394d06964ad0f8387b764c01f43152;p=vpp.git diff --git a/test/vpp_pg_interface.py b/test/vpp_pg_interface.py index 4707f0b7fdf..8792e6c3767 100644 --- a/test/vpp_pg_interface.py +++ b/test/vpp_pg_interface.py @@ -3,6 +3,8 @@ import time import socket import struct from traceback import format_exc, format_stack + +import scapy.compat from scapy.utils import wrpcap, rdpcap, PcapReader from scapy.plist import PacketList from vpp_interface import VppInterface @@ -84,11 +86,11 @@ class VppPGInterface(VppInterface): def __init__(self, test, pg_index): """ Create VPP packet-generator interface """ - r = test.vapi.pg_create_interface(pg_index) - self._sw_if_index = r.sw_if_index - super(VppPGInterface, self).__init__(test) + r = test.vapi.pg_create_interface(pg_index) + self.set_sw_if_index(r.sw_if_index) + self._in_history_counter = 0 self._out_history_counter = 0 self._out_assert_counter = 0 @@ -220,6 +222,10 @@ class VppPGInterface(VppInterface): if len(capture.res) == expected_count: # bingo, got the packets we expected return capture + elif len(capture.res) > expected_count: + self.test.logger.error( + ppc("Unexpected packets captured:", capture)) + break else: self.test.logger.debug("Partial capture containing %s " "packets doesn't match expected " @@ -251,8 +257,6 @@ class VppPGInterface(VppInterface): if not capture or len(capture.res) == 0: # junk filtered out, we're good return - self.test.logger.error( - ppc("Unexpected packets captured:", capture)) except: pass self.generate_debug_aid("empty-assert") @@ -283,7 +287,7 @@ class VppPGInterface(VppInterface): while time.time() < deadline: if os.path.isfile(self.out_path): break - time.sleep(0) # yield + self._test.sleep(0) # yield if os.path.isfile(self.out_path): self.test.logger.debug("Capture file appeared after %fs" % (time.time() - (deadline - timeout))) @@ -351,7 +355,7 @@ class VppPGInterface(VppInterface): self.test.logger.debug("Polling for packet") while time.time() < deadline or poll: if not self.verify_enough_packet_data_in_pcap(): - time.sleep(0) # yield + self._test.sleep(0) # yield poll = False continue p = self._pcap_reader.recv() @@ -365,7 +369,7 @@ class VppPGInterface(VppInterface): "Packet received after %fs" % (time.time() - (deadline - timeout))) return p - time.sleep(0) # yield + self._test.sleep(0) # yield poll = False self.test.logger.debug("Timeout - no packets received") raise CaptureTimeoutError("Packet didn't arrive within timeout") @@ -412,7 +416,7 @@ class VppPGInterface(VppInterface): # Make Dot1AD packet content recognizable to scapy if arp_reply.type == 0x88a8: arp_reply.type = 0x8100 - arp_reply = Ether(str(arp_reply)) + arp_reply = Ether(scapy.compat.raw(arp_reply)) try: if arp_reply[ARP].op == ARP.is_at: self.test.logger.info("VPP %s MAC address is %s " % @@ -458,8 +462,11 @@ class VppPGInterface(VppInterface): ndp_reply = captured_packet.copy() # keep original for exception # Make Dot1AD packet content recognizable to scapy if ndp_reply.type == 0x88a8: + self._test.logger.info( + "Replacing EtherType: 0x88a8 with " + "0x8100 and regenerating Ethernet header. ") ndp_reply.type = 0x8100 - ndp_reply = Ether(str(ndp_reply)) + ndp_reply = Ether(scapy.compat.raw(ndp_reply)) try: ndp_na = ndp_reply[ICMPv6ND_NA] opt = ndp_na[ICMPv6NDOptDstLLAddr]