From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 562608DB1 for ; Thu, 24 Sep 2015 04:46:54 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 23 Sep 2015 19:46:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,579,1437462000"; d="scan'208";a="796089224" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 23 Sep 2015 19:46:53 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 23 Sep 2015 19:46:53 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 23 Sep 2015 19:46:52 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.75]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.210]) with mapi id 14.03.0248.002; Thu, 24 Sep 2015 10:46:50 +0800 From: "Liu, Yong" To: "Tang, HaifengX" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts Thread-Index: AQHQ9Qg9IA5tc8yrKEq/+6l1syPa6J5JZU6AgAEQ1ACAAIZAgA== Date: Thu, 24 Sep 2015 02:46:49 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10F052E3@SHSMSX101.ccr.corp.intel.com> References: <1442906614-89134-1-git-send-email-haifengx.tang@intel.com> <56020E8F.5030908@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts 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: Thu, 24 Sep 2015 02:46:55 -0000 Ok, please do not forget it. > -----Original Message----- > From: Tang, HaifengX > Sent: Thursday, September 24, 2015 10:46 AM > To: Liu, Yong; dts@dpdk.org > Subject: RE: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts >=20 >=20 > Hi yong : >=20 > You can merge the patch first. I will submit another patch to add the > suite into cfg file . >=20 >=20 > thanks > -----Original Message----- > From: Liu, Yong > Sent: Wednesday, September 23, 2015 10:30 AM > To: Tang, HaifengX; dts@dpdk.org > Subject: Re: [dts] [PATCH 1/2] add TestSuite_pmdpcap into dts >=20 > Haifeng, > Please add this case into default execution file. >=20 > On 09/22/2015 03:23 PM, haifeng wrote: > > Signed-off-by: haifeng > > --- > > tests/TestSuite_pmdpcap.py | 186 > +++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 186 insertions(+) > > create mode 100644 tests/TestSuite_pmdpcap.py > > > > diff --git a/tests/TestSuite_pmdpcap.py b/tests/TestSuite_pmdpcap.py > > new file mode 100644 index 0000000..41e2cfe > > --- /dev/null > > +++ b/tests/TestSuite_pmdpcap.py > > @@ -0,0 +1,186 @@ > > +# BSD LICENSE > > +# > > +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > > +# All rights reserved. > > +# > > +# Redistribution and use in source and binary forms, with or without > > +# modification, are permitted provided that the following conditions > > +# are met: > > +# > > +# * Redistributions of source code must retain the above copyright > > +# notice, this list of conditions and the following disclaimer. > > +# * Redistributions in binary form must reproduce the above copyrigh= t > > +# notice, this list of conditions and the following disclaimer in > > +# the documentation and/or other materials provided with the > > +# distribution. > > +# * Neither the name of Intel Corporation nor the names of its > > +# contributors may be used to endorse or promote products derived > > +# from this software without specific prior written permission. > > +# > > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS > > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # > > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR > > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > > +COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > > +INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > > +(INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > > +SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > > +HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, > > +STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) > > +ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED > OF THE POSSIBILITY OF SUCH DAMAGE. > > + > > +''' > > +''' > > +from test_case import TestCase > > +import dts > > + > > +from time import sleep > > +from scapy.all import * > > + > > + > > +# > > +# > > +# Test class. > > +# > > +class TestPmdPcap(TestCase): > > + > > + pcap_file_sizes =3D [1000, 500] > > + dut_pcap_files_path =3D '/root/' > > + > > + def set_up_all(self): > > + self.check_scapy_in_dut() > > + > > + self.memory_channel =3D self.dut.get_memory_channels() > > + > > + # Enable PCAP features and rebuild the package > > + self.pcap_config =3D self.get_pcap_compile_config() > > + self.dut.send_expect( > > + "sed -i > 's/CONFIG_RTE_LIBRTE_PMD_PCAP=3Dn$/CONFIG_RTE_LIBRTE_PMD_PCAP=3Dy/' > config/%s" % self.pcap_config, "# ") > > + self.dut.build_install_dpdk(self.target) > > + > > + # make sure there is no interface to bind > > + # because if there is any interface bonded to igb_uio, > > + # it will result in packet transmiting failed > > + self.dut.restore_interfaces() > > + > > + def get_pcap_compile_config(self): > > + config_head =3D "common_" > > + os_type =3D self.dut.get_os_type() > > + if os_type =3D=3D "linux": > > + config_tail =3D os_type + "app" > > + elif os_type =3D=3D "freebsd": > > + config_tail =3D "bsdapp" > > + else: > > + raise Exception( > > + "Unknow os type, please check to make sure pcap can > > + work in OS [ %s ]" % os_type) > > + > > + return config_head + config_tail > > + > > + def create_pcap_file(self, filename, number_of_packets): > > + flow =3D [] > > + for pkt_id in range(number_of_packets): > > + pkt_id =3D str(hex(pkt_id % 256)) > > + flow.append(Ether(src=3D'00:00:00:00:00:%s' % pkt_id[2:], > dst=3D'00:00:00:00:00:00') / IP( > > + src=3D'192.168.1.1', dst=3D'192.168.1.2') / ("X" * 26)= ) > > + > > + wrpcap(filename, flow) > > + > > + def check_scapy_in_dut(self): > > + try: > > + self.dut.send_expect('scapy', '>>> ') > > + self.dut.send_expect('quit()', '# ') > > + except: > > + self.verify(False, 'Scapy is required in dut.') > > + > > + def check_pcap_files(self, in_pcap, out_pcap, expected_frames): > > + > > + # Check if the number of expected frames are in the output > > + result =3D self.dut.send_expect( > > + 'tcpdump -n -e -r %s | wc -l' % out_pcap, '# ') > > + self.verify(str(expected_frames) in result, > > + 'Not all packets have been forwarded') > > + > > + # Check if the frames in the input and output files match > > + self.dut.send_expect('scapy', '>>> ') > > + self.dut.send_expect('input=3Drdpcap("%s")' % in_pcap, '>>> ') > > + self.dut.send_expect('output=3Drdpcap("%s")' % out_pcap, '>>> = ') > > + self.dut.send_expect( > > + 'result=3D[input[i]=3D=3Doutput[i] for i in xrange(len(inp= ut))]', > '>>> ') > > + result =3D self.dut.send_expect('False in result', '>>> ') > > + self.dut.send_expect('quit()', '# ') > > + > > + self.verify('True' not in result, 'In/Out packets do not > > + match.') > > + > > + def test_send_packets_with_one_device(self): > > + in_pcap =3D 'in_pmdpcap.pcap' > > + out_pcap =3D '/tmp/out_pmdpcap.pcap' > > + > > + two_cores =3D self.dut.get_core_list("1S/2C/1T") > > + core_mask =3D dts.create_mask(two_cores) > > + > > + self.create_pcap_file(in_pcap, TestPmdPcap.pcap_file_sizes[0]) > > + self.dut.session.copy_file_to(in_pcap) > > + > > + command =3D ("./{}/app/testpmd -c {} -n {} " + > > + "--vdev=3Deth_pcap0,rx_pcap=3D{},tx_pcap=3D{} " + > > + "-- -i --port-topology=3Dchained") > > + > > + self.dut.send_expect(command.format(self.target, core_mask, > > + self.memory_channel, > > + TestPmdPcap.dut_pcap_files_path + in_pcap= , > > + out_pcap), 'testpmd> ', 15) > > + > > + self.dut.send_expect('start', 'testpmd> ') > > + sleep(2) > > + self.dut.send_expect('stop', 'testpmd> ') > > + self.dut.send_expect('quit', '# ') > > + > > + self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + in_pca= p, > > + out_pcap, > > + TestPmdPcap.pcap_file_sizes[0]) > > + > > + def test_send_packets_with_two_devices(self): > > + > > + in_pcap1 =3D 'in1_pmdpcap.pcap' > > + out_pcap1 =3D '/tmp/out1_pmdpcap.pcap' > > + > > + in_pcap2 =3D 'in2_pmdpcap.pcap' > > + out_pcap2 =3D '/tmp/out2_pmdpcap.pcap' > > + > > + four_cores =3D self.dut.get_core_list("1S/4C/1T") > > + core_mask =3D dts.create_mask(four_cores) > > + > > + self.create_pcap_file(in_pcap1, TestPmdPcap.pcap_file_sizes[0]= ) > > + self.dut.session.copy_file_to(in_pcap1) > > + self.create_pcap_file(in_pcap2, TestPmdPcap.pcap_file_sizes[1]= ) > > + self.dut.session.copy_file_to(in_pcap2) > > + > > + command =3D ("./{}/app/testpmd -c {} -n {} " + > > + "--vdev=3Deth_pcap0,rx_pcap=3D{},tx_pcap=3D{} " + > > + "--vdev=3Deth_pcap1,rx_pcap=3D{},tx_pcap=3D{} " + > > + "-- -i") > > + > > + self.dut.send_expect(command.format(self.target, core_mask, > > + self.memory_channel, > > + > TestPmdPcap.dut_pcap_files_path + > > + in_pcap1, > > + out_pcap1, > > + > TestPmdPcap.dut_pcap_files_path + > > + in_pcap2, > > + out_pcap2), 'testpmd> ', > > + 10) > > + > > + self.dut.send_expect('start', 'testpmd> ') > > + sleep(2) > > + self.dut.send_expect('stop', 'testpmd> ') > > + self.dut.send_expect('quit', '# ') > > + > > + self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + > in_pcap1, > > + out_pcap2, > > + TestPmdPcap.pcap_file_sizes[0]) > > + > > + self.check_pcap_files(TestPmdPcap.dut_pcap_files_path + > in_pcap2, > > + out_pcap1, > > + TestPmdPcap.pcap_file_sizes[1]) > > + > > + def tear_down_all(self): > > + # Disable PCAP feature and rebuild the package > > + self.dut.send_expect( > > + "sed -i > 's/CONFIG_RTE_LIBRTE_PMD_PCAP=3Dy$/CONFIG_RTE_LIBRTE_PMD_PCAP=3Dn/' > config/%s" % self.pcap_config, "# ") > > + self.dut.set_target(self.target)