From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 568554CB9 for ; Wed, 28 Feb 2018 03:22:13 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 18:22:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,403,1515484800"; d="scan'208";a="207604160" Received: from unknown (HELO nfvihost.sh.intel.com) ([10.239.182.51]) by fmsmga006.fm.intel.com with ESMTP; 27 Feb 2018 18:22:10 -0800 From: michael.luo@intel.com To: dts@dpdk.org Cc: yong.liu@intel.com Date: Wed, 28 Feb 2018 18:15:23 +0800 Message-Id: <1519812923-77663-1-git-send-email-michael.luo@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518087481-53786-1-git-send-email-michael.luo@intel.com> References: <1518087481-53786-1-git-send-email-michael.luo@intel.com> Subject: [dts] [PATCH v2] tests/pmdrss_hash: check reta_lines before verifying the result X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 02:22:13 -0000 From: Luo Gaoliang If reta_lines was empty, DTS shows the test case passed still. So add the checking of "reta_lines" before verifying result. And changing the variable "reta_lines" as an argument of verify function rather than a global variable. Signed-off-by: Luo Gaoliang --- tests/TestSuite_pmdrss_hash.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/TestSuite_pmdrss_hash.py b/tests/TestSuite_pmdrss_hash.py index 728c427..07c47b4 100644 --- a/tests/TestSuite_pmdrss_hash.py +++ b/tests/TestSuite_pmdrss_hash.py @@ -43,7 +43,6 @@ import utils testQueues = [16] reta_entries = [] -reta_lines = [] reta_num = 128 # Use scapy to send packets with different source and dest ip. # and collect the hash result of five tuple and the queue id. @@ -61,7 +60,7 @@ class TestPmdrssHash(TestCase): """ Sends packets. """ - global reta_lines + received_pkts = [] self.tester.scapy_foreground() self.dut.send_expect("start", "testpmd>") mac = self.dut.get_mac_address(0) @@ -172,18 +171,18 @@ class TestPmdrssHash(TestCase): name, value = item.split("=", 1) reta_line[name.strip()] = value.strip() - reta_lines.append(reta_line) + received_pkts.append(reta_line) - self.verifyResult() + self.verifyResult(received_pkts) - def verifyResult(self): + def verifyResult(self, reta_lines): """ Verify whether or not the result passes. """ - global reta_lines global reta_num result = [] + self.verify(len(reta_lines) > 0, 'No packet received!') self.result_table_create( ['packet index', 'hash value', 'hash index', 'queue id', 'actual queue id', 'pass ']) @@ -205,14 +204,13 @@ class TestPmdrssHash(TestCase): i = i + 1 self.result_table_print() - reta_lines = [] self.verify(sum(result) == 0, "the reta update function failed!") def send_packet_symmetric(self, itf, tran_type): """ Sends packets. """ - global reta_lines + received_pkts = [] self.tester.scapy_foreground() self.dut.send_expect("start", "testpmd>") mac = self.dut.get_mac_address(0) @@ -370,20 +368,22 @@ class TestPmdrssHash(TestCase): item = item.strip() if(item.startswith("RSS hash")): name, value = item.split("=", 1) + else: + continue reta_line[name.strip()] = value.strip() - reta_lines.append(reta_line) + received_pkts.append(reta_line) - self.verifyResult_symmetric() + self.verifyResult_symmetric(received_pkts) - def verifyResult_symmetric(self): + def verifyResult_symmetric(self, reta_lines): """ Verify whether or not the result passes. """ - global reta_lines global reta_num result = [] + self.verify(len(reta_lines) > 0, 'No packet received!') self.result_table_create( ['packet index', 'RSS hash', 'hash index', 'queue id', 'actual queue id', 'pass ']) @@ -407,7 +407,6 @@ class TestPmdrssHash(TestCase): i = i + 1 self.result_table_print() - reta_lines = [] self.verify( sum(result) == 0, "the symmetric RSS hash function failed!") -- 2.7.4