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 28B99152A for ; Mon, 16 Jan 2017 09:21:21 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 16 Jan 2017 00:21:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,238,1477983600"; d="scan'208";a="31051853" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2017 00:21:00 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 16 Jan 2017 00:20:59 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 16 Jan 2017 00:20:59 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0248.002; Mon, 16 Jan 2017 16:20:57 +0800 From: "Mo, YufengX" To: "Liu, Yong" CC: "dts@dpdk.org" Thread-Topic: [dts][PATCH V2 2/2] userspace_ethtool: update automation testing script. Thread-Index: AQHSb9Bw3UHXq0kOek+zI4UdMY9FJKE6wyug Importance: low X-Priority: 5 Date: Mon, 16 Jan 2017 08:20:57 +0000 Message-ID: References: <1484554397-20716-1-git-send-email-yufengx.mo@intel.com> <1484554397-20716-3-git-send-email-yufengx.mo@intel.com> In-Reply-To: <1484554397-20716-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 V2 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 08:21:22 -0000 ignore this mail. Use to test mail account > -----Original Message----- > From: Mo, YufengX > Sent: January 16, 2017 4:13 PM > To: dts@dpdk.org > Cc: Mo, YufengX > Subject: [dts][PATCH V2 2/2] userspace_ethtool: update automation testing= script. >=20 > From: yufengmx >=20 >=20 > *. add nic's firmware/bus-info information query checking, which is corre= sponding with > Qiming Yang's > patchset 18597-18600(accepted) > patchset 18601(accepted) >=20 > Signed-off-by: yufengmx > --- > tests/TestSuite_userspace_ethtool.py | 141 +++++++++++++++++++++++++++--= ------ > 1 file changed, 111 insertions(+), 30 deletions(-) >=20 > diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_users= pace_ethtool.py > index ced7e96..937a9e5 100644 > --- a/tests/TestSuite_userspace_ethtool.py > +++ b/tests/TestSuite_userspace_ethtool.py > @@ -128,22 +128,6 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGener= ator): > else: > return 1518 >=20 > - def resize_linux_eeprom_file(self, dpdk_eeprom_file, linux_eeprom_fi= le): > - basePath =3D os.sep + "root" + self.dut.base_dir[1:] + os.sep > - with open( basePath + os.sep + dpdk_eeprom_file, 'rb') as fpDpdk= : > - dpdk_bytes =3D fpDpdk.read() > - dpdk_length =3D len(dpdk_bytes) > - > - with open( basePath + linux_eeprom_file, 'rb') as fplinux: > - linux_bytes =3D fplinux.read() > - linux_length =3D len(linux_bytes) > - > - self.verify(dpdk_length <=3D linux_length, > - "linux ethtool haven't dump out enough data as dpdk = ethtool") > - > - with open( basePath + linux_eeprom_file, 'wb') as fplinux: > - fplinux.write(linux_bytes[:dpdk_length]) > - > def strip_md5(self, filename): > md5_info =3D self.dut.send_expect("md5sum %s" % filename, "# ") > md5_pattern =3D r"(\w+) (\w+)" > @@ -153,25 +137,123 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGen= erator): > else: > return "" >=20 > + def dpdk_get_nic_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'] > + nic_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) > + nic_infos[port] =3D {} > + nic_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': > + nic_infos[port][out[0]] =3D "0x" + re.fi= ndall(firmwarePat, out[1], re.M)[0] > + else: > + nic_infos[port][out[0]] =3D out[1] > + cnt +=3D 1 > + # check driver content > + status =3D [] > + for port_no in nic_infos: > + nic_info =3D nic_infos[port_no] > + for item in check_content: > + if item not in nic_info.keys(): > + status.append("port {0} get {1} failed".format(port_= no, item)) > + break > + # if there is error in status, clear nic_infos > + if status: > + msg =3D os.linesep.join(status) > + nic_infos =3D None > + else: > + msg =3D '' > + > + return nic_infos, msg > + > + def linux_get_nic_info(self, port_name): > + # 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() > + 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] > + return sys_nic_info > + > + def check_driver_info(self, port_name, sys_nic_info, dpdk_drv_info): > + # compare dpdk query nic information with linux query nic inform= ation > + 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 nic information done".format= (port_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_nic_infos, msg =3D self.dpdk_get_nic_info(dpdk_driver_msg) > + self.verify(dpdk_nic_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'] > + # 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_name =3D netdev.get_interface_name() > + sys_nic_info =3D self.linux_get_nic_info(intf_name) > + status, msg =3D self.check_driver_info(intf_name, sys_nic_in= fo, dpdk_nic_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: > @@ -294,7 +376,6 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenera= tor): >=20 > for index in range(len(self.ports)): > md5 =3D self.strip_md5(portsinfo[index]['eeprom_file']) > - self.resize_linux_eeprom_file( portsinfo[index]['eeprom_file= '], portsinfo[index]['ethtool_eeprom']) > md5_ref =3D self.strip_md5(portsinfo[index]['ethtool_eeprom'= ]) > print utils.GREEN("Reference eeprom md5 %s" % md5) > print utils.GREEN("Reference eeprom md5_ref %s" % md5_ref) > -- > 1.9.3