* [dts] [PATCH V1] fix ieee1588 get packet failed
@ 2016-01-08 8:03 xu,huilong
0 siblings, 0 replies; only message in thread
From: xu,huilong @ 2016-01-08 8:03 UTC (permalink / raw)
To: dts
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-08 8:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08 8:03 [dts] [PATCH V1] fix ieee1588 get packet failed xu,huilong
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).