test suite reviews and discussions
 help / color / mirror / Atom feed
From: "xu,huilong" <huilongx.xu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH V1] fix ieee1588 get packet failed
Date: Fri,  8 Jan 2016 16:03:11 +0800	[thread overview]
Message-ID: <1452240191-9379-1-git-send-email-huilongx.xu@intel.com> (raw)

when we test forville nic ieee1588 case, sometimes we get packet by scapy.
the packet as below:
"68:05:ca:27:d5:8e > 00:00:00:00:00:00 (0x88f7) / Raw"
so used tcpdump replace scapy get packet

Signed-off-by: xu,huilong <huilongx.xu@intel.com>
---
 tests/TestSuite_ieee1588.py | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/tests/TestSuite_ieee1588.py b/tests/TestSuite_ieee1588.py
index 012d601..04b9132 100644
--- a/tests/TestSuite_ieee1588.py
+++ b/tests/TestSuite_ieee1588.py
@@ -66,7 +66,13 @@ class TestIeee1588(TestCase):
         Run before each test case.
         """
         pass
+    def start_tcpdump(self, intf, tcpdump_name):
+        self.tester.send_expect(r'rm -rf ./%s' % tcpdump_name, "# ")
+        self.tester.send_expect(r'tcpdump -i %s -w ./%s 2> /dev/null &' % (intf, tcpdump_name), "# ")
 
+    def get_packet(self, tcpdump_name):
+        self.tester.send_expect("killall tcpdump", "# ")
+        return self.tester.send_expect("tcpdump -nn -e -v -r %s" % tcpdump_name, "# ")
     def test_ieee1588_enable(self):
         """
         IEEE1588 Enable test case.
@@ -82,22 +88,22 @@ class TestIeee1588(TestCase):
         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()')
-
+        tcpdump_filename = "ieee1588.cpa"
+        
+        self.start_tcpdump(itf, tcpdump_filename)
         # 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)')
 
         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")
+        out = self.get_packet(tcpdump_filename)
+
+        # rx port same with tx port in ieee1588 function,
+        # so count 0x88f7(packet type) and 0002(pyload) number, it should 2i
+        self.verify( 2 == out.count("0x88f7"), "Ether type is not PTP")
+        self.verify(2 == out.count("0002"), "Payload wrong in PTP")
 
         time.sleep(1)
         out = self.dut.get_session_output()
-- 
1.9.3

                 reply	other threads:[~2016-01-08  8:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452240191-9379-1-git-send-email-huilongx.xu@intel.com \
    --to=huilongx.xu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).