From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DD256A3160 for ; Sat, 12 Oct 2019 07:35:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 90E551EB91; Sat, 12 Oct 2019 07:35:47 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 870311EB88 for ; Sat, 12 Oct 2019 07:35:45 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2019 22:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,286,1566889200"; d="scan'208";a="224551315" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 11 Oct 2019 22:35:44 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 11 Oct 2019 22:35:44 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 11 Oct 2019 22:35:43 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.96]) by SHSMSX154.ccr.corp.intel.com ([10.239.6.54]) with mapi id 14.03.0439.000; Sat, 12 Oct 2019 13:35:41 +0800 From: "Tu, Lijuan" To: "Han, YingyaX" , "dts@dpdk.org" CC: "Han, YingyaX" Thread-Topic: [dts] [PATCH V1]tests/multiple_pthread: add test suite Thread-Index: AQHVdQ2NBwMyJU8xB0KIwVlf4UNU/KdWk59g Date: Sat, 12 Oct 2019 05:35:41 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB3EA25@SHSMSX101.ccr.corp.intel.com> References: <20190927162805.5337-1-yingyax.han@intel.com> In-Reply-To: <20190927162805.5337-1-yingyax.han@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2ZiYTNhNTItZGYwNS00M2U1LWJkNGYtNmUzZTI1Yzc2NTBhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiYmJzYkx1N2xmdFpCallyblJ6RDFsTnZkNDFkM3lSR3BGRHZubEVvbkFoZHplMmxZYzdYb2FFTEJTcVg4Z2VoaiJ9 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 V1]tests/multiple_pthread: add 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of hanyingya > Sent: Saturday, September 28, 2019 12:28 AM > To: dts@dpdk.org > Cc: Han, YingyaX > Subject: [dts] [PATCH V1]tests/multiple_pthread: add test suite >=20 > Signed-off-by: hanyingya > --- > tests/TestSuite_multiple_pthread.py | 240 ++++++++++++++++++++++++++++ > 1 file changed, 240 insertions(+) > create mode 100644 tests/TestSuite_multiple_pthread.py >=20 > diff --git a/tests/TestSuite_multiple_pthread.py > b/tests/TestSuite_multiple_pthread.py > new file mode 100644 > index 0000000..1ea71a5 > --- /dev/null > +++ b/tests/TestSuite_multiple_pthread.py > @@ -0,0 +1,240 @@ > +# BSD LICENSE > +# > +# Copyright(c) 2019 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. > + > +import time > +import os > +import re > +import random > +import string > +import utils > +from test_case import TestCase > + > + > +class TestMultiplePthread(TestCase): > + > + def set_up_all(self): > + """ > + Run at the start of each test suite. > + """ > + self.verify(self.dut.get_os_type() =3D=3D 'linux', "Test suite c= urrently only > supports Linux platforms") > + self.dut_ports =3D self.dut.get_ports(self.nic) > + global valports > + valports =3D [_ for _ in self.dut_ports if self.tester.get_local= _port(_) !=3D -1] > + # Verify that enough ports are available > + self.verify(len(valports) >=3D 1, "Insufficient ports for testin= g") > + # get socket and cores > + self.socket =3D self.dut.get_numa_id(self.dut_ports[0]) > + self.cores =3D self.dut.get_core_list("1S/8C/1T", socket=3Dself.= socket) > + self.verify(self.cores is not None, "Requested 8 cores failed") > + self.out_view =3D {'header': [], 'data': []} > + > + def set_up(self): > + """ > + Run before each test case. > + """ > + pass > + > + def destroy_packets_session(self): > + """ > + close send packets session. > + """ > + for i in valports: > + self.tester.create_session(name=3D"%s" % i).send_expect("^C"= , "#") > + > + self.tester.destroy_session(self.tester.create_session(name=3D"%s" % i)= ) > + > + def send_packet(self): > + """ > + create sessions and Send packets continuous. > + """ > + for index in valports: > + localPort =3D self.tester.get_local_port(index) > + iface =3D self.tester.get_interface(localPort) > + self.send_packets_session =3D self.tester.create_session(nam= e=3D"%s" % > index) > + packet =3D r'sendp([Ether()/IP(src=3D"1.2.3.4", dst=3D"192.1= 68.0.%d")], > iface=3D"%s", loop=3D1)' % (index, iface) > + self.send_packets_session.send_expect("scapy", ">>>") > + self.send_packets_session.send_command(packet) > + > + def get_cores_statistic(self, cmdline): > + """ > + Get cpu and thread statistics. > + """ > + mutiple_pthread_session =3D self.dut.new_session() > + out =3D mutiple_pthread_session.send_expect("ps -C testpmd -L - > opid,tid,%cpu,psr,args", "#", 20) > + m =3D cmdline.replace('"', '', 2) > + out_list =3D out.split(m) > + mutiple_pthread_session.send_expect("^C", "#") > + return out_list > + > + def verify_before_send_packets(self, out_list): > + """ > + handle out info before send packets and recode the status. > + """ > + for data in out_list: > + if data !=3D '': > + data_row =3D re.findall(r'[\d\.]+', data) > + if data_row[0] =3D=3D data_row[1]: > + self.verify(data_row[2] > 0, "master thread are not = running") > + # add data to the table > + self.result_table_add(data_row) > + self.out_view['data'].append(data_row) > + > + def verify_after_send_packets(self, out_list, lcore_list): > + """ > + handle out info after send packets and verify the core's status. > + """ > + for data in out_list: > + if data !=3D '': > + data_row =3D re.findall(r'[\d\.]+', data) > + for lcore in lcore_list: > + if data_row[3] =3D=3D lcore: > + self.verify(data_row[2] > 0, "TID:%s not running= " % > data_row[1]) > + self.result_table_add(data_row) > + self.out_view['data'].append(data_row) > + # print table > + self.result_table_print() > + > + def multiple_pthread_test(self, lcores, cpu_list, lcore_list): > + """ > + multiple pthread test according to lcores, cpus, etc. > + """ > + header_row =3D ["PID", "TID", "%CPU", "PSRF"] > + self.out_view['header'] =3D header_row > + self.result_table_create(header_row) > + self.out_view['data'] =3D [] > + > + cmdline =3D './x86_64-native-linuxapp-gcc/app/testpmd --lcores= =3D"%s" -n > 4 -- -i' % lcores > + # start application > + self.dut.send_expect(cmdline, "testpmd", 60) > + > + out_list =3D self.get_cores_statistic(cmdline) > + self.verify_before_send_packets(out_list) > + > + # set testpmd corelist > + m =3D "" > + for cpu in cpu_list: > + m +=3D "%s," % cpu > + setline =3D "set corelist %s" % m[:-1] > + self.dut.send_expect(setline, "testpmd> ") > + self.dut.send_expect("start", "testpmd> ") > + out =3D self.dut.send_expect("show config fwd", "testpmd> ") > + # check fwd config > + if len(cpu_list) >=3D 2: > + for core in cpu_list[:2]: > + self.verify('Logical Core %s' % core in out, "set coreli= st config failed") > + else: > + for core in cpu_list: > + self.verify('Logical Core %s' % core in out, "set coreli= st config failed") > + self.send_packet() > + # get cpu statictis and verify the result > + out_list =3D self.get_cores_statistic(cmdline) > + self.verify_after_send_packets(out_list, lcore_list) > + # quit application > + self.dut.send_expect("stop", "testpmd> ") > + self.dut.send_expect("quit", "# ", 30) > + self.destroy_packets_session() > + > + def test_basic_operation(self): > + """ > + Test an basic operation. > + """ > + # prepare cmdline > + n =3D random.sample(self.cores, 5) > + n.sort() > + lcores =3D "%s@%s,(%s,%s)@%s" % (n[0], n[1], n[2], n[3], n[4]) > + self.multiple_pthread_test(lcores, n[2:4], [n[1], n[4]]) > + > + def test_positive(self): > + """ > + Test an random parameter from an defined table which has a coupl= e of > valid lcore parameters. > + """ > + n =3D self.cores > + CONFIG_RTE_MAX_LCORE =3D 128 > + test_list =3D [ > + {"lcores": "(%s,%s)@(%s,%s)" % (n[0], > CONFIG_RTE_MAX_LCORE-1, n[1], n[2]), > + "cpu_list":[CONFIG_RTE_MAX_LCORE-1], > + "core_list":n[1:3]}, > + {"lcores": "%s@%s,(%s,%s)@(%s,%s,%s,%s)" % (n[0], n= [1], n[2], > n[3], n[4], n[5], n[6], n[7]), > + "cpu_list":n[2:4], > + "core_list":n[4:]}, > + {"lcores": "(%s,%s,%s,%s)@(%s,%s)" % (n[0], n[1], n= [2], n[3], > n[4], n[5]), > + "cpu_list":n[1:3], > + "core_list":n[4:6]}, > + {"lcores": "%s,(%s,%s,%s)@%s" % (n[0], n[1], n[2], = n[3], n[4]), > + "cpu_list":n[1:4], > + "core_list":n[4:5]}, > + {"lcores": "(%s,%s,%s,%s,%s)@(%s,%s)" % (n[0], n[1]= , n[2], n[3], > n[4], n[5], n[6]), > + "cpu_list":n[1:5], > + "core_list":n[5:7]}, > + {"lcores": > "%s,%s@(%s,%s,%s,%s,%s,%s),(%s,%s,%s)@%s,(%s,%s)" > + % (n[0], n[1], n[0], n[1], n[2], n[3], n= [4], n[5], n[2], n[3], > n[5], n[4], n[6], n[7]), > + "cpu_list":[n[1], n[2], n[3], n[5]], > + "core_list":n[1:6]} > + ] > + params_list =3D random.sample(test_list, 1) > + params =3D params_list[0] > + self.multiple_pthread_test(params["lcores"], > + params["cpu_list"], params["core_list"]) > + > + def test_negative(self): > + """ > + Test an random parameter from an defined table which has a coupl= e of > invalid lcore parameters. > + """ > + cmdline_list =3D ["./x86_64-native-linuxapp-gcc/app/testpmd --lc= ores=3D'(0- > ,4-7)@(4,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(-1,4- > 7)@(4,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4-7- > 9)@(4,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd -- > lcores=3D'(0,abcd)@(4,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)@(1-,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)@(-1,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)@(4,5-8-9)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)@(abc,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)@(4,xyz)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0,4- > 7)=3D(8,9)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'2,3 at > 4,(0-1,,4))' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'[0-,4- > 7]@(4,5)' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'(0-,4- > 7)@[4,5]' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'3-4 at > 3,2 at 5-6' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd --lcor= es=3D'2,,3''2-- > 3' -n 4 -- -i", > + "./x86_64-native-linuxapp-gcc/app/testpmd > + --lcores=3D'2,,,3''2--3' -n 4 -- -i"] > + > + cmdline =3D random.sample(cmdline_list, 1) > + out =3D self.dut.send_expect(cmdline[0], "#", 60) > + self.verify("invalid parameter" in out, "it's a valid > + parameter") > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + self.dut.kill_all() > + > + def tear_down_all(self): > + """ > + Run after each test suite. > + """ > + pass > -- > 2.17.1