test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V2] fix ieee1588 Ether type is not PTP
@ 2017-08-24  9:51 xu,gang
  2017-08-25 11:22 ` Liu, Yong
  0 siblings, 1 reply; 2+ messages in thread
From: xu,gang @ 2017-08-24  9:51 UTC (permalink / raw)
  To: dts; +Cc: xu,gang

use tcpdump replace sniff and use packet module

Signed-off-by: xu,gang <gangx.xu@intel.com>
---
 tests/TestSuite_ieee1588.py | 50 +++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/tests/TestSuite_ieee1588.py b/tests/TestSuite_ieee1588.py
index 58d9a10..d9a7b3a 100644
--- a/tests/TestSuite_ieee1588.py
+++ b/tests/TestSuite_ieee1588.py
@@ -39,6 +39,8 @@ import time
 import re
 from test_case import TestCase
 from pmd_output import PmdOutput
+from packet import Packet
+
 
 class TestIeee1588(TestCase):
 
@@ -51,7 +53,8 @@ class TestIeee1588(TestCase):
         self.verify(len(dutPorts) > 0, "No ports found for " + self.nic)
 
         # Change the config file to support IEEE1588 and recompile the package.
-        self.dut.send_expect("sed -i -e 's/IEEE1588=n$/IEEE1588=y/' config/common_base", "# ", 30)
+        self.dut.send_expect(
+            "sed -i -e 's/IEEE1588=n$/IEEE1588=y/' config/common_base", "# ", 30)
         self.dut.skip_setup = False
         self.dut.build_install_dpdk(self.target)
 
@@ -69,32 +72,32 @@ class TestIeee1588(TestCase):
         IEEE1588 Enable test case.
         """
         self.dut.send_expect("set fwd ieee1588", "testpmd> ", 10)
-        # Waiting for 'testpmd> ' Fails due to log messages, "Received non PTP packet", in the output
-        self.dut.send_expect("start", ">", 10)  
-        # Allow the output from the "start" command to finish before looking for a regexp in expect
+        # Waiting for 'testpmd> ' Fails due to log messages, "Received non PTP
+        # packet", in the output
+        self.dut.send_expect("start", ">", 10)
+        # Allow the output from the "start" command to finish before looking
+        # for a regexp in expect
         time.sleep(1)
 
         # use the first port on that self.nic
         dutPorts = self.dut.get_ports()
-        mac =  self.dut.get_mac_address(dutPorts[0])
+        mac = self.dut.get_mac_address(dutPorts[0])
         port = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(port)
 
-        self.tester.scapy_background()
-        self.tester.scapy_append('p = sniff(iface="%s", count=2)' % itf)
-        self.tester.scapy_append('RESULT = p[1].summary()')
+        self.tester.send_expect(
+            "tcpdump -i %s -e ether src %s" % (itf, mac), "tcpdump", 20)
 
-        # this is the output of sniff
-        # [<Ether  dst=01:1b:19:00:00:00 src=00:00:00:00:00:00 type=0x88f7 |<Raw  load='\x00\x02' |>>]
-        self.tester.scapy_foreground()
-        self.tester.scapy_append('nutmac="%s"' % mac)
-        self.tester.scapy_append('sendp([Ether(dst=nutmac,type=0x88f7)/"\\x00\\x02"], iface="%s")' % itf)
-        self.tester.scapy_append('time.sleep(1)')
+        pkt = Packet(pkt_type='TIMESYNC')
+        pkt.config_layer('ether', {'dst': mac, })
+        pkt.send_pkt(tx_port=itf)
+
+        time.sleep(1)
+        out = self.tester.get_session_output(timeout=20)
+
+        self.tester.send_expect("^C", "# ", 20)
 
-        self.tester.scapy_execute()
-        out = self.tester.scapy_get_result()
         self.verify("0x88f7" in out, "Ether type is not PTP")
-        # self.verify("\\x00\\x02" in out, "Payload wrong in PTP")
 
         time.sleep(1)
         out = self.dut.get_session_output()
@@ -102,7 +105,7 @@ class TestIeee1588(TestCase):
 
         text = utils.regexp(out, "(.*) by hardware")
         self.verify("IEEE1588 PTP V2 SYNC" in text, "Not filtered " + text)
-        
+
         pattern_rx = re.compile("RX timestamp value (\d+) s (\d+) ns")
         pattern_tx = re.compile("TX timestamp value (\d+) s (\d+) ns")
 
@@ -126,17 +129,19 @@ class TestIeee1588(TestCase):
 
         # use the first port on that self.nic
         dutPorts = self.dut.get_ports()
-        mac =  self.dut.get_mac_address(dutPorts[0])
+        mac = self.dut.get_mac_address(dutPorts[0])
         port = self.tester.get_local_port(dutPorts[0])
         itf = self.tester.get_interface(port)
 
         self.tester.scapy_background()
-        self.tester.scapy_append('p = sniff(iface="%s", count=2, timeout=1)' % itf)
+        self.tester.scapy_append(
+            'p = sniff(iface="%s", count=2, timeout=1)' % itf)
         self.tester.scapy_append('RESULT = p[1].summary()')
 
         self.tester.scapy_foreground()
         self.tester.scapy_append('nutmac="%s"' % mac)
-        self.tester.scapy_append('sendp([Ether(dst=nutmac,type=0x88f7)/"\\x00\\x02"], iface="%s")' % itf)
+        self.tester.scapy_append(
+            'sendp([Ether(dst=nutmac,type=0x88f7)/"\\x00\\x02"], iface="%s")' % itf)
 
         self.tester.scapy_execute()
         time.sleep(2)
@@ -157,5 +162,6 @@ class TestIeee1588(TestCase):
         self.dut.send_expect("quit", "# ", 30)
 
         # Restore the config file and recompile the package.
-        self.dut.send_expect("sed -i -e 's/IEEE1588=y$/IEEE1588=n/' config/common_base", "# ", 30)
+        self.dut.send_expect(
+            "sed -i -e 's/IEEE1588=y$/IEEE1588=n/' config/common_base", "# ", 30)
         self.dut.build_install_dpdk(self.target)
-- 
1.9.3

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

* Re: [dts] [PATCH V2] fix ieee1588 Ether type is not PTP
  2017-08-24  9:51 [dts] [PATCH V2] fix ieee1588 Ether type is not PTP xu,gang
@ 2017-08-25 11:22 ` Liu, Yong
  0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2017-08-25 11:22 UTC (permalink / raw)
  To: xu,gang, dts

Thanks, applied with some commit log changes.

On 08/24/2017 05:51 PM, xu,gang wrote:
> use tcpdump replace sniff and use packet module
>
> Signed-off-by: xu,gang<gangx.xu@intel.com>

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

end of thread, other threads:[~2017-08-25  2:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24  9:51 [dts] [PATCH V2] fix ieee1588 Ether type is not PTP xu,gang
2017-08-25 11:22 ` 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).