From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 989D3A04FD; Tue, 27 Dec 2022 11:25:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 936F241143; Tue, 27 Dec 2022 11:25:58 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 3919C40E2D for ; Tue, 27 Dec 2022 11:25:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136757; x=1703672757; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8VvSmRqotTiHOh+yO0ZvJM8E68b1WHOdT6X6aou0HJY=; b=koFX2+Ts0Rx1DI535DG5t5HwkX4vX+A7OUXn1ne0zEzAlbiRy2ObSvCw wAr5I/k/moVu6hh17qH8OtWJWGMke1e0H42S7BDzoEOtwCxwEnk3FwEOw PTa7brKSaE0Bh9HvYkyYoHK1rH7EVjzkH7tu+RCjgEqMluzl7v9sPzYMD McIl/1twpMobw6VxSDw7fu0IvXZS5ntcZV1cUmSIfcwNJVRoH7bKzR+B4 SzxotDQ7xMoWDAOvT8esPloLDSejFGTFYOVGPAGTQPrweDtI1wZKaSckw M83nTklAKhhYKwP3CPlAGCkmNMbvweU/L0kmy8pysr51onhtDmy+u1jAX w==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656504" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656504" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:25:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292314" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292314" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:25:54 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation. Date: Tue, 27 Dec 2022 18:21:37 +0800 Message-Id: <20221227102131.529684-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Packet reading implementation is more common to use when to verify the received packet count and payload size. The tcpdump method is not able to recognize some of the tunnel packets, leading to a wrong output failing the validation. Newly added tcpdump_analyse_sniff method is implemented by sniff packet reading and analysing and can replace the lagacy methods number_of_packets and number_of_bytes. Signed-off-by: Ke Xu --- tests/TestSuite_vf_offload.py | 77 +++++++++-------------------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py index eb702559..f2356c76 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -627,43 +627,6 @@ class TestVfOffload(TestCase): rx_packet_size = [len(p[Raw].load) for p in pkts] return rx_packet_count, rx_packet_size - def tcpdump_command(self, command): - """ - Send a tcpdump related command and return an integer from the output. - """ - - result = self.tester.send_expect(command, "#") - print(result) - return int(result.strip()) - - def number_of_packets(self, iface): - """ - By reading the file generated by tcpdump it counts how many packets are - forwarded by the sample app and received in the self.tester. The sample app - will add a known MAC address for the test to look for. - """ - - command = ( - "tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/dev/null | " - + 'grep -c "seq"' - ) - return self.tcpdump_command(command.format(**locals())) - - def tcpdump_scanner(self, scanner): - """ - Execute scanner to return results - """ - scanner_result = self.tester.send_expect(scanner, "#") - finally_result = re.findall(r"length( \d+)", scanner_result) - return list(finally_result) - - def number_of_bytes(self, iface): - """ - Get the length of loading_sizes - """ - scanner = 'tcpdump -n -vv -r tcpdump_{iface}.pcap 2>/dev/null | grep "seq" | grep "length"' - return self.tcpdump_scanner(scanner.format(**locals())) - def test_tso(self): """ TSO IPv4 TCP, IPv6 TCP testing. @@ -761,27 +724,26 @@ class TestVfOffload(TestCase): out = self.vm0_testpmd.execute_cmd("show port stats all") print(out) self.tcpdump_stop_sniff() - rx_stats = self.number_of_packets(rx_interface) - tx_stats = self.number_of_packets(tx_interface) - tx_outlist = self.number_of_bytes(rx_interface) - tx_outlist.sort(reverse=True) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) + self.logger.info(payload_size_list) if loading_size <= 800: self.verify( - rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, + rx_stats == tx_stats and int(payload_size_list[0]) == loading_size, "IPV4 RX or TX packet number not correct", ) else: num = loading_size // 800 for i in range(num): self.verify( - int(tx_outlist[i]) == 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[i]) == 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) if loading_size % 800 != 0: self.verify( - int(tx_outlist[num]) == loading_size % 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[num]) == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) for loading_size in self.loading_sizes: @@ -796,27 +758,26 @@ class TestVfOffload(TestCase): out = self.vm0_testpmd.execute_cmd("show port stats all") print(out) self.tcpdump_stop_sniff() - rx_stats = self.number_of_packets(rx_interface) - tx_stats = self.number_of_packets(tx_interface) - tx_outlist = self.number_of_bytes(rx_interface) - tx_outlist.sort(reverse=True) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) + self.logger.info(payload_size_list) if loading_size <= 800: self.verify( - rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, + rx_stats == tx_stats and int(payload_size_list[0]) == loading_size, "IPV6 RX or TX packet number not correct", ) else: num = loading_size // 800 for i in range(num): self.verify( - int(tx_outlist[i]) == 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[i]) == 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) if loading_size % 800 != 0: self.verify( - int(tx_outlist[num]) == loading_size % 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[num]) == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) @check_supported_nic( @@ -915,6 +876,7 @@ class TestVfOffload(TestCase): self.tcpdump_stop_sniff() rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) self.logger.info(payload_size_list) if loading_size <= 800: self.verify( @@ -958,6 +920,7 @@ class TestVfOffload(TestCase): self.tcpdump_stop_sniff() rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) self.logger.info(payload_size_list) if loading_size <= 800: self.verify( -- 2.25.1