From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C42F61DB1 for ; Mon, 8 Jun 2015 03:56:17 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 07 Jun 2015 18:56:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,570,1427785200"; d="scan'208";a="707024411" Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2015 18:56:16 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX105.gar.corp.intel.com (10.221.44.96) with Microsoft SMTP Server (TLS) id 14.3.224.2; Mon, 8 Jun 2015 09:55:36 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.120]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.50]) with mapi id 14.03.0224.002; Mon, 8 Jun 2015 09:55:34 +0800 From: "Fu, JingguoX" To: "Xu, HuilongX" , "dts@dpdk.org" Thread-Topic: [dts 3/3] [PATCH V1] add queue start queue test code Thread-Index: AQHQmesR8KvyLBkYEk+JFlCuTBNDMp2h6H6Q Date: Mon, 8 Jun 2015 01:55:34 +0000 Message-ID: <6BD6202160B55B409D4232931158226267338A@SHSMSX101.ccr.corp.intel.com> References: <1432888786-25354-1-git-send-email-huilongx.xu@intel.com> <1432888786-25354-3-git-send-email-huilongx.xu@intel.com> In-Reply-To: <1432888786-25354-3-git-send-email-huilongx.xu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: AuHZ BbTi DaOF DulW EEl0 ELHt FOq0 Fbdo FlUk GsTU Hbns HkX4 HukB IP1R JC6T J6dV; 1; ZAB0AHMAQABkAHAAZABrAC4AbwByAGcA; Sosha1_v1; 7; {1AF85E41-F129-4A30-BB94-7CDFE498D108}; agBpAG4AZwBnAHUAbwB4AC4AZgB1AEAAaQBuAHQAZQBsAC4AYwBvAG0A; Mon, 08 Jun 2015 01:55:32 GMT; UgBFADoAIABbAGQAdABzACAAMwAvADMAXQAgAFsAUABBAFQAQwBIACAAVgAxAF0AIABhAGQAZAAgAHEAdQBlAHUAZQAgAHMAdABhAHIAdAAgAHEAdQBlAHUAZQAgAHQAZQBzAHQAIABjAG8AZABlAA== x-cr-puzzleid: {1AF85E41-F129-4A30-BB94-7CDFE498D108} 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] [dts 3/3] [PATCH V1] add queue start queue test code 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: Mon, 08 Jun 2015 01:56:18 -0000 > -----Original Message----- > From: Xu, HuilongX > Sent: Friday, May 29, 2015 16:40 > To: dts@dpdk.org > Cc: Fu, JingguoX; Xu, HuilongX > Subject: [dts 3/3] [PATCH V1] add queue start queue test code >=20 > From: huilong xu >=20 >=20 > Signed-off-by: huilong xu > --- > tests/TestSuite_queue_start_stop.py | 207 > +++++++++++++++++++++++++++++++++++ > 1 files changed, 207 insertions(+), 0 deletions(-) > create mode 100644 tests/TestSuite_queue_start_stop.py >=20 > diff --git a/tests/TestSuite_queue_start_stop.py > b/tests/TestSuite_queue_start_stop.py > new file mode 100644 > index 0000000..4fdc921 > --- /dev/null > +++ b/tests/TestSuite_queue_start_stop.py > @@ -0,0 +1,207 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2010-2015 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 copyright > +# 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. > + > + > + > +""" > +DPDK Test suite. > + > +Test queue start stop Feature > + > +""" > + > +import dts > +import time > +import re > +import os > +from test_case import TestCase > +from pmd_output import PmdOutput > + > +# > +# > +# Test class. > +# > + > + > +class TestQueueStartStop(TestCase): > + # > + # > + # > + # Test cases. > + # > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.ports) >=3D 2, "Insufficient number of port= s.") > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def check_forwarding(self, ports, nic, testerports=3D[None, None], > pktSize=3D64, received=3DTrue): > + self.send_packet(ports[0], ports[1], self.nic, testerports[1], > pktSize, received) > + > + def send_packet(self, txPort, rxPort, nic, testerports=3DNone, pktSi= ze=3D64, > received=3DTrue): > + """ > + Send packages according to parameters. > + """ > + > + if testerports is None: > + rxitf =3D > self.tester.get_interface(self.tester.get_local_port(rxPort)) > + txitf =3D > self.tester.get_interface(self.tester.get_local_port(txPort)) > + else: > + itf =3D testerports > + mac =3D self.dut.get_mac_address(txPort) > + > + self.tester.scapy_background() > + self.tester.scapy_append('p=3Dsniff(iface=3D"%s",count=3D1,timeo= ut=3D5)' % > rxitf) > + self.tester.scapy_append('RESULT=3Dstr(p)') > + > + self.tester.scapy_foreground() > + > + if self.nic in ["fortville_eagle", "fortville_spirit", > + "fortville_spirit_single", "bartonhills", > + "powerville", "springville", "hartwell"]: > + pktlen =3D pktSize - 22 > + else: > + pktlen =3D pktSize - 18 > + padding =3D pktlen - 20 > + > self.tester.scapy_append('sendp([Ether(dst=3D"%s")/IP()/Raw(load=3D"\x50"= *%s)], > iface=3D"%s")' % (mac, padding, txitf)) > + > + self.tester.scapy_execute() > + time.sleep(3) > + > + out =3D self.tester.scapy_get_result() > + if received: > + self.verify('\x50\x50\x50' in out, "start queue failed") > + else: > + self.verify('\x50\x50\x50' not in out, "stop queue failed") > + > + def add_code_to_dpdk(self, file_name, standard_row, add_rows, offset= =3D0): > + """ > + this function for add code in dpdk src code file. > + file: source code full path > + standard_row: standard row for find the place that add code > + offset: need offset row number > + add_rows:add source code > + > + return: source code lines > + """ > + file_handel =3D open(file_name, "r+w") > + source_lines =3D file_handel.readlines() > + > + write_lines =3D source_lines > + > + # get the index that need add code > + index =3D -1 > + for line in write_lines: > + if standard_row in line: > + index =3D write_lines.index(line) + offset > + break > + > + # add source code and re-write the file > + # print write_lines,index > + for line in add_rows: > + write_lines.insert(index, line) > + index +=3D 1 > + # print write_lines > + file_handel.seek(file_handel.tell() * -1, 2) > + file_handel.writelines(write_lines) > + file_handel.close() > + > + return source_lines > + > + def test_queue_start_stop(self): > + """ > + queue start/stop test for fortville nic > + """ > + fwdmac_file =3D os.getcwd() + r'/dep/dpdk/app/test-pmd/macfwd.c' > + printf_lines =3D ['printf("ports %u queue %u revice %u packages"= , fs- > >rx_port, fs->rx_queue, nb_rx);\n', r'printf("\n");',"\n"] > + sourcelines =3D self.add_code_to_dpdk(fwdmac_file, r'(unlikely(n= b_rx =3D=3D > 0)', printf_lines, 2) > + self.dut.session.copy_file_to(fwdmac_file) > + self.dut.send_expect('scp /root/macfwd.c /root/dpdk/app/test- > pmd/macfwd.c', "#") > + self.dut.build_dpdk_apps('./app/test-pmd') > + > + self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i", > "testpmd>", 120) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic) > + > + # stop rx queue test > + print "test stop rx queue" > + self.dut.send_expect("stop", "testpmd>") > + self.dut.send_expect("port 0 rxq 0 stop", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic, received=3DFalse) > + > + # start rx queue test > + print "test start rx queue stop tx queue" > + self.dut.send_expect("stop", "testpmd>") > + self.dut.send_expect("port 0 rxq 0 start", "testpmd>") > + self.dut.send_expect("port 1 txq 0 stop", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic, received=3DFalse) > + out =3D self.dut.send_expect("\n", "testpmd>") > + # print out > + self.verify("ports 0 queue 0 revice 1 packages" in out, "start q= ueue > revice package failed") > + > + # start tx queue test > + print "test start rx and tx queue" > + self.dut.send_expect("stop", "testpmd>") > + self.dut.send_expect("port 0 rxq 0 start", "testpmd>") > + self.dut.send_expect("port 1 txq 0 start", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic) > + > + # recover testpmd changed > + file_handel =3D open(fwdmac_file, "w") > + file_handel.writelines(sourcelines) > + file_handel.close() > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.kill_all() > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + self.dut.kill_all() > + #self.dut.send_expect("rm -rf ./app/test-pmd/testpmd", "#") > + #self.dut.send_expect("rm -rf ./app/test-pmd/*.o", "#") > + #self.dut.send_expect("rm -rf ./app/test-pmd/build", "#") > -- > 1.7.4.4 Acked-by: Jingguo Fu