From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 2B4AB5A58 for ; Wed, 8 Jul 2015 07:18:52 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 07 Jul 2015 22:18:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,429,1432623600"; d="scan'208";a="760345440" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga002.jf.intel.com with ESMTP; 07 Jul 2015 22:18:50 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 8 Jul 2015 13:18:48 +0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.46]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.146]) with mapi id 14.03.0224.002; Wed, 8 Jul 2015 13:18:47 +0800 From: "Liu, Yong" To: "Qiu, Michael" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH v2] tests: Add RRC support for queue_start_stop case Thread-Index: AQHQuH6iWl9gLs/nM0WXxVrRN6cvRp3RChbA Date: Wed, 8 Jul 2015 05:18:47 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E10E5B183@SHSMSX103.ccr.corp.intel.com> References: <1436174358-21999-1-git-send-email-michael.qiu@intel.com> <1436250630-12176-1-git-send-email-michael.qiu@intel.com> In-Reply-To: <1436250630-12176-1-git-send-email-michael.qiu@intel.com> 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 v2] tests: Add RRC support for queue_start_stop case 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: Wed, 08 Jul 2015 05:18:53 -0000 Thanks, applied into 1.1 branch. > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Michael Qiu > Sent: Tuesday, July 07, 2015 2:31 PM > To: dts@dpdk.org > Subject: [dts] [PATCH v2] tests: Add RRC support for queue_start_stop cas= e >=20 > queue_start_stop case does not support RRC yet, this patch > is to enbale this. >=20 > Also change the patch file to change to source code. >=20 > Signed-off-by: Michael Qiu > --- > v2 --> v1 > Add portmask to testpmd commanline >=20 > dep/macfwd_log.patch | 10 +++ > tests/TestSuite_queue_start_stop.py | 166 ++++++++++++++++++------------= - > ----- > 2 files changed, 92 insertions(+), 84 deletions(-) > create mode 100644 dep/macfwd_log.patch >=20 > diff --git a/dep/macfwd_log.patch b/dep/macfwd_log.patch > new file mode 100644 > index 0000000..0f657f8 > --- /dev/null > +++ b/dep/macfwd_log.patch > @@ -0,0 +1,10 @@ > +--- app/test-pmd/macfwd.c.org 2015-07-02 10:51:12.821246109 +0800 > ++++ app/test-pmd/macfwd.c 2015-07-02 10:50:11.343243319 +0800 > +@@ -102,6 +102,7 @@ > + nb_pkt_per_burst); > + if (unlikely(nb_rx =3D=3D 0)) > + return; > ++ printf("ports %u queue %u receive %u packages\n", fs->rx_port, fs- > >rx_queue, nb_rx); > + > + #ifdef RTE_TEST_PMD_RECORD_BURST_STATS > + fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; > diff --git a/tests/TestSuite_queue_start_stop.py > b/tests/TestSuite_queue_start_stop.py > index 1c4b7b7..d62cc8c 100644 > --- a/tests/TestSuite_queue_start_stop.py > +++ b/tests/TestSuite_queue_start_stop.py > @@ -44,6 +44,7 @@ import re > import os > from test_case import TestCase > from pmd_output import PmdOutput > +from settings import FOLDERS >=20 > # > # > @@ -69,7 +70,16 @@ class TestQueueStartStop(TestCase): > """ > Run before each test case. > """ > - pass > + patch_file =3D FOLDERS["Depends"] + r'/macfwd_log.patch' > + patch_dst =3D "/tmp/" > + > + # dpdk patch and build > + try: > + self.dut.session.copy_file_to(patch_file, patch_dst) > + self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", True) > + self.dut.build_dpdk_apps('./app/test-pmd') > + except Exception, e: > + raise IOError("dpdk setup failure: %s" % e) >=20 > 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) > @@ -84,7 +94,8 @@ class TestQueueStartStop(TestCase): > txitf =3D > self.tester.get_interface(self.tester.get_local_port(txPort)) > else: > itf =3D testerports > - mac =3D self.dut.get_mac_address(txPort) > + smac =3D self.tester.get_mac(self.tester.get_local_port(txPort)) > + dmac =3D self.dut.get_mac_address(txPort) >=20 > self.tester.scapy_background() > self.tester.scapy_append('p=3Dsniff(iface=3D"%s",count=3D1,timeo= ut=3D5)' % > rxitf) > @@ -94,7 +105,7 @@ class TestQueueStartStop(TestCase): >=20 > pktlen =3D pktSize - 14 > padding =3D pktlen - 20 > - > self.tester.scapy_append('sendp([Ether(dst=3D"%s")/IP()/Raw(load=3D"P"*%s= )], > iface=3D"%s")' % (mac, padding, txitf)) > + self.tester.scapy_append('sendp([Ether(src=3D"%s", > dst=3D"%s")/IP()/Raw(load=3D"P"*%s)], iface=3D"%s")' % (smac, dmac, paddi= ng, > txitf)) >=20 > self.tester.scapy_execute() > time.sleep(3) > @@ -105,102 +116,89 @@ class TestQueueStartStop(TestCase): > else: > self.verify('PPP' not in out, "stop queue failed") >=20 > - def add_code_to_dpdk(self, file_name, standard_row, add_rows, > offset=3D0): > + def patch_hotfix_dpdk(self, patch_dir, on =3D True): > """ > - 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 > + This function is to apply or remove patch for dpdk. > + patch_dir: the abs path of the patch > + on: True for apply, False for remove > """ > - 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 > + try: > + if on: > + self.dut.send_expect("patch -p0 < %s" % patch_dir, "#") > + else: > + self.dut.send_expect("patch -p0 -R < %s" % patch_dir, "#= ") > + except Exception, e: > + raise ValueError("patch_hotfix_dpdk failure: %s" % e) >=20 > def test_queue_start_stop(self): > """ > - queue start/stop test for fortville nic > + queue start/stop test > """ > - self.dut.session.copy_file_from(r'%s/app/test-pmd/macfwd.c' % > self.dut.base_dir) > - fwdmac_file =3D '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(nb_rx =3D=3D 0)', printf_lines, 2) > - self.dut.session.copy_file_to(fwdmac_file) > - self.dut.send_expect('scp /root/macfwd.c %s/app/test- > pmd/macfwd.c' % self.dut.base_dir, "#") > - self.dut.build_dpdk_apps('./app/test-pmd') > - > - self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- -i -= - > portmask=3D0x3", "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 > queue 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) > - self.dut.send_expect("quit", "testpmd>") > - > - # recover testpmd changed > - file_handel =3D open(fwdmac_file, "w") > - file_handel.writelines(sourcelines) > - file_handel.close() > - self.dut.session.copy_file_to(fwdmac_file) > - self.dut.send_expect('scp /root/macfwd.c %s/app/test- > pmd/macfwd.c' % self.dut.base_dir, "#") > + #dpdk start > + try: > + self.dut.send_expect("./app/test-pmd/testpmd -c 0xf -n 4 -- = - > i --portmask=3D0x3", "testpmd>", 120) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set promisc all off", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic) > + except Exception, e: > + raise IOError("dpdk start and first forward failure: %s" % e= ) > + > + # stop rx queue test > + try: > + 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>") > + except Exception, e: > + raise IOError("queue start/stop forward failure: %s" % e) > + > + self.verify("ports 0 queue 0 receive 1 packages" in out, "start > queue revice package failed, out =3D %s"%out) > + > + try: > + # start tx queue test > + print "test start rx and tx queue" > + self.dut.send_expect("stop", "testpmd>") > + self.dut.send_expect("port 1 txq 0 start", "testpmd>") > + self.dut.send_expect("start", "testpmd>") > + self.check_forwarding([0, 1], self.nic) > + except Exception, e: > + raise IOError("queue start/stop forward failure: %s" % e) >=20 > def tear_down(self): > """ > Run after each test case. > """ > + patch_dst =3D "/tmp/" > + > + try: > + self.dut.send_expect("stop", "testpmd>") > + self.dut.send_expect("quit", "testpmd>") > + except: > + print "Failed to quit testpmd" > + > self.dut.kill_all() >=20 > + try: > + self.patch_hotfix_dpdk(patch_dst + "macfwd_log.patch", False= ) > + except Exception, e: > + print "patch_hotfix_dpdk remove failure :%s" %e > + > 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", "#") > + 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.9.3