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 58955591E for ; Mon, 9 Nov 2015 03:46:54 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 08 Nov 2015 18:46:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,264,1444719600"; d="scan'208";a="814996025" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 08 Nov 2015 18:46:53 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Nov 2015 18:46:52 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 8 Nov 2015 18:46:52 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.42]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.83]) with mapi id 14.03.0248.002; Mon, 9 Nov 2015 10:46:50 +0800 From: "Tu, LijuanX A" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH 1/3] Add multiple pthread test suite, Thread-Index: AQHRGpgoCo08x5bTs0y3LOwHNZIbxp6S/Bng Date: Mon, 9 Nov 2015 02:46:50 +0000 Message-ID: <38D041F150D4184C8114E499040E62340723C93E@shsmsx102.ccr.corp.intel.com> References: <1446633072-40477-1-git-send-email-lijuanx.a.tu@intel.com> <5640080B.1060306@intel.com> In-Reply-To: <5640080B.1060306@intel.com> Accept-Language: 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/3] Add multiple pthread test suite, 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, 09 Nov 2015 02:46:55 -0000 Thanks for your advise ,I will do it as soon as possible -----Original Message----- From: Liu, Yong=20 Sent: Monday, November 09, 2015 10:42 AM To: Tu, LijuanX A; dts@dpdk.org Subject: Re: [dts] [PATCH 1/3] Add multiple pthread test suite, Lijuan, You may need one function to strip lcore of one application. This function = will reduce lots of redundant codes. The function should like below. Further more, it's better to implement it i= n crb.py and support both FreeBSD and Linux. def strip_lcore_byname(app_name=3D"testpmd") lcores =3D [] ... return lcores On 11/04/2015 06:31 PM, Lijuan Tu wrote: > From: lijuan tu > > There're three cases contained in this suite > 1)Basic operation > 2)Positive Test > 3)Negative Test > > Signed-off-by: lijuan tu > --- > tests/TestSuite_multiple_pthread.py | 601 +++++++++++++++++++++++++++++= +++++++ > 1 file changed, 601 insertions(+) > create mode 100644 tests/TestSuite_multiple_pthread.py > > diff --git a/tests/TestSuite_multiple_pthread.py=20 > b/tests/TestSuite_multiple_pthread.py > new file mode 100644 > index 0000000..197fa03 > --- /dev/null > +++ b/tests/TestSuite_multiple_pthread.py > @@ -0,0 +1,601 @@ > +# 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=20 > +# modification, are permitted provided that the following conditions=20 > +# 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=20 > +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=20 > +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE=20 > +COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,=20 > +INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES=20 > +(INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR=20 > +SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION)=20 > +HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT,=20 > +STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE)=20 > +ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF= THE POSSIBILITY OF SUCH DAMAGE. > + > +""" > +DPDK Test suite. > + > +Test Multiple Pthread Feature > + > +""" > + > +import dts > +import time > +import re > +import os > +from test_case import TestCase > +from pmd_output import PmdOutput > + > +# > +# > +# Test class. > +# > + > + > +class TestMultiplePthread(TestCase): > + > + # > + # > + # > + # Test cases. > + # > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.ports =3D self.dut.get_ports() > + self.portmask =3D dts.create_mask(self.dut.get_ports(self.nic)) > + self.verify(len(self.ports) >=3D 2, "Insufficient number of port= s.") > + self.ports_socket =3D self.dut.get_numa_id(self.ports[0]) > + self.pmdout =3D PmdOutput(self.dut) > + > + def get_stats(self, portid): > + """ > + Get packets number from port statistic. > + """ > + output =3D PmdOutput(self.dut) > + stats =3D output.get_pmd_stats(portid) > + return stats > + > + def check_forwarding(self, ports): > + for i in range(len(ports)): > + if i % 2 =3D=3D 0: > + self.send_packet(ports[i], ports[i + 1]) > + self.send_packet(ports[i + 1], ports[i]) > + > + def send_packet(self, txPort, rxPort): > + """ > + Send packages according to parameters. > + """ > + port0_stats =3D self.get_stats(txPort) > + gp0tx_bytes =3D port0_stats['TX-bytes'] > + port1_stats =3D self.get_stats(rxPort) > + gp1rx_err =3D port1_stats['RX-errors'] > + gp1rx_bytes =3D port1_stats['RX-bytes'] > + time.sleep(5) > + > + itf =3D=20 > + self.tester.get_interface(self.tester.get_local_port(rxPort)) > + > + destMac =3D self.dut.get_mac_address(txPort) > + self.tester.scapy_foreground() > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s", src=3D"52:00:00:00:00:00")], iface= =3D"%s")' > + % (destMac, itf)) > + self.tester.scapy_execute() > + time.sleep(3) > + > + port0_stats =3D self.get_stats(txPort) > + p0tx_bytes =3D port0_stats['TX-bytes'] > + port1_stats =3D self.get_stats(rxPort) > + p1rx_err =3D port1_stats['RX-errors'] > + p1rx_bytes =3D port1_stats['RX-bytes'] > + time.sleep(5) > + > + p0tx_bytes -=3D gp0tx_bytes > + p1rx_bytes -=3D gp1rx_bytes > + p1rx_err -=3D gp1rx_err > + > + self.verify(p0tx_bytes =3D=3D p1rx_bytes, > + "Wrong TX pkts p0_tx=3D%d, p1_rx=3D%d" > + % (p0tx_bytes, p1rx_bytes)) > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def basic_operation(self, lcores, corelist): > + """ > + Basic operation > + """ > + # lcores =3D '0@8,(4-5)@9' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + for core in corelist: > + if core.isdigit() =3D=3D True: > + self.verify("Logical Core %s " % core in out, > + "set corelist error: " + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#") > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+9\s./%s/app/testpmd" \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $2}'", "#") > + count +=3D 1 > + self.verify(count =3D=3D 2, "Threads running error") > + Most cases need the function that can strip the lcores used by testpmd. It's better implement it as one function, that can be called by test cases. > + self.dut.send_expect("quit", "#") > + > + def positive_1_test(self, lcores, corelist): > + # lcores =3D '0@8,(4-5)@(8-11)' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + for core in corelist: > + if core.isdigit() =3D=3D True: > + self.verify("Logical Core %s " % core in out, > + "set corelist error:" + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 2 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '8', > + "Threads running error:cpu is %s, expect 8 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + tail -n 2", "#") > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d+\s./%s/app/testpmd"= \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '8' or out =3D=3D '9' or out =3D=3D '10' o= r out =3D=3D '11': > + count +=3D 1 > + self.verify(count =3D=3D 2, > + "Threads running error:cpu is %s, expect 2 ."=20 > + % count) > + > + self.dut.send_expect("quit", "#") > + > + def positive_2_test(self, lcores, corelist): > + # lcores =3D '1,2@(0-4,6),(3-4,6)@5,(7,8)' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + for core in corelist: > + if core.isdigit() =3D=3D True: > + self.verify("Logical Core %s " % core in out, > + "set corelist error: " + out) > + > + self.check_forwarding(self.ports) > + > + # decode lcores work cpus > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 2 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '1', > + "Threads running error:cpu is %s, expect 1 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 4 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '0' or out =3D=3D '1' or out =3D=3D '2' o= r > + out =3D=3D '3' or out =3D=3D '4' or out =3D=3D '6', > + "Threads running error") > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 7 | tail -n 3", "#") > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+5\s./%s/app/testpmd" \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '5': > + count +=3D 1 > + self.verify(count =3D=3D 3, > + "Threads running error:cpu is %s, expect 3 ." %=20 > + count) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2", "#") > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" = \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '8' or out =3D=3D '7': > + count +=3D 1 > + self.verify(count =3D=3D 2, > + "Threads running error:cpu is %s, expect 2 ." %=20 > + count) > + > + self.dut.send_expect("quit", "#") > + > + def positive_3_test(self, lcores, corelist): > + # lcores =3D '(0,127)@(4,5)' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D'%s'" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + self.verify("Logical Core 127 " in out, "set corelist error:=20 > + " + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 2",=20 > + "#") > + > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" = \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '5' or out =3D=3D '4': > + count +=3D 1 > + self.verify(count =3D=3D 2, > + "Threads running error:cpu is %s, expect 2 ." %=20 > + count) > + > + self.dut.send_expect("quit", "#") > + > + def positive_4_test(self, lcores, corelist): > + # lcores =3D '(0,64-66)@(4,5)' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + self.verify("Logical Core 64 " or "Logical Core 65 " in out, > + "set corelist error: " + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | tail -n 4",=20 > + "#") > + > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" = \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '5' or out =3D=3D '4': > + count +=3D 1 > + self.verify(count =3D=3D 4, > + "Threads running error:cpu is %s, expect 4 ." %=20 > + count) > + > + self.dut.send_expect("quit", "#") > + > + def positive_5_test(self, lcores, corelist): > + # lcores =3D '2-5,6,7-9' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + for core in corelist: > + if core.isdigit() =3D=3D True: > + self.verify("Logical Core %s " % core in out, > + "set corelist error: " + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 2 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '2', > + "Threads running error:cpu is %s, expect 2 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 4 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '3', > + "Threads running error:cpu is %s, expect 3 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 5 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '4', > + "Threads running error:cpu is %s, expect 4 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 6 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '5', > + "Threads running error:cpu is %s, expect 5 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 7 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '6', > + "Threads running error:cpu is %s, expect 6 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 8 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '7', > + "Threads running error:cpu is %s, expect 7 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 9 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '8', > + "Threads running error:cpu is %s, expect 8 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 10 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '9', > + "Threads running error:cpu is %s, expect 9 ." %=20 > + out) > + > + self.dut.send_expect("quit", "#") > + > + def positive_6_test(self, lcores, corelist): > + # lcores =3D '2, (3-5)@ 3' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + for core in corelist: > + if core.isdigit() =3D=3D True: > + self.verify("Logical Core %s " % core in out, > + "set corelist error: " + out) > + > + self.check_forwarding(self.ports) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args | \ > + head -n 2 | tail -n 1 | awk '{print $4}'", "#") > + self.verify(out =3D=3D '2', > + "Threads running error:cpu is %s, expect 2 ." %=20 > + out) > + > + out =3D self.dut.alt_session.send_expect( > + "ps -C testpmd -L -opid,tid,%cpu,psr,args", "#") > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" = \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '3': > + count +=3D 1 > + self.verify(count =3D=3D 3, > + "Threads running error:cpu is %s, expect 3 ." %=20 > + count) > + > + self.dut.send_expect("quit", "#") > + > + def positive_7_test(self, lcores, corelist): > + > + # lcores =3D '(0,64-66)@(4,5)' > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + out =3D self.dut.send_expect(pmd_cmd, "testpmd> ", 100) > + self.dut.send_expect("set fwd mac", "testpmd>") > + self.dut.send_expect("set corelist %s" % corelist, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + self.dut.send_expect("show config fwd", "testpmd> ") > + self.check_forwarding(self.ports) > + > + result_scanner =3D "\d+\s+\d+\s+\w+.\w+\s+\d\s./%s/app/testpmd" = \ > + % self.target > + scanner =3D re.compile(result_scanner, re.DOTALL) > + m =3D scanner.finditer(out) > + self.dut.alt_session.send_expect( > + "cd /sys/fs/cgroup/cpu/dpdk/thread0", "#") > + if m: > + count =3D 0 > + for i in m: > + text =3D i.group() > + self.dut.alt_session.send_expect( > + "echo '%s' > /root/temp" % text, "#") > + out =3D self.dut.alt_session.send_expect( > + "cat /root/temp | awk '{print $4}'", "#") > + if out =3D=3D '5' or out =3D=3D '4': > + count +=3D 1 > + self.verify(count =3D=3D 5, "Threads running error:cpu is %s, ex= pect 5 ." > + % count) > + > + self.dut.send_expect("quit", "#") > + > + def check_negative(self, lcores): > + """ > + """ > + pmd_cmd =3D "./%s/app/testpmd --lcores=3D'%s' -n 4 -- -i --portm= ask=3D%s" \ > + % (self.target, lcores, self.portmask) > + self.dut.send_expect(pmd_cmd, "#", 100) > + > + def test_basic_operation(self): > + """ > + Basic operation > + """ > + lcores =3D '0@8,(4-5)@9' > + corelist =3D ['4', '5', '4,5'] > + for core in corelist: > + self.basic_operation(lcores, core) > + > + def test_positive_test(self): > + """ > + Positive Test > + """ > + > + # item 1 > + lcores =3D '0@8,(4-5)@(8-11)' > + corelist =3D ['4', '5', '4,5'] > + for core in corelist: > + self.positive_1_test(lcores, core) > + > + # item 2 > + lcores =3D '1,2@(0-4,6),(3-4,6)@5,(7,8)' > + corelist =3D ['2', '3', '4', '6', '7', '8', > + '2,3', '2,4', '2,6', '2,7', '2,8', > + '3,4', '3,6', '3,7', '3,8', > + '4,6', '4,7', '4,8', > + '6,7', '6,8', > + '7,8'] > + for core in corelist: > + self.positive_2_test(lcores, core) > + > + # item 3 > + lcores =3D '(0,127)@(4,5)' > + corelist =3D ['127'] > + for core in corelist: > + self.positive_3_test(lcores, core) > + > + # item 4 > + lcores =3D '(0,64-66)@(4,5)' > + corelist =3D ['64', '65', '66', '64,65', '64,66', '65,66'] > + for core in corelist: > + self.positive_4_test(lcores, core) > + > + # item 5 > + lcores =3D '2-5,6,7-9' > + corelist =3D ['3', '4', '5', '6', '7', '8', '9', > + '3,4', '3,5', '3,6', '3,7', '3,8', '3,9', > + '4,5', '4,6', '4,7', '4,8', '4,9', > + '5,6', '5,7', '5,8', '5,9', > + '6,7', '6,8', '6,9', > + '7,8', '7,9', > + '8,9'] > + for core in corelist: > + self.positive_5_test(lcores, core) > + > + # item 6 > + lcores =3D '2, (3-5)@ 3' > + corelist =3D ['3', '4', '5', '3,4', '3,5', '4,5'] > + for core in corelist: > + self.positive_6_test(lcores, core) > + > + # item 7 > + lcores =3D '(0,7-4)@(4,5)' > + corelist =3D ['7', '6', '5', '4', > + '7,6', '7,5', '7,4', '6,5', '6,4', '5,4'] > + for core in corelist: > + self.positive_7_test(lcores, core) > + > + def test_negative_test(self): > + """ > + Negative Test > + """ > + lcores =3D [ > + '(0-,4-7)@(4,5)', > + '(-1,4-7)@(4,5)', > + '(0,4-7-9)@(4,5)', > + '(0,abcd)@(4,5)', > + '(0,4-7)@(1-,5)', > + '(0,4-7)@(-1,5)', > + '(0,4-7)@(4,5-8-9)', > + '(0,4-7)@(abc,5)', > + '(0,4-7)@(4,xyz)', > + '(0,4-7)=3D(8,9)', > + '2,3@4,(0-1,,4))', > + '[0-,4-7]@(4,5)', > + '(0-,4-7)@[4,5]', > + '3-4@3,2@5-6', > + '2,,3''2--3', > + '2,,,3''2--3'] > + for lcore in lcores: > + self.check_negative(lcore) > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.kill_all() > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """