test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts]  used tcpdum get package replace scapy get package
@ 2015-02-15  1:00 huilongx.xu
  2015-02-15  1:34 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: huilongx.xu @ 2015-02-15  1:00 UTC (permalink / raw)
  To: dts

scapy default get package will remove vlan id in package head,
so used linux kernel tcpdum get package form tester port.

update some variable name

Signed-off-by: huilongx.xu <huilongx.xu@intel.com>
---
 tests/TestSuite_vlan.py |   70 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
index e9813f3..08d03f8 100644
--- a/tests/TestSuite_vlan.py
+++ b/tests/TestSuite_vlan.py
@@ -51,6 +51,8 @@ class TestVlan(TestCase):
 
         Vlan Prerequistites
         """
+        global dutRxPortId
+        global dutTxPortId
 
         # Based on h/w type, choose how many ports to use
         ports = self.dut.get_ports(self.nic)
@@ -61,7 +63,8 @@ class TestVlan(TestCase):
         ports = self.dut.get_ports(self.nic)
         global valports
         valports = [_ for _ in ports if self.tester.get_local_port(_) != -1]
-
+        dutRxPortId = valports[0]
+        dutTxPortId = valports[1]
         portMask = dts.create_mask(valports[:2])
 
         self.pmdout = PmdOutput(self.dut)
@@ -69,21 +72,32 @@ class TestVlan(TestCase):
 
         self.dut.send_expect("set verbose 1", "testpmd> ")
         out = self.dut.send_expect("set fwd mac", "testpmd> ")
-        self.dut.send_expect("vlan set strip off %s" % valports[0], "testpmd> ")
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("set promisc all off", "testpmd> ")
+            self.dut.send_expect("vlan set filter on %s"%dutRxPortId, "testpmd> ")
+        self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ")
         self.verify('Set mac packet forwarding mode' in out, "set fwd rxonly error")
+    def start_tcpdump(self):
+        port = self.tester.get_local_port(dutTxPortId)
+        rxItf = self.tester.get_interface(port)
 
+        self.tester.send_expect("rm -rf ./vlan_test.cap","#")
+        self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2> /dev/null& "%rxItf,"#" )
+    def get_tcpdump_package(self):
+        self.tester.send_expect("killall tcpdump","#")
+        return self.tester.send_expect("tcpdump -nn -e -v -r ./vlan_test.cap","#")
     def vlan_send_packet(self, vid, num=1):
         """
         Send $num of packet to portid
         """
 
-        port = self.tester.get_local_port(valports[0])
+        port = self.tester.get_local_port(dutRxPortId)
         txItf = self.tester.get_interface(port)
 
-        port = self.tester.get_local_port(valports[1])
+        port = self.tester.get_local_port(dutTxPortId)
         rxItf = self.tester.get_interface(port)
 
-        mac = self.dut.get_mac_address(valports[0])
+        mac = self.dut.get_mac_address(dutRxPortId)
 
         # FIXME  send a burst with only num packet
         self.tester.scapy_background()
@@ -106,12 +120,16 @@ class TestVlan(TestCase):
         Enable receipt of VLAN packets
         """
         self.dut.send_expect("set promisc all off", "testpmd> ")
-        self.dut.send_expect("rx_vlan add 1 %s" % valports[0], "testpmd> ")
+        self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, "testpmd> ")
+        self.dut.send_expect("vlan set strip off  %s" % dutRxPortId, "testpmd> ")
         self.dut.send_expect("start", "testpmd> ", 120)
+        out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
 
+        self.start_tcpdump()
         self.vlan_send_packet(1)
-        out = self.tester.scapy_get_result()
-        self.verify("vlan=1L" in out, "Wrong vlan:" + out)
+        
+        out = self.get_tcpdump_package()
+        self.verify("vlan 1" in out, "Wrong vlan:" + out)
 
         self.dut.send_expect("stop", "testpmd> ")
 
@@ -120,13 +138,13 @@ class TestVlan(TestCase):
         Disable receipt of VLAN packets
         """
 
-        self.dut.send_expect("rx_vlan rm 1 %s" % valports[0], "testpmd> ")
+        self.dut.send_expect("rx_vlan rm 1 %s" % dutRxPortId, "testpmd> ")
         self.dut.send_expect("start", "testpmd> ", 120)
-
+        self.start_tcpdump()
         self.vlan_send_packet(1)
 
-        out = self.tester.scapy_get_result()
-        self.verify("vlan=1L" not in out, "Wrong vlan:" + out)
+        out = self.get_tcpdump_package()
+        self.verify("vlan 1" not in out, "Wrong vlan:" + out)
 
         out = self.dut.send_expect("stop", "testpmd> ")
 
@@ -134,15 +152,17 @@ class TestVlan(TestCase):
         """
         Set vlan strip on
         """
-        self.dut.send_expect("vlan set strip on %s" % valports[0], "testpmd> ", 20)
-        self.dut.send_expect("set promisc all off", "testpmd> ", 20)
-        out = self.dut.send_expect("vlan set strip on %s" % valports[0], "testpmd> ", 20)
+        self.dut.send_expect("vlan set strip on %s" % dutRxPortId, "testpmd> ", 20)
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, "testpmd> ", 20)
+        out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
         self.verify("strip on" in out, "Wrong strip:" + out)
 
         self.dut.send_expect("start", "testpmd> ", 120)
+        self.start_tcpdump()
         self.vlan_send_packet(1)
-        out = self.tester.scapy_get_result()
-        self.verify("vlan=1L" not in out, "Wrong vlan:" + out)
+        out = self.get_tcpdump_package()
+        self.verify("vlan 1" not in out, "Wrong vlan:" + out)
         out = self.dut.send_expect("quit", "#", 120)
 
     def test_vlan_strip_config_off(self):
@@ -150,14 +170,17 @@ class TestVlan(TestCase):
         Set vlan strip off
         """
 
-        self.dut.send_expect("vlan set strip off %s" % valports[0], "testpmd> ", 20)
-        out = self.dut.send_expect("show port info %s" % valports[0], "testpmd> ", 20)
+        self.dut.send_expect("vlan set strip off %s" % dutRxPortId, "testpmd> ", 20)
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, "testpmd> ", 20)
+        out = self.dut.send_expect("show port info %s" % dutRxPortId, "testpmd> ", 20)
         self.verify("strip off" in out, "Wrong strip:" + out)
         self.dut.send_expect("set nbport 2", "testpmd> ")
         self.dut.send_expect("start", "testpmd> ", 120)
+        self.start_tcpdump()
         self.vlan_send_packet(1)
-        out = self.tester.scapy_get_result()
-        self.verify("vlan=1L" in out, "Wrong strip vlan:" + out)
+        out = self.get_tcpdump_package()
+        self.verify("vlan 1" in out, "Wrong strip vlan:" + out)
         out = self.dut.send_expect("stop", "testpmd> ", 120)
 
     def FAILING_test_vlan_enable_vlan_insertion(self):
@@ -187,7 +210,10 @@ class TestVlan(TestCase):
 
         out = self.tester.scapy_get_result()
         self.verify("vlan=1L" in out, "Wrong vlan: " + out)
-        self.dut.send_expect("quit", "# ", 30)
+        if self.nic in ["fortville_eagle", "fortville_spirit", "fortville_spirit_single"]:
+            self.dut.send_expect("stop", "testpmd> ", 30)
+        else:
+            self.dut.send_expect("quit", "# ", 30)
 
     def tear_down(self):
         """
-- 
1.7.4.4

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

* Re: [dts] used tcpdum get package replace scapy get package
  2015-02-15  1:00 [dts] used tcpdum get package replace scapy get package huilongx.xu
@ 2015-02-15  1:34 ` Liu, Yong
  0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2015-02-15  1:34 UTC (permalink / raw)
  To: Xu, HuilongX, dts

Huilong, please see my comments below.

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of huilongx.xu
> Sent: Sunday, February 15, 2015 9:00 AM
> To: dts@dpdk.org
> Subject: [dts] used tcpdum get package replace scapy get package
> 
> scapy default get package will remove vlan id in package head,
> so used linux kernel tcpdum get package form tester port.
> 
> update some variable name
> 
> Signed-off-by: huilongx.xu <huilongx.xu@intel.com>
> ---
>  tests/TestSuite_vlan.py |   70 ++++++++++++++++++++++++++++++++----------
> -----
>  1 files changed, 48 insertions(+), 22 deletions(-)
> 
> diff --git a/tests/TestSuite_vlan.py b/tests/TestSuite_vlan.py
> index e9813f3..08d03f8 100644
> --- a/tests/TestSuite_vlan.py
> +++ b/tests/TestSuite_vlan.py
> @@ -51,6 +51,8 @@ class TestVlan(TestCase):
> 
>          Vlan Prerequistites
>          """
> +        global dutRxPortId
> +        global dutTxPortId
> 
>          # Based on h/w type, choose how many ports to use
>          ports = self.dut.get_ports(self.nic)
> @@ -61,7 +63,8 @@ class TestVlan(TestCase):
>          ports = self.dut.get_ports(self.nic)
>          global valports
>          valports = [_ for _ in ports if self.tester.get_local_port(_) !=
> -1]
> -
> +        dutRxPortId = valports[0]
> +        dutTxPortId = valports[1]
>          portMask = dts.create_mask(valports[:2])
> 
>          self.pmdout = PmdOutput(self.dut)
> @@ -69,21 +72,32 @@ class TestVlan(TestCase):
> 
>          self.dut.send_expect("set verbose 1", "testpmd> ")
>          out = self.dut.send_expect("set fwd mac", "testpmd> ")
> -        self.dut.send_expect("vlan set strip off %s" % valports[0],
> "testpmd> ")

Please add some comments about why FVL need set promisc off and vlan filter on.
And why FVL has different behavior from other NICs.

> +        if self.nic in ["fortville_eagle", "fortville_spirit",
> "fortville_spirit_single"]:
> +            self.dut.send_expect("set promisc all off", "testpmd> ")
> +            self.dut.send_expect("vlan set filter on %s"%dutRxPortId,
> "testpmd> ")

Please follow python Pep8 code format, you can use pep8 do such check. 

> +        self.dut.send_expect("vlan set strip off %s" % dutRxPortId,
> "testpmd> ")
>          self.verify('Set mac packet forwarding mode' in out, "set fwd
> rxonly error")
> +    def start_tcpdump(self):
> +        port = self.tester.get_local_port(dutTxPortId)
> +        rxItf = self.tester.get_interface(port)
> 
> +        self.tester.send_expect("rm -rf ./vlan_test.cap","#")
> +        self.tester.send_expect("tcpdump -i %s -w ./vlan_test.cap 2>
> /dev/null& "%rxItf,"#" )
Better save pcap file in tmp folder. After system reboot, these file will be removed automatically.

> +    def get_tcpdump_package(self):
> +        self.tester.send_expect("killall tcpdump","#")
> +        return self.tester.send_expect("tcpdump -nn -e -v -
> r ./vlan_test.cap","#")


Can we make these two functions into more generic API?
Like sniff_packets(self, intf="", count=-1, timeout=5, filter="") and dump_packets(self, pcap="", filter="").

>      def vlan_send_packet(self, vid, num=1):
>          """
>          Send $num of packet to portid
>          """
> 
> -        port = self.tester.get_local_port(valports[0])
> +        port = self.tester.get_local_port(dutRxPortId)
>          txItf = self.tester.get_interface(port)
> 
> -        port = self.tester.get_local_port(valports[1])
> +        port = self.tester.get_local_port(dutTxPortId)
>          rxItf = self.tester.get_interface(port)
> 
> -        mac = self.dut.get_mac_address(valports[0])
> +        mac = self.dut.get_mac_address(dutRxPortId)
> 
>          # FIXME  send a burst with only num packet
>          self.tester.scapy_background()
> @@ -106,12 +120,16 @@ class TestVlan(TestCase):
>          Enable receipt of VLAN packets
>          """
>          self.dut.send_expect("set promisc all off", "testpmd> ")
> -        self.dut.send_expect("rx_vlan add 1 %s" % valports[0], "testpmd>
> ")
> +        self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId, "testpmd>
> ")
> +        self.dut.send_expect("vlan set strip off  %s" % dutRxPortId,
> "testpmd> ")
>          self.dut.send_expect("start", "testpmd> ", 120)
> +        out = self.dut.send_expect("show port info %s" % dutRxPortId,
> "testpmd> ", 20)
> 
> +        self.start_tcpdump()
>          self.vlan_send_packet(1)
> -        out = self.tester.scapy_get_result()
> -        self.verify("vlan=1L" in out, "Wrong vlan:" + out)
> +
> +        out = self.get_tcpdump_package()
> +        self.verify("vlan 1" in out, "Wrong vlan:" + out)
> 
>          self.dut.send_expect("stop", "testpmd> ")
> 
> @@ -120,13 +138,13 @@ class TestVlan(TestCase):
>          Disable receipt of VLAN packets
>          """
> 
> -        self.dut.send_expect("rx_vlan rm 1 %s" % valports[0], "testpmd> ")
> +        self.dut.send_expect("rx_vlan rm 1 %s" % dutRxPortId, "testpmd> ")
>          self.dut.send_expect("start", "testpmd> ", 120)
> -
> +        self.start_tcpdump()
>          self.vlan_send_packet(1)
> 
> -        out = self.tester.scapy_get_result()
> -        self.verify("vlan=1L" not in out, "Wrong vlan:" + out)
> +        out = self.get_tcpdump_package()
> +        self.verify("vlan 1" not in out, "Wrong vlan:" + out)
> 
>          out = self.dut.send_expect("stop", "testpmd> ")
> 
> @@ -134,15 +152,17 @@ class TestVlan(TestCase):
>          """
>          Set vlan strip on
>          """
> -        self.dut.send_expect("vlan set strip on %s" % valports[0],
> "testpmd> ", 20)
> -        self.dut.send_expect("set promisc all off", "testpmd> ", 20)
> -        out = self.dut.send_expect("vlan set strip on %s" % valports[0],
> "testpmd> ", 20)
> +        self.dut.send_expect("vlan set strip on %s" % dutRxPortId,
> "testpmd> ", 20)
> +        if self.nic in ["fortville_eagle", "fortville_spirit",
> "fortville_spirit_single"]:
> +            self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId,
> "testpmd> ", 20)
> +        out = self.dut.send_expect("show port info %s" % dutRxPortId,
> "testpmd> ", 20)
>          self.verify("strip on" in out, "Wrong strip:" + out)
> 
>          self.dut.send_expect("start", "testpmd> ", 120)
> +        self.start_tcpdump()
>          self.vlan_send_packet(1)
> -        out = self.tester.scapy_get_result()
> -        self.verify("vlan=1L" not in out, "Wrong vlan:" + out)
> +        out = self.get_tcpdump_package()
> +        self.verify("vlan 1" not in out, "Wrong vlan:" + out)
>          out = self.dut.send_expect("quit", "#", 120)
> 
>      def test_vlan_strip_config_off(self):
> @@ -150,14 +170,17 @@ class TestVlan(TestCase):
>          Set vlan strip off
>          """
> 
> -        self.dut.send_expect("vlan set strip off %s" % valports[0],
> "testpmd> ", 20)
> -        out = self.dut.send_expect("show port info %s" % valports[0],
> "testpmd> ", 20)
> +        self.dut.send_expect("vlan set strip off %s" % dutRxPortId,
> "testpmd> ", 20)
> +        if self.nic in ["fortville_eagle", "fortville_spirit",
> "fortville_spirit_single"]:
> +            self.dut.send_expect("rx_vlan add 1 %s" % dutRxPortId,
> "testpmd> ", 20)
> +        out = self.dut.send_expect("show port info %s" % dutRxPortId,
> "testpmd> ", 20)

Please add some comments about when FVL need add rx vlan here.
>          self.verify("strip off" in out, "Wrong strip:" + out)
>          self.dut.send_expect("set nbport 2", "testpmd> ")
>          self.dut.send_expect("start", "testpmd> ", 120)
> +        self.start_tcpdump()
>          self.vlan_send_packet(1)
> -        out = self.tester.scapy_get_result()
> -        self.verify("vlan=1L" in out, "Wrong strip vlan:" + out)
> +        out = self.get_tcpdump_package()
> +        self.verify("vlan 1" in out, "Wrong strip vlan:" + out)
>          out = self.dut.send_expect("stop", "testpmd> ", 120)
> 
>      def FAILING_test_vlan_enable_vlan_insertion(self):
> @@ -187,7 +210,10 @@ class TestVlan(TestCase):
> 
>          out = self.tester.scapy_get_result()
>          self.verify("vlan=1L" in out, "Wrong vlan: " + out)
> -        self.dut.send_expect("quit", "# ", 30)
> +        if self.nic in ["fortville_eagle", "fortville_spirit",
> "fortville_spirit_single"]:
> +            self.dut.send_expect("stop", "testpmd> ", 30)
> +        else:
> +            self.dut.send_expect("quit", "# ", 30)
> 
>      def tear_down(self):
>          """
> --
> 1.7.4.4

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

end of thread, other threads:[~2015-02-15  1:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-15  1:00 [dts] used tcpdum get package replace scapy get package huilongx.xu
2015-02-15  1:34 ` 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).