From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C2949FAB4 for ; Mon, 16 Jan 2017 06:56:09 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 15 Jan 2017 21:56:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,237,1477983600"; d="scan'208";a="1113237779" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 15 Jan 2017 21:56:08 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 15 Jan 2017 21:56:08 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 15 Jan 2017 21:56:08 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Mon, 16 Jan 2017 13:56:05 +0800 From: "Liu, Yong" To: "Mo, YufengX" , "dts@dpdk.org" CC: "Mo, YufengX" Thread-Topic: [dts] [PATCH V1 2/2] userspace_ethtool: update automation testing script. Thread-Index: AQHSb6tT9+PaokGbn0KRUan46j1dSqE6j09g Date: Mon, 16 Jan 2017 05:56:04 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D47F42@SHSMSX103.ccr.corp.intel.com> References: <1484538512-45811-1-git-send-email-yufengx.mo@intel.com> <1484538512-45811-3-git-send-email-yufengx.mo@intel.com> In-Reply-To: <1484538512-45811-3-git-send-email-yufengx.mo@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 2/2] userspace_ethtool: update automation testing script. 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, 16 Jan 2017 05:56:10 -0000 Yufen, Some comments below. Thanks, Marvin > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of yufengx.mo@intel.com > Sent: Monday, January 16, 2017 11:49 AM > To: dts@dpdk.org > Cc: Mo, YufengX > Subject: [dts] [PATCH V1 2/2] userspace_ethtool: update automation testin= g > script. >=20 > From: yufengmx >=20 >=20 > *. add nic's firmware/bus-info information query checking, which is > corresponding with Qiming Yang's patchset 18597-18600(accepted) patchset > 18601(accepted) >=20 > Signed-off-by: yufengmx > --- > tests/TestSuite_userspace_ethtool.py | 119 > +++++++++++++++++++++++++++++++---- > 1 file changed, 106 insertions(+), 13 deletions(-) >=20 > diff --git a/tests/TestSuite_userspace_ethtool.py > b/tests/TestSuite_userspace_ethtool.py > index ced7e96..6024b87 100644 > --- a/tests/TestSuite_userspace_ethtool.py > +++ b/tests/TestSuite_userspace_ethtool.py > @@ -153,25 +153,118 @@ class TestUserspaceEthtool(TestCase, > IxiaPacketGenerator): > else: > return "" >=20 > + def get_driver_info(self, dpdk_driver_msg): > + # get nic driver information using dpdk's ethtool > + info_lines =3D dpdk_driver_msg.strip().splitlines() > + driver_pattern =3D r"Port (\d+) driver: (.*) \(ver: (.*)\)" > + pattern =3D "(.*): (.*)" > + firmwarePat =3D "0x([0-9a-f]+)" > + check_content =3D ['firmware-version', 'driver'] > + dpdk_drv_infos =3D {} > + port =3D None > + cnt =3D 0 > + while cnt < len(info_lines): > + if not info_lines[cnt]: > + pass > + else: > + m =3D re.match(driver_pattern, info_lines[cnt]) > + if m: > + port =3D m.group(1) > + dpdk_drv_infos[port] =3D {} > + dpdk_drv_infos[port]['driver'] =3D m.group(2).split(= '_').pop() > + dpdk_version =3D m.group(3) > + else: > + if port: > + out =3D re.findall(pattern, info_lines[cnt], re.= M)[0] > + if len(out) =3D=3D 2: > + if out[0] =3D=3D 'firmware-version': > + dpdk_drv_infos[port][out[0]] =3D "0x" + = re.findall(firmwarePat, > out[1], re.M)[0] > + else: > + dpdk_drv_infos[port][out[0]] =3D out[1] > + cnt +=3D 1 > + # check driver content > + msg =3D '' > + if 'firmware-version' not in dpdk_driver_msg: > + self.logger.warning('firmware-version query not supported by= current > dpdk version') > + return dpdk_drv_infos, msg Item ['firmware-version', 'driver'] should be existed in dpdk_drv_infos. Ca= se should not consider tested code whether unsupported itself. We will use excel file for tracking this. > + for port_no in dpdk_drv_infos: > + dpdk_drv_info =3D dpdk_drv_infos[port_no] > + for item in check_content: > + if item not in dpdk_drv_info.keys(): > + msg =3D os.linesep.join([msg, "port {0} get {1} fail= ed".format(port_no, > item)]) > + dpdk_drv_infos =3D None > + break > + > + return dpdk_drv_infos, msg > + > + def check_driver_info(self, port_name, dpdk_drv_info): > + # get nic driver information using linux's ethtool > + pattern =3D "(.*): (.*)" > + firmwarePat =3D "0x([0-9a-f]+)" > + infos =3D self.dut.send_expect("ethtool -i %s"%port_name, "# ").= splitlines() Not satisfy with pep8 rule, please check with python-pep8 first. > + sys_nic_info =3D {} > + for info in infos: > + if not info: > + continue > + result =3D re.findall(pattern, info, re.M) > + if not result: > + continue > + out =3D result[0] > + if len(out) =3D=3D 2: > + if out[0] =3D=3D 'firmware-version': > + sys_nic_info[out[0]] =3D "0x" + re.findall(firmwareP= at, out[1], re.M)[0] > + else: > + sys_nic_info[out[0]] =3D out[1] Suggest to split into two functions. One is that strip driver information, = another is compare function. > + # compare two information data > + for item, value in dpdk_drv_info.items(): > + if item not in sys_nic_info.keys(): > + msg =3D "linux ethtool failed to dump driver info" > + status =3D False > + break > + if value !=3D sys_nic_info[item]: > + msg =3D "Userspace ethtool failed to dump driver info" > + status =3D False > + break > + else: > + msg =3D "{0}: dpdk ethtool dump driver info done".format(por= t_name) > + status =3D True > + > + return status, msg > + > def test_dump_driver_info(self): > """ > Test ethtool can dump basic information > """ > self.dut.send_expect(self.cmd, "EthApp>", 60) > - out =3D self.dut.send_expect("drvinfo", "EthApp>") > - driver_pattern =3D r"Port (\d+) driver: rte_(.*)_pmd \(ver: RTE = (.*)\)" > - driver_infos =3D out.split("\r\n") > - self.verify(len(driver_infos) > 1, "Userspace tool failed to dum= p driver infor") > - > - # check dump driver info function > - for driver_info in driver_infos: > - m =3D re.match(driver_pattern, driver_info) > - if m: > - port =3D m.group(1) > - driver =3D m.group(2) > - version =3D m.group(3) > - print utils.GREEN("Detect port %s with %s driver\n" % (p= ort, driver)) > + dpdk_driver_msg =3D self.dut.send_expect("drvinfo", "EthApp>") > + self.dut.send_expect("quit", "# ") > + dpdk_drv_infos, msg =3D self.get_driver_info(dpdk_driver_msg) > + self.verify(dpdk_drv_infos, msg) > + > + portsinfo =3D {} > + for index in range(len(self.ports)): > + portsinfo[index] =3D {} > + portinfo =3D portsinfo[index] > + port =3D self.ports[index] > + netdev =3D self.dut.ports_info[port]['port'] > + intf_name =3D self.dut.ports_info[port]['intf'] > + # strip orignal driver > + portinfo['ori_driver'] =3D netdev.get_nic_driver() > + portinfo['net_dev'] =3D netdev > + # bind to default driver > + netdev.bind_driver() > + # get linux interface > + intf =3D netdev.get_interface_name() > + status, msg =3D self.check_driver_info(intf_name, > dpdk_drv_infos[str(index)]) > + self.logger.info(msg) > + self.verify(status, msg) >=20 > + for index in range(len(self.ports)): > + # bind to original driver > + portinfo =3D portsinfo[index] > + portinfo['net_dev'].bind_driver(portinfo['ori_driver']) > + > + self.dut.send_expect(self.cmd, "EthApp>", 60) > # ethtool doesn't support port disconnect by tools of linux > # only detect physical link disconnect status > if self.nic.startswith("fortville") =3D=3D False: > -- > 1.9.3