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 656EA2BAA for ; Fri, 10 Feb 2017 03:35:24 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 09 Feb 2017 18:35:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,138,1484035200"; d="scan'208";a="1105436978" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 09 Feb 2017 18:35:22 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Feb 2017 18:35:22 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 9 Feb 2017 18:35:22 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Fri, 10 Feb 2017 10:35:21 +0800 From: "Liu, Yong" To: "Xu, GangX" , "dts@dpdk.org" CC: "Xu, GangX" Thread-Topic: [dts] [PATCH V1] modify link_status_interrupt test suite Thread-Index: AQHSgqyD/OD1R37fGUmm3SY5cUExYqFhhfYQ Date: Fri, 10 Feb 2017 02:35:20 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D5DCE9@SHSMSX103.ccr.corp.intel.com> References: <1486628053-21655-1-git-send-email-gangx.xu@intel.com> In-Reply-To: <1486628053-21655-1-git-send-email-gangx.xu@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 V1] modify link_status_interrupt 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: Fri, 10 Feb 2017 02:35:25 -0000 Gang, please use pep8 to check code style. And one question below. Thanks, Marvin > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of xu,gang > Sent: Thursday, February 09, 2017 4:14 PM > To: dts@dpdk.org > Cc: Xu, GangX > Subject: [dts] [PATCH V1] modify link_status_interrupt test suite >=20 > rewrite the test suite according test_plan >=20 > Signed-off-by: xu,gang > --- > tests/TestSuite_link_status_interrupt.py | 285 ++++++++++++++-----------= - > ----- > 1 file changed, 126 insertions(+), 159 deletions(-) >=20 > diff --git a/tests/TestSuite_link_status_interrupt.py > b/tests/TestSuite_link_status_interrupt.py > index c50a99d..ab6bdc1 100644 > --- a/tests/TestSuite_link_status_interrupt.py > +++ b/tests/TestSuite_link_status_interrupt.py > @@ -1,88 +1,75 @@ > -# > +#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 > +# 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. > + >=20 > """ > DPDK Test suite. > - > -Link Status Detection > - > +Test link status. > """ >=20 > -# NOTE: These tests generally won't work in automated mode since the > -# link doesn't stay down unless the cable is actually removed. The code > -# is left 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 interru= pt', > - '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 > 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) >=20 > - dutPorts =3D self.dut.get_ports(self.nic) > - self.verify(len(dutPorts) > 1, "Insufficient ports for " + > self.nic) > - 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") > + self.path =3D > "./examples/link_status_interrupt/build/link_status_interrupt" >=20 > + # build sample app > + out =3D self.dut.build_dpdk_apps("./examples/link_status_interru= pt") > + self.verify("Error" not in out, "compilation error 1") > + self.verify("No such file" not in out, "compilation error 2") > + > 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(dutPort)) > - 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 po= rt > error") > - else: > - self.verify(info[1][1] =3D=3D status, "Link status change he= llo > 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) > + > def set_up(self): > """ > Run before each test case. > @@ -91,111 +78,91 @@ 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_status_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_status_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.portmask) > + 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_mode[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.target, 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, > self.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 Look like removed verify LSC on the second port, why you remove it?