From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36176A2F6B for ; Tue, 8 Oct 2019 04:22:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2D6051C00F; Tue, 8 Oct 2019 04:22:45 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 41B5F1BF8C for ; Tue, 8 Oct 2019 04:22:43 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2019 19:22:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,269,1566889200"; d="scan'208";a="192455955" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 07 Oct 2019 19:22:42 -0700 Received: from fmsmsx162.amr.corp.intel.com (10.18.125.71) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 7 Oct 2019 19:22:41 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by fmsmsx162.amr.corp.intel.com (10.18.125.71) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 7 Oct 2019 19:22:41 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.33]) with mapi id 14.03.0439.000; Tue, 8 Oct 2019 10:22:35 +0800 From: "Chen, Zhaoyan" To: "Mei, JianweiX" , "dts@dpdk.org" CC: "Ma, LihongX" , "Chen, Zhaoyan" Thread-Topic: [dts][PATCH V1 3/6] framework/crb.py: only scan configured ports from ports.cfg and overwrite kill all Thread-Index: AQHVdRBl631fSI/nOkiZZdW5+mZ1UadQFFcg Date: Tue, 8 Oct 2019 02:22:34 +0000 Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41DD73B2@SHSMSX104.ccr.corp.intel.com> References: <1569605698-316544-1-git-send-email-jianweix.mei@intel.com> <1569605698-316544-3-git-send-email-jianweix.mei@intel.com> In-Reply-To: <1569605698-316544-3-git-send-email-jianweix.mei@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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 3/6] framework/crb.py: only scan configured ports from ports.cfg and overwrite kill all 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Acked-by: Chen, Zhaoyan Regards, Zhaoyan Chen > -----Original Message----- > From: Mei, JianweiX > Sent: Saturday, September 28, 2019 1:35 AM > To: dts@dpdk.org > Cc: Chen, Zhaoyan ; Ma, LihongX ; > Mei, JianweiX > Subject: [dts][PATCH V1 3/6] framework/crb.py: only scan configured ports= from > ports.cfg and overwrite kill all >=20 > From: meijx >=20 > only scan configured ports when dts start pretreatment ENV and overwrite = kill all. >=20 > Signed-off-by: meijx > --- > framework/crb.py | 106 ++++++++++++++++++++++++++++++++++++++++++++- > ---------- > 1 file changed, 85 insertions(+), 21 deletions(-) >=20 > diff --git a/framework/crb.py b/framework/crb.py index 6e5f56f..91f2946 1= 00644 > --- a/framework/crb.py > +++ b/framework/crb.py > @@ -35,6 +35,7 @@ import os > from settings import TIMEOUT, IXIA > from ssh_connection import SSHConnection from logger import getLogger > +from config import PortConf, PORTCONF >=20 > """ > CRB (customer reference board) basic functions and handlers @@ -278,6 +2= 79,37 > @@ class Crb(object): > pattern =3D re.compile(rexp) > match =3D pattern.findall(out) > self.pci_devices_info =3D [] > + > + obj_str =3D str(self) > + if 'VirtDut' in obj_str: > + # there is no port.cfg in VM, so need to scan all pci in VM. > + pass > + else: > + # only scan configured pcis > + portconf =3D PortConf(PORTCONF) > + portconf.load_ports_config(self.crb['IP']) > + configed_pcis =3D portconf.get_ports_config() > + if configed_pcis: > + if 'tester' in str(self): > + tester_pci_in_cfg =3D [] > + for item in configed_pcis.values(): > + for pci_info in match: > + if item['peer'] =3D=3D pci_info[0]: > + tester_pci_in_cfg.append(pci_info) > + match =3D tester_pci_in_cfg[:] > + else: > + dut_pci_in_cfg =3D [] > + for key in configed_pcis.keys(): > + for pci_info in match: > + if key =3D=3D pci_info[0]: > + dut_pci_in_cfg.append(pci_info) > + match =3D dut_pci_in_cfg[:] > + # keep the original pci sequence > + match =3D sorted(match) > + else: > + # INVALID CONFIG FOR NO PCI ADDRESS!!! eg: port.cfg for = freeBSD > + pass > + > for i in range(len(match)): > #check if device is cavium and check its linkspeed, append o= nly if it is 10G > if "177d:" in match[i][1]: > @@ -434,31 +466,63 @@ class Crb(object): > f.write(contents) > self.session.copy_file_to(fileName, password=3Dself.get_password= ()) >=20 > - def kill_all(self, alt_session=3DTrue): > + def get_dpdk_pids(self, prefix_list, alt_session): > """ > - Kill all dpdk applications on CRB. > + get all dpdk applications on CRB. > """ > + file_directorys =3D ['/var/run/dpdk/%s/config' % file_prefix for > + file_prefix in prefix_list] > pids =3D [] > pid_reg =3D r'p(\d+)' > - cmd =3D 'lsof -Fp /var/run/dpdk/rte/config' > - out =3D self.send_expect(cmd, "# ", 20, alt_session) > - if len(out): > - lines =3D out.split('\r\n') > - for line in lines: > - m =3D re.match(pid_reg, line) > - if m: > - pids.append(m.group(1)) > - for pid in pids: > - self.send_expect('kill -9 %s' % pid, '# ', 20, alt_session) > - self.get_session_output(timeout=3D2) > - > - cmd =3D 'lsof -Fp /var/run/dpdk/rte/hugepage_info' > - out =3D self.send_expect(cmd, "# ", 20, alt_session) > - if len(out) and "No such file or directory" not in out: > - self.logger.warning("There are some dpdk process not free hu= gepage") > - self.logger.warning("**************************************"= ) > - self.logger.warning(out) > - self.logger.warning("**************************************"= ) > + for config_file in file_directorys: > + cmd =3D 'lsof -Fp %s' % config_file > + out =3D self.send_expect(cmd, "# ", 20, alt_session) > + if len(out): > + lines =3D out.split('\r\n') > + for line in lines: > + m =3D re.match(pid_reg, line) > + if m: > + pids.append(m.group(1)) > + for pid in pids: > + self.send_expect('kill -9 %s' % pid, '# ', 20, alt_sessi= on) > + self.get_session_output(timeout=3D2) > + > + hugepage_info =3D ['/var/run/dpdk/%s/hugepage_info' % file_prefi= x for > file_prefix in prefix_list] > + for hugepage in hugepage_info: > + cmd =3D 'lsof -Fp %s' % hugepage > + out =3D self.send_expect(cmd, "# ", 20, alt_session) > + if len(out) and "No such file or directory" not in out: > + self.logger.warning("There are some dpdk process not fre= e hugepage") > + self.logger.warning("***********************************= ***") > + self.logger.warning(out) > + > + self.logger.warning("**************************************") > + > + # remove directory > + directorys =3D ['/var/run/dpdk/%s' % file_prefix for file_prefix= in prefix_list] > + for directory in directorys: > + cmd =3D 'rm -rf %s' % directory > + self.send_expect(cmd, "# ", 20, alt_session) > + > + def kill_all(self, alt_session=3DTrue): > + """ > + Kill all dpdk applications on CRB. > + """ > + if 'tester' in str(self): > + self.logger.info('kill_all: called by tester') > + pass > + else: > + if self.prefix_list: > + self.logger.info('kill_all: called by dut and prefix lis= t has value.') > + self.get_dpdk_pids(self.prefix_list, alt_session) > + # init prefix_list > + self.prefix_list =3D [] > + else: > + self.logger.info('kill_all: called by dut and has no pre= fix list.') > + session =3D self.create_session('dut_session') > + out =3D session.send_command("ls -l /var/run/dpdk |awk '= /^d/ {print $NF}'", > timeout=3D0.5) > + # the last directory is expect string, eg: [PEXPECT]# > + if out !=3D '': > + dir_list =3D out.split('\r\n') > + self.get_dpdk_pids(dir_list[:-1], alt_session) >=20 > def close(self): > """ > -- > 1.8.3.1