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 8F968A04FD; Thu, 10 Nov 2022 09:12:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 61732400EF; Thu, 10 Nov 2022 09:12:00 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 59717400D4 for ; Thu, 10 Nov 2022 09:11:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668067919; x=1699603919; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=0KL7yo/FZqXnS9q6wGPr4dcoCLnrDbRo/r1YB+HBkOc=; b=ZgrhqdecjdXLI2pZikX0fan+KHWSu8vTVjE1DbGN6fjVRVFPNdfnyw7x nJM+UAyuhS04449iHCN+NNP/r3xZWKCOWpPK4OXLJrJOaiUHaMvIRjS4m E8LUo7qqSS4R+9Ofax2XO5Xf+r2ULkO0+9bGo4Aczubou75AruD7xpEpL udZmcG9LQ0lI65DG51evYNIIhD8H/ecHBcYar3WNYuyiLa3fGh5ZBvqna qw5ami5FI17H2lfAKzy9gj/hAXVkucPowTBnJtESTsM1/y9WvDY1amorh rfHZi4TaS80VjkdA7tONDgRcYx00BlVFJRbo5zKgYXpeLiIAohcYMchPr w==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="291645115" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="291645115" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 00:11:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="631570983" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="631570983" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.114.198]) by orsmga007.jf.intel.com with ESMTP; 10 Nov 2022 00:11:56 -0800 From: Ke Xu To: dts@dpdk.org Cc: lijuan.tu@intel.com, ke1.xu@intel.com Subject: [dts][PATCH V1] tests/tso: improve checksum verify code Date: Thu, 10 Nov 2022 16:10:50 +0800 Message-Id: <20221110081050.76753-1-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 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 Reimplemented the checksum calculation with a non-file method. Replaced property pks with a local variable pkts. Renamed local variable pks to pkt as it stands for a single packet. Use the name of layers as the index of packet to check if it is in a packet rather than check if it is in the dumped string of a packet. Renamed checksum_list and checksum_list1 to chksum_list_rx and checksum_list_good. Signed-off-by: Ke Xu --- tests/TestSuite_tso.py | 51 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py index 9f4e27a3..e95f68cf 100644 --- a/tests/TestSuite_tso.py +++ b/tests/TestSuite_tso.py @@ -138,41 +138,30 @@ class TestTSO(TestCase): scanner = 'tcpdump -vv -r /tmp/tcpdump_{iface}.pcap 2>/dev/null | grep "seq" | grep "length"' return self.tcpdump_scanner(scanner.format(**locals())) - def get_chksum_value_and_verify(self, dump_pcap, save_file, Nic_list): + def get_chksum_value_and_verify(self, dump_pcap, Nic_list): packet = Packet() - self.pks = packet.read_pcapfile(dump_pcap, self.tester) - for i in range(len(self.pks)): - pks = self.pks[i] - out = repr(pks) - chksum_list = re.findall(r"chksum=(0x\w+)", out) - pks["IP"].chksum = None - if "VXLAN" in out: - pks["UDP"].chksum = None - pks["VXLAN"]["IP"].chksum = None - pks["VXLAN"]["TCP"].chksum = None - elif "GRE" in out: - pks["GRE"]["IP"].chksum = None - pks["GRE"]["TCP"].chksum = None - packet.save_pcapfile(self.tester, filename=save_file) - self.pks = Packet().read_pcapfile(dump_pcap, self.tester) - self.pks1 = Packet().read_pcapfile(save_file, self.tester) - self.tester.send_expect("rm -rf %s" % save_file, "#") - for i in range(len(self.pks1)): - pks = self.pks[i] - out = repr(pks) - chksum_list = re.findall(r"chksum=(0x\w+)", out) - out1 = repr(self.pks1[i]) - chksum_list1 = re.findall(r"chksum=(0x\w+)", out1) - if self.nic in Nic_list and "VXLAN" in out: + pkts = packet.read_pcapfile(dump_pcap, self.tester) + for pkt in pkts: + chksum_list_rx = re.findall(r"chksum\s*=\s*(0x\w+)", pkt.show(dump=True)) + pkt["IP"].chksum = None + if "VXLAN" in pkt: + pkt["UDP"].chksum = None + pkt["VXLAN"]["IP"].chksum = None + pkt["VXLAN"]["TCP"].chksum = None + elif "GRE" in pkt: + pkt["GRE"]["IP"].chksum = None + pkt["GRE"]["TCP"].chksum = None + chksum_list_good = re.findall(r"chksum\s*=\s*(0x\w+)", pkt.show2(dump=True)) + if self.nic in Nic_list and "VXLAN" in pkt: self.verify( - chksum_list[0] == chksum_list1[0] - and chksum_list[2] == chksum_list1[2] - and chksum_list[3] == chksum_list1[3], + chksum_list_rx[0] == chksum_list_good[0] + and chksum_list_rx[2] == chksum_list_good[2] + and chksum_list_rx[3] == chksum_list_good[3], "The obtained chksum value is incorrect.", ) else: self.verify( - chksum_list == chksum_list1, + chksum_list_rx == chksum_list_good, "The obtained chksum value is incorrect.", ) @@ -439,7 +428,7 @@ class TestTSO(TestCase): int(tx_outlist[num]) == loading_size % 800, "the packet segmentation incorrect, %s" % tx_outlist, ) - self.get_chksum_value_and_verify(dump_pcap, save_file, Nic_list) + self.get_chksum_value_and_verify(dump_pcap, Nic_list) for loading_size in self.loading_sizes: # Nvgre test @@ -474,7 +463,7 @@ class TestTSO(TestCase): int(tx_outlist[num]) == loading_size % 800, "the packet segmentation incorrect, %s" % tx_outlist, ) - self.get_chksum_value_and_verify(dump_pcap, save_file, Nic_list) + self.get_chksum_value_and_verify(dump_pcap, Nic_list) def test_perf_TSO_2ports(self): """ -- 2.25.1