From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 652D8A052A; Tue, 2 Feb 2021 08:15:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 64D3A24027B; Tue, 2 Feb 2021 08:15:00 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 0DA5A240279 for ; Tue, 2 Feb 2021 08:14:57 +0100 (CET) IronPort-SDR: ZCWV0U+sPxBWyf7FLJ7SfA7jvJX/1UJhcS6NLkoXiNd8ZJwuPgiSeo+R8nGoCCa1ch2ORhIrZc 9tEgsfnu7mdw== X-IronPort-AV: E=McAfee;i="6000,8403,9882"; a="180034353" X-IronPort-AV: E=Sophos;i="5.79,394,1602572400"; d="scan'208";a="180034353" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 23:14:56 -0800 IronPort-SDR: li26YIncykrn+EYXta6U7o50JmwQBVyUPUfJ7LOL679FwvZsAQEInw2BiMYf+DE17LbEtoeync ud/Zjy/zdHbg== X-IronPort-AV: E=Sophos;i="5.79,394,1602572400"; d="scan'208";a="370393794" Received: from unknown (HELO localhost.localdomain) ([10.240.183.222]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2021 23:14:54 -0800 From: Ling Wei To: dts@dpdk.org Cc: Ling Wei Date: Tue, 2 Feb 2021 15:08:10 +0000 Message-Id: <20210202150810.3878371-1-weix.ling@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [dts] [PATCH V4] tests/virtio_smoke:add virtio smoke test suite with test plan X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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" v1: Add virtio smoke test suite with test plan v2: 1.Modiry Copyrint(c)<2019> to Copyrint(c)<2021>. 2.Fix CentOS check hugepagesize retrun ' 2048' dts issue. 3.Add test case run exception handing 'kill dpdk-testpmd' in set_up and tea= r_down. v3: Modify patch subject and comments decription error. v4: Modify set_up method,kill testpmd then remove vhost-net*. Signed-off-by: Ling Wei --- tests/TestSuite_virtio_smoke.py | 202 ++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 tests/TestSuite_virtio_smoke.py diff --git a/tests/TestSuite_virtio_smoke.py b/tests/TestSuite_virtio_smoke= .py new file mode 100644 index 0000000..85d9457 --- /dev/null +++ b/tests/TestSuite_virtio_smoke.py @@ -0,0 +1,202 @@ +# BSD LICENSE=0D +#=0D +# Copyright(c) <2021> Intel Corporation. All rights reserved.=0D +# All rights reserved.=0D +#=0D +# Redistribution and use in source and binary forms, with or without=0D +# modification, are permitted provided that the following conditions=0D +# are met:=0D +#=0D +# * Redistributions of source code must retain the above copyright=0D +# notice, this list of conditions and the following disclaimer.=0D +# * Redistributions in binary form must reproduce the above copyright=0D +# notice, this list of conditions and the following disclaimer in=0D +# the documentation and/or other materials provided with the=0D +# distribution.=0D +# * Neither the name of Intel Corporation nor the names of its=0D +# contributors may be used to endorse or promote products derived=0D +# from this software without specific prior written permission.=0D +#=0D +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS=0D +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT=0D +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR=0D +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT=0D +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0D +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0D +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,=0D +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY=0D +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT=0D +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE=0D +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.=0D +=0D +"""=0D +DPDK Test suite.=0D +"""=0D +=0D +import re=0D +from test_case import TestCase=0D +from pmd_output import PmdOutput=0D +DEFAULT_MTU =3D 1500=0D +TSO_MTU =3D 9000=0D +=0D +class TestVirtioSmoke(TestCase):=0D +=0D +=0D + def set_up_all(self):=0D + """=0D + Run at the start of each test suite.=0D + """=0D + self.dst_mac =3D "00:01:02:03:04:05"=0D + self.dut_ports =3D self.dut.get_ports()=0D + self.txItf =3D self.tester.get_interface(self.tester.get_local_por= t(self.dut_ports[0]))=0D + self.socket =3D self.dut.get_numa_id(self.dut_ports[0])=0D + self.cores =3D self.dut.get_core_list("all", socket=3Dself.socket)= =0D + self.vhost_cores =3D self.cores[0:3]=0D + self.virtio1_cores =3D self.cores[3:6]=0D + self.base_dir =3D self.dut.base_dir.replace('~', '/root')=0D + self.path =3D self.dut.apps_name['test-pmd']=0D + self.testpmd_name =3D self.path.split("/")[-1]=0D + self.vhost_user =3D self.dut.new_session(suite=3D"vhost-user")=0D + self.virtio_user1 =3D self.dut.new_session(suite=3D"virtio-user1")= =0D + self.pmdout_vhost_user =3D PmdOutput(self.dut, self.vhost_user)=0D + self.pmdout_virtio_user1 =3D PmdOutput(self.dut, self.virtio_user1= )=0D +=0D + def set_up(self):=0D + """=0D + Run before each test case.=0D + """=0D + self.dut.send_expect("rm -rf %s/vhost-net*" % self.base_dir, "#")= =0D + self.dut.send_expect("killall -s INT %s" % self.testpmd_name, "#")= =0D +=0D + @property=0D + def check_2M_env(self):=0D + out =3D self.dut.send_expect("cat /proc/meminfo |grep Hugepagesize= |awk '{print($2)}'", "# ")=0D + # On CentOS, sometimes return ' 2048'=0D + resp =3D out.replace(' ', '')=0D + return True if resp =3D=3D '2048' else False=0D +=0D + def launch_testpmd_as_vhost_user(self, param, cores=3D"Default", udev= =3D"", ports=3D[], no_pci=3DTrue):=0D + self.pmdout_vhost_user.start_testpmd(cores=3Dcores, param=3Dparam,= vdevs=3D[udev], ports=3Dports, prefix=3D"vhost",=0D + fixed_prefix=3DTrue, no_pci= =3Dno_pci)=0D + self.pmdout_vhost_user.execute_cmd('set fwd mac')=0D +=0D + def launch_testpmd_as_virtio_user1(self, param, cores=3D"Default", ude= v=3D"", no_pci=3DTrue):=0D + eal_param =3D ""=0D + if self.check_2M_env:=0D + eal_param +=3D " --single-file-segments"=0D + if 'vectorized' in self.running_case:=0D + eal_param +=3D " --force-max-simd-bitwidth=3D512"=0D + self.pmdout_virtio_user1.start_testpmd(cores=3Dcores, param=3Dpara= m, vdevs=3D[udev], ports=3D[], prefix=3D"virtio1",=0D + fixed_prefix=3DTrue, eal_pa= ram=3Deal_param, no_pci=3Dno_pci)=0D +=0D + def verify_vhost_queue_rx_tx_pkts(self, queue_list):=0D + out =3D self.pmdout_vhost_user.execute_cmd('stop')=0D + for queue_index in queue_list:=0D + queue =3D "Queue=3D %d" % queue_index=0D + index =3D out.find(queue)=0D + rx =3D re.search("RX-packets:\s*(\d*)", out[index:])=0D + tx =3D re.search("TX-packets:\s*(\d*)", out[index:])=0D + rx_packets =3D int(rx.group(1))=0D + tx_packets =3D int(tx.group(1))=0D + self.verify(rx_packets > 0 and tx_packets > 0,=0D + "The queue %d rx-packets or tx-packets is 0 about = " % queue_index +=0D + "rx-packets:%d, tx-packets:%d" % (rx_packets, tx_p= ackets))=0D +=0D + def test_virtio_loopback(self):=0D + param =3D " --nb-cores=3D{} --rxq=3D{} --txq=3D{}"=0D + other_param =3D " --tx-offloads=3D0x0 --enable-hw-vlan-strip --rss= -ip"=0D + vhost_dev =3D f"'eth_vhost0,iface=3Dvhost-net,client=3D1,queues=3D= 8'"=0D + virtio_dev =3D f"'net_virtio_user0,mac=3D{self.dst_mac},path=3D./v= host-net,server=3D1,queues=3D8,mrg_rxbuf=3D1,in_order=3D1'"=0D +=0D + self.logger.info("Launch vhost as client mode with 2 queues")=0D + nb_core =3D 2=0D + vhost_rxq_txq =3D 2=0D + virtio_rxq_txq =3D 8=0D + vhost_param =3D param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq= )=0D + virtio_param =3D (other_param + param).format(nb_core, virtio_rxq_= txq, virtio_rxq_txq)=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.vhost_cores, udev=3Dvhost_dev, no_pci=3DTrue)=0D + self.pmdout_vhost_user.execute_cmd('start')=0D + self.logger.info("Launch virtio-user as server mode with 8 queues"= )=0D + self.launch_testpmd_as_virtio_user1(param=3Dvirtio_param, cores=3D= self.virtio1_cores, udev=3Dvirtio_dev, no_pci=3DTrue)=0D + self.pmdout_virtio_user1.execute_cmd('set fwd mac')=0D + self.pmdout_virtio_user1.execute_cmd('start tx_first 32')=0D + self.verify_vhost_queue_rx_tx_pkts(queue_list=3Drange(vhost_rxq_tx= q))=0D + self.pmdout_vhost_user.execute_cmd('quit', '#')=0D +=0D + self.logger.info("Relaunch vhost with 8 queues and send packets")= =0D + vhost_rxq_txq =3D 8=0D + vhost_param =3D param.format(nb_core, vhost_rxq_txq, vhost_rxq_txq= )=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.cores[0:3], udev=3Dvhost_dev, no_pci=3DTrue)=0D + self.pmdout_vhost_user.execute_cmd('start tx_first 32')=0D + self.pmdout_vhost_user.execute_cmd('stop')=0D + self.pmdout_vhost_user.execute_cmd('set burst 1')=0D + self.pmdout_vhost_user.execute_cmd('start tx_first 1')=0D + self.verify_vhost_queue_rx_tx_pkts(queue_list=3Drange(vhost_rxq_tx= q))=0D +=0D + self.pmdout_virtio_user1.execute_cmd('quit', '#')=0D + self.pmdout_vhost_user.execute_cmd('quit', '#')=0D +=0D + def send_packets(self, frame_size, pkt_count):=0D + pkt =3D "Ether(dst=3D'%s')/IP()/('x'*%d)" %(self.dst_mac, frame_si= ze)=0D + self.tester.scapy_append('sendp([%s], iface=3D"%s", count=3D%s)' %= (pkt, self.txItf, pkt_count))=0D + self.tester.scapy_execute()=0D +=0D + def verify_virtio_user_receive_packets(self, pkt_count):=0D + out =3D self.pmdout_virtio_user1.execute_cmd('show port stats all'= )=0D + rx =3D re.search("RX-packets:\s*(\d*)", out)=0D + tx =3D re.search("TX-packets:\s*(\d*)", out)=0D + rx_packets =3D int(rx.group(1))=0D + tx_packets =3D int(tx.group(1))=0D + self.verify(rx_packets >=3D pkt_count and tx_packets >=3D pkt_coun= t,=0D + "Virtio-user receive no enough packets, RX-packets: {}= ,RX-packets: {}".format(rx_packets, tx_packets))=0D +=0D + def test_virtio_pvp(self):=0D + param =3D " --nb-cores=3D{} --txd=3D{} --rxd=3D{}"=0D + vhost_dev =3D f"'net_vhost0,iface=3Dvhost-net,queues=3D1'"=0D + virtio_dev =3D f"'net_virtio_user0,mac=3D{self.dst_mac},path=3D./v= host-net,packed_vq=3D1,mrg_rxbuf=3D0,in_order=3D1," \=0D + f"vectorized=3D1,queue_size=3D1024'"=0D + self.logger.info("Launch vhost")=0D + nb_core =3D 2=0D + vhost_rxd_txd =3D 1024=0D + vhost_param =3D param.format(nb_core, vhost_rxd_txd, vhost_rxd_txd= )=0D + port =3D self.dut.ports_info[self.dut_ports[0]]['pci']=0D + self.launch_testpmd_as_vhost_user(param=3Dvhost_param, cores=3Dsel= f.vhost_cores, udev=3Dvhost_dev,=0D + ports=3D[port], no_pci=3DFalse)= =0D + self.pmdout_vhost_user.execute_cmd('start')=0D +=0D + self.logger.info("Launch virtio")=0D + nb_core =3D 1=0D + virtio_param =3D param.format(nb_core, vhost_rxd_txd, vhost_rxd_tx= d)=0D + self.launch_testpmd_as_virtio_user1(param=3Dvirtio_param, cores=3D= self.virtio1_cores, udev=3Dvirtio_dev, no_pci=3DTrue)=0D + self.pmdout_virtio_user1.execute_cmd('set fwd mac')=0D + self.pmdout_virtio_user1.execute_cmd('start')=0D +=0D + self.logger.info("Start send packets and verify")=0D + # set tester port MTU=3D9000 when nedd to send big packets.=0D + self.tester.send_expect("ifconfig %s mtu %s" % (self.txItf, TSO_MT= U), "# ")=0D + # set vhost testpmd port MTU=3D9000=0D + self.pmdout_vhost_user.execute_cmd('stop')=0D + self.pmdout_vhost_user.execute_cmd('port stop 0')=0D + self.pmdout_vhost_user.execute_cmd('port config mtu 0 %s' % TSO_MT= U)=0D + self.pmdout_vhost_user.execute_cmd('port start 0')=0D + self.pmdout_vhost_user.execute_cmd('start')=0D + self.send_packets(frame_size=3D64, pkt_count=3D10)=0D + self.send_packets(frame_size=3D1518, pkt_count=3D10)=0D + self.verify_virtio_user_receive_packets(pkt_count=3D20)=0D +=0D + self.pmdout_virtio_user1.execute_cmd('quit', '#')=0D + self.pmdout_vhost_user.execute_cmd('quit', '#')=0D +=0D + def tear_down(self):=0D + """=0D + Run after each test case.=0D + """=0D + self.dut.send_expect("killall -s INT %s" % self.testpmd_name, "#")= =0D +=0D + def tear_down_all(self):=0D + """=0D + Run after each test suite.=0D + """=0D + self.dut.close_session(self.vhost_user)=0D + self.dut.close_session(self.virtio_user1)=0D + self.tester.send_expect("ifconfig %s mtu %s" % (self.txItf, DEFAUL= T_MTU), "# ")=0D --=20 2.25.1