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 201D7A04FD; Wed, 28 Dec 2022 06:10:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BC2642C29; Wed, 28 Dec 2022 06:10:31 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C5FEC42C29 for ; Wed, 28 Dec 2022 06:10:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204230; x=1703740230; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yH02kApkDcv7vLhVcvNOfWLxngK53hQNiYBheQHyh8s=; b=QDBdMBghE7RyV8vuENsYYMK7KEKU1465WyKSoFkutTjJzP7G6swYpBYi Ln19DCFNy9pnJ1J3Hdo6BWhHcHgGWA35HlftOuuRgjULd5eT1QhsDq5/T DUHH7pGrd0Y3FUMnMAWGn25dgQOXJey9ftP0Lqu5iNADxks8p3yXzQ7FQ H2pb/OYMzVKbBFrI6vk0E7waIcfwDTm/7akNKiIXXAey1Tn6uNVJB28y0 fkYdWwWA6hInhwWDiaKOQm28gFz62S1SameMHH1G3raL6FT+RvEPidrfo 8mzPbrO1iLnxWfW+x+XGYS/hJn212nm+k16U8aUHw7HARyRO/Wr60H7lx A==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499481" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499481" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536375" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536375" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10:27 -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 V2 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation. Date: Wed, 28 Dec 2022 13:08:50 +0800 Message-Id: <20221228050850.33004-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 a9d587e9..084f2249 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