From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 6A5803B5 for ; Fri, 10 Feb 2017 07:54:16 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 09 Feb 2017 22:54:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,139,1484035200"; d="scan'208";a="223590868" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 09 Feb 2017 22:54:15 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Feb 2017 22:54:14 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Feb 2017 22:54:14 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Fri, 10 Feb 2017 14:54:11 +0800 From: "Xu, GangX" To: "Tu, LijuanX A" , "dts@dpdk.org" CC: "Tu, LijuanX A" Thread-Topic: [dts] [PATCH V1] add test suite link_status_interrupt Thread-Index: AQHSg2nmgZvnCEdHJkCD/wvgfnjpwaFhzdiQ Date: Fri, 10 Feb 2017 06:54:10 +0000 Message-ID: <52FE6B2C7B32C541B3B4C691E214F6AB31494540@SHSMSX101.ccr.corp.intel.com> References: <1486709437-22775-1-git-send-email-lijuanx.a.tu@intel.com> In-Reply-To: <1486709437-22775-1-git-send-email-lijuanx.a.tu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWY5MTVhMzYtYjJjYS00YzIyLWI5ZDgtZWE5MTQxM2I2ZDI2IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjVcL2JuVlwvTWdOXC82NGN3T29McGdYSjgzVkFBSDdhbE0rbjRnWWlKamhVTEU9In0= 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] add test suite link_status_interrupt 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: Fri, 10 Feb 2017 06:54:17 -0000 Hi, Please ignore this email -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Lijuan Tu Sent: Friday, February 10, 2017 2:51 PM To: dts@dpdk.org Cc: Tu, LijuanX A Subject: [dts] [PATCH V1] add test suite link_status_interrupt Signed-off-by: Lijuan Tu --- tests/TestSuite_link_status_interrupt.py | 288 ++++++++++++++-------------= ---- 1 file changed, 132 insertions(+), 156 deletions(-) diff --git a/tests/TestSuite_link_status_interrupt.py b/tests/TestSuite_lin= k_status_interrupt.py index c50a99d..ae205cc 100644 --- a/tests/TestSuite_link_status_interrupt.py +++ b/tests/TestSuite_link_status_interrupt.py @@ -1,87 +1,77 @@ -# +# BSD LICENSE +# +# Copyright(c) 2010-2017 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 COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + =20 """ DPDK Test suite. - -Link Status Detection - +Test link status. """ =20 -# NOTE: These tests generally won't work in automated mode since the -# li= nk doesn't stay down unless the cable is actually removed. The code -# is l= eft here for legacy reasons. - - import utils +import string +import time import re - -testPorts =3D [] -intr_mode =3D ['"intr_mode=3Drandom"', - '"intr_mode=3Dmsix"', '"intr_mode=3Dlegacy"', ''] -intr_mode_output =3D ['Error: bad parameter - random', 'Use MSIX interrupt= ', - 'Use legacy interrupt', 'Use MSIX interrupt by default= '] - - from test_case import TestCase - -# -# -# Test class. -# +from packet import Packet, sniff_packets, load_sniff_packets =20 =20 class TestLinkStatusInterrupt(TestCase): =20 - # - # - # - # Test cases. - # - def set_up_all(self): """ Run at the start of each test suite. - - - Link Status Interrupt Prerequisites """ + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") + cores =3D self.dut.get_core_list("1S/4C/1T") + self.coremask =3D utils.create_mask(cores) + self.portmask =3D utils.create_mask(self.dut_ports) + + self.path =3D "./examples/link_status_interrupt/build/link_status_= interrupt" =20 - dutPorts =3D self.dut.get_ports(self.nic) - self.verify(len(dutPorts) > 1, "Insufficient ports for " + self.ni= c) - for n in range(2): - testPorts.append(dutPorts[n]) - inter =3D self.tester.get_interface( - self.tester.get_local_port(testPorts[n])) - self.tester.send_expect("ifconfig %s up" % inter, "# ", 5) - out =3D self.dut.send_expect( - "make -C examples/link_status_interrupt", "# ") - self.verify("Error" not in out, "Compilation error 1") - self.verify("No such file" not in out, "Compilation error 2") + # build sample app + out =3D self.dut.build_dpdk_apps("./examples/link_status_interrupt= ") + self.verify("Error" not in out, "compilation error 1") + self.verify("No such file" not in out, "compilation error 2") =20 def set_link_status_and_verify(self, dutPort, status): """ - In registered callback... - Event type: LSC interrupt - Port 0 Link Up - speed 10000 Mbps - full-duplex - - In registered callback... - Event type: LSC interrupt - Port 0 Link Down + set link status verify results """ - - inter =3D self.tester.get_interface(self.tester.get_local_port(dut= Port)) - self.tester.send_expect("ifconfig %s %s" % (inter, status), "# ", = 10) - self.dut.send_expect("", "Port %s Link %s" % - (dutPort, status.capitalize()), 60) - out =3D self.dut.send_expect("", "Aggregate statistics", 60) - exp =3D r"Statistics for port (\d+) -+\r\n" + \ - "Link status:\s+Link (up|down)\r\n" - pattern =3D re.compile(exp) - info =3D pattern.findall(out) - if info[0][0] =3D=3D repr(dutPort): - self.verify(info[0][1] =3D=3D status, "Link status change port= error") - else: - self.verify(info[1][1] =3D=3D status, "Link status change hell= o error") + self.intf =3D self.tester.get_interface( + self.tester.get_local_port(dutPort)) + self.tester.send_expect("ifconfig %s %s" % + (self.intf, status.lower()), "# ", 10) + verify_point =3D "Port %s Link %s" % (dutPort, status) + self.dut.send_expect("", verify_point, 60) =20 def set_up(self): """ @@ -91,111 +81,97 @@ class TestLinkStatusInterrupt(TestCase): =20 def test_link_status_interrupt_change(self): """ - Link status change. + Verify Link status change """ - - memChannel =3D self.dut.get_memory_channels() - portMask =3D utils.create_mask(testPorts) - if self.drivername in ["igb_uio"]: - cmdline =3D "./examples/link_status_interrupt/build/link_statu= s_interrupt -c f -n %s -- -q 2 -p %s" % ( - memChannel, portMask) - elif self.drivername in ["vfio-pci"]: - cmdline =3D "./examples/link_status_interrupt/build/link_statu= s_interrupt -c f -n %s --vfio-intr=3Dintx -- -q 2 -p %s" % ( - memChannel, portMask) - else: - print "unknow driver" - for n in range(len(intr_mode)): - if self.drivername in ["igb_uio"]: - self.dut.send_expect("rmmod igb_uio", "# ") + if self.drivername =3D=3D "igb_uio": + cmdline =3D self.path + " -c %s -n %s -- -p %s " % ( + self.coremask, self.dut.get_memory_channels(), self.portma= sk) + for mode in ["legacy", "msix"]: + self.dut.send_expect("rmmod -f igb_uio", "#", 20) self.dut.send_expect( - "insmod %s/kmod/igb_uio.ko %s" % (self.target, intr_mo= de[n]), "# ") - out =3D self.dut.send_expect( - "dmesg -c | grep '\<%s\>'" % (intr_mode_output[n]), "#= ") - self.verify( - intr_mode_output[n] in out, "Fail to insmod igb_uio " = + intr_mode[n]) - if n =3D=3D 0: - continue - self.dut.send_expect(cmdline, "Aggregate statistics", 605) - self.dut.send_expect( - "", "Port %s Link Up.+\r\n" % (testPorts[1]), 5) - self.set_link_status_and_verify(testPorts[0], 'down') - self.set_link_status_and_verify(testPorts[0], 'up') - self.set_link_status_and_verify(testPorts[1], 'down') - self.set_link_status_and_verify(testPorts[1], 'up') - self.dut.send_expect("^C", "# ") + 'insmod %s/kmod/igb_uio.ko "intr_mode=3D%s"' % (self.t= arget, mode), "# ") + self.dut.bind_interfaces_linux() + self.dut.send_expect(cmdline, "Aggregate statistics", 60) + self.set_link_status_and_verify(self.dut_ports[0], 'Down') + self.set_link_status_and_verify(self.dut_ports[0], 'Up') + self.dut.send_expect("^C", "#", 60) + elif self.drivername =3D=3D "vfio-pci": + for mode in ["legacy", "msi", "msix"]: + cmdline =3D self.path + " -c %s -n %s --vfio-intr=3D%s -- = -p %s" % ( + self.coremask, self.dut.get_memory_channels(), mode, s= elf.portmask) + self.dut.send_expect(cmdline, "Aggregate statistics", 60) + self.set_link_status_and_verify(self.dut_ports[0], 'Down') + self.set_link_status_and_verify(self.dut_ports[0], 'Up') + self.dut.send_expect("^C", "#", 60) =20 def test_link_status_interrupt_port_available(self): """ - Port available. + interrupt all port link, then link them, + sent packet, check packets received. """ - - memChannel =3D self.dut.get_memory_channels() - portMask =3D utils.create_mask(testPorts) - if self.drivername in ["igb_uio"]: - cmdline =3D "./examples/link_status_interrupt/build/link_statu= s_interrupt -c f -n %s -- -q 2 -p %s" % ( - memChannel, portMask) - elif self.drivername in ["vfio-pci"]: - cmdline =3D "./examples/link_status_interrupt/build/link_statu= s_interrupt -c f -n %s --vfio-intr=3Dintx -- -q 2 -p %s " % ( - memChannel, portMask) - else: - print "unknow driver" - for n in range(1, len(intr_mode)): - if self.drivername in ["igb_uio"]: - self.dut.send_expect("rmmod igb_uio", "# ") + if self.drivername =3D=3D "igb_uio": + cmdline =3D self.path + " -c %s -n %s -- -p %s " % ( + self.coremask, self.dut.get_memory_channels(), self.portma= sk) + for mode in ["legacy", "msix"]: + self.dut.send_expect("rmmod -f igb_uio", "#", 20) self.dut.send_expect( - "insmod %s/kmod/igb_uio.ko %s" % (self.target, intr_mo= de[n]), "# ") - out =3D self.dut.send_expect( - "dmesg -c | grep '\<%s\>'" % (intr_mode_output[n]), "#= ") - self.verify( - intr_mode_output[n] in out, "Fail to insmod igb_uio " = + intr_mode[n]) - self.dut.send_expect(cmdline, "Aggregate statistics", 60) - self.dut.send_expect( - "", "Port %s Link Up.+\r\n" % (testPorts[1]), 5) - self.set_link_status_and_verify(testPorts[0], 'down') - self.set_link_status_and_verify(testPorts[1], 'down') - self.set_link_status_and_verify(testPorts[0], 'up') - self.set_link_status_and_verify(testPorts[1], 'up') - for m in [0, 1]: - txPort =3D self.tester.get_local_port(testPorts[m]) - rxPort =3D self.tester.get_local_port(testPorts[1 - m]) - txItf =3D self.tester.get_interface(txPort) - rxItf =3D self.tester.get_interface(rxPort) - self.tester.scapy_background() - self.tester.scapy_append( - 'p =3D sniff(iface=3D"%s", count=3D1)' % rxItf) - self.tester.scapy_append('nr_packets=3Dlen(p)') - self.tester.scapy_append('RESULT =3D str(nr_packets)') - self.tester.scapy_foreground() - self.tester.scapy_append( - 'sendp([Ether()/IP()/UDP()/("X"*46)], iface=3D"%s")' %= txItf) - self.tester.scapy_execute() - nr_packets =3D self.tester.scapy_get_result() - self.verify(nr_packets =3D=3D "1", "Fail to switch L2 fram= e") - self.dut.send_expect("^C", "# ") - - def test_link_status_interrupt_recovery(self): - """ - Recovery. - """ - if self.drivername in ["igb_uio"]: - self.dut.send_expect("^C", "# ") - self.dut.send_expect("rmmod igb_uio", "# ") - self.dut.send_expect( - "insmod %s/kmod/igb_uio.ko" % (self.target), "# ") - out =3D self.dut.send_expect( - "dmesg -c | grep '\'", "# = ") - self.verify( - 'Use MSIX interrupt by default' in out, "Fail to recovery = default igb_uio") - elif self.drivername in ["vfio-pci"]: - self.verify(Ture, "not need run this case, when used vfio driv= er") - else: - print "unknow driver" + 'insmod %s/kmod/igb_uio.ko "intr_mode=3D%s"' % (self.t= arget, mode), "# ") + self.dut.bind_interfaces_linux() + self.dut.send_expect(cmdline, "Aggregate statistics", 60) + for port in self.dut_ports: + self.set_link_status_and_verify( + self.dut_ports[port], 'Down') + time.sleep(10) + for port in self.dut_ports: + self.set_link_status_and_verify(self.dut_ports[port], = 'Up') + self.scapy_send_packet(1) + out =3D self.dut.get_session_output(timeout=3D60) + pkt_send =3D re.findall("Total packets sent:\s*(\d*)", out= ) + pkt_received =3D re.findall( + "Total packets received:\s*(\d*)", out) + self.verify(pkt_send =3D=3D pkt_received =3D=3D '1', + "Error: sent packets !=3D received packets") + self.dut.send_expect("^C", "#", 60) + elif self.drivername =3D=3D "vfio-pci": + for mode in ["legacy", "msi", "msix"]: + cmdline =3D self.path + " -c %s -n %s --vfio-intr=3D%s -- = -p %s" % ( + self.coremask, self.dut.get_memory_channels(), mode, s= elf.portmask) + self.dut.send_expect(cmdline, "Aggregate statistics", 60) + for port in self.dut_ports: + self.set_link_status_and_verify( + self.dut_ports[port], 'Down') + time.sleep(10) + for port in self.dut_ports: + self.set_link_status_and_verify(self.dut_ports[port], = 'Up') + self.scapy_send_packet(1) + out =3D self.dut.get_session_output(timeout=3D60) + pkt_send =3D re.findall("Total packets sent:\s*(\d*)", out= ) + pkt_received =3D re.findall( + "Total packets received:\s*(\d*)", out) + self.verify(pkt_send =3D=3D pkt_received =3D=3D '1', + "Error: sent packets !=3D received packets") + self.dut.send_expect("^C", "#", 60) + + def scapy_send_packet(self, num=3D1): + """ + Send a packet to port + """ + self.dmac =3D self.dut.get_mac_address(self.dut_ports[0]) + txport =3D self.tester.get_local_port(self.dut_ports[0]) + self.txItf =3D self.tester.get_interface(txport) + pkt =3D Packet(pkt_type=3D'UDP') + pkt.config_layer('ether', {'dst': self.dmac}) + pkt.send_pkt(tx_port=3Dself.txItf, count=3Dnum) =20 def tear_down(self): """ Run after each test case. """ - pass + self.dut.kill_all() + time.sleep(2) + for port in self.dut_ports: + intf =3D self.tester.get_interface(self.tester.get_local_port(= port)) + self.tester.send_expect("ifconfig %s up" % intf, "# ", 10) =20 def tear_down_all(self): """ --=20 1.9.3