test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] tests/pmdrss_hash: check reta_lines before verifying the result
@ 2018-02-08 10:58 michael.luo
  2018-02-11  1:38 ` Liu, Yong
  2018-02-28 10:15 ` [dts] [PATCH v2] " michael.luo
  0 siblings, 2 replies; 4+ messages in thread
From: michael.luo @ 2018-02-08 10:58 UTC (permalink / raw)
  To: dts

From: Luo Gaoliang <michael.luo@intel.com>

If reta_lines was empty, DTS shows the test case passed still.
So add the checking of reta_lines before verifying result.

Signed-off-by: Luo Gaoliang <michael.luo@intel.com>
---
 tests/TestSuite_pmdrss_hash.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/TestSuite_pmdrss_hash.py b/tests/TestSuite_pmdrss_hash.py
index 78e4075..7a1f870 100644
--- a/tests/TestSuite_pmdrss_hash.py
+++ b/tests/TestSuite_pmdrss_hash.py
@@ -184,6 +184,7 @@ class TestPmdrssHash(TestCase):
         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 '])
 
@@ -370,6 +371,8 @@ 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)
@@ -384,6 +387,7 @@ class TestPmdrssHash(TestCase):
         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 '])
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dts] [PATCH] tests/pmdrss_hash: check reta_lines before verifying the result
  2018-02-08 10:58 [dts] [PATCH] tests/pmdrss_hash: check reta_lines before verifying the result michael.luo
@ 2018-02-11  1:38 ` Liu, Yong
  2018-02-28 10:15 ` [dts] [PATCH v2] " michael.luo
  1 sibling, 0 replies; 4+ messages in thread
From: Liu, Yong @ 2018-02-11  1:38 UTC (permalink / raw)
  To: Luo, Michael, dts

Thanks, Michael. 
I'm fine with the logic refine, but variable "reta_lines" should better be an argument of verify function than a global variable. 
Could you please modify your patch?

Regards,
Marvin


> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of michael.luo@intel.com
> Sent: Thursday, February 08, 2018 6:58 PM
> To: dts@dpdk.org
> Subject: [dts] [PATCH] tests/pmdrss_hash: check reta_lines before
> verifying the result
> 
> From: Luo Gaoliang <michael.luo@intel.com>
> 
> If reta_lines was empty, DTS shows the test case passed still.
> So add the checking of reta_lines before verifying result.
> 
> Signed-off-by: Luo Gaoliang <michael.luo@intel.com>
> ---
>  tests/TestSuite_pmdrss_hash.py | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tests/TestSuite_pmdrss_hash.py
> b/tests/TestSuite_pmdrss_hash.py
> index 78e4075..7a1f870 100644
> --- a/tests/TestSuite_pmdrss_hash.py
> +++ b/tests/TestSuite_pmdrss_hash.py
> @@ -184,6 +184,7 @@ class TestPmdrssHash(TestCase):
>          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 '])
> 
> @@ -370,6 +371,8 @@ 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)
> @@ -384,6 +387,7 @@ class TestPmdrssHash(TestCase):
>          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 '])
> 
> --
> 2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dts] [PATCH v2] tests/pmdrss_hash: check reta_lines before verifying the result
  2018-02-08 10:58 [dts] [PATCH] tests/pmdrss_hash: check reta_lines before verifying the result michael.luo
  2018-02-11  1:38 ` Liu, Yong
@ 2018-02-28 10:15 ` michael.luo
  2018-03-02 10:15   ` Liu, Yong
  1 sibling, 1 reply; 4+ messages in thread
From: michael.luo @ 2018-02-28 10:15 UTC (permalink / raw)
  To: dts; +Cc: yong.liu

From: Luo Gaoliang <michael.luo@intel.com>

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 <michael.luo@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dts] [PATCH v2] tests/pmdrss_hash: check reta_lines before verifying the result
  2018-02-28 10:15 ` [dts] [PATCH v2] " michael.luo
@ 2018-03-02 10:15   ` Liu, Yong
  0 siblings, 0 replies; 4+ messages in thread
From: Liu, Yong @ 2018-03-02 10:15 UTC (permalink / raw)
  To: michael.luo, dts

Thanks Michael, applied in.

On 02/28/2018 06:15 PM, michael.luo@intel.com wrote:
> From: Luo Gaoliang<michael.luo@intel.com>
>
> 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<michael.luo@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-02  2:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 10:58 [dts] [PATCH] tests/pmdrss_hash: check reta_lines before verifying the result michael.luo
2018-02-11  1:38 ` Liu, Yong
2018-02-28 10:15 ` [dts] [PATCH v2] " michael.luo
2018-03-02 10:15   ` Liu, Yong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).