From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 00018C1CC for ; Fri, 8 Jan 2016 09:07:54 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 08 Jan 2016 00:07:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,537,1444719600"; d="scan'208";a="722859200" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.238.55.12]) by orsmga003.jf.intel.com with ESMTP; 08 Jan 2016 00:07:35 -0800 From: "xu,huilong" To: dts@dpdk.org Date: Fri, 8 Jan 2016 16:03:11 +0800 Message-Id: <1452240191-9379-1-git-send-email-huilongx.xu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V1] fix ieee1588 get packet failed X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2016 08:07:55 -0000 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 --- 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 # [>] - 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