From: "Chen, Zhaoyan" <zhaoyan.chen@intel.com>
To: "Mei, JianweiX" <jianweix.mei@intel.com>, "dts@dpdk.org" <dts@dpdk.org>
Cc: "Ma, LihongX" <lihongx.ma@intel.com>,
"Chen, Zhaoyan" <zhaoyan.chen@intel.com>
Subject: Re: [dts] [PATCH V1 3/6] framework/crb.py: only scan configured ports from ports.cfg and overwrite kill all
Date: Tue, 8 Oct 2019 02:22:34 +0000 [thread overview]
Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41DD73B2@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1569605698-316544-3-git-send-email-jianweix.mei@intel.com>
Acked-by: Chen, Zhaoyan <zhaoyan.chen@intel.com>
Regards,
Zhaoyan Chen
> -----Original Message-----
> From: Mei, JianweiX
> Sent: Saturday, September 28, 2019 1:35 AM
> To: dts@dpdk.org
> Cc: Chen, Zhaoyan <zhaoyan.chen@intel.com>; Ma, LihongX <lihongx.ma@intel.com>;
> Mei, JianweiX <jianweix.mei@intel.com>
> Subject: [dts][PATCH V1 3/6] framework/crb.py: only scan configured ports from
> ports.cfg and overwrite kill all
>
> From: meijx <jianweix.mei@intel.com>
>
> only scan configured ports when dts start pretreatment ENV and overwrite kill all.
>
> Signed-off-by: meijx <jianweix.mei@intel.com>
> ---
> framework/crb.py | 106 ++++++++++++++++++++++++++++++++++++++++++++-
> ----------
> 1 file changed, 85 insertions(+), 21 deletions(-)
>
> diff --git a/framework/crb.py b/framework/crb.py index 6e5f56f..91f2946 100644
> --- 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
>
> """
> CRB (customer reference board) basic functions and handlers @@ -278,6 +279,37
> @@ class Crb(object):
> pattern = re.compile(rexp)
> match = pattern.findall(out)
> self.pci_devices_info = []
> +
> + obj_str = 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 = PortConf(PORTCONF)
> + portconf.load_ports_config(self.crb['IP'])
> + configed_pcis = portconf.get_ports_config()
> + if configed_pcis:
> + if 'tester' in str(self):
> + tester_pci_in_cfg = []
> + for item in configed_pcis.values():
> + for pci_info in match:
> + if item['peer'] == pci_info[0]:
> + tester_pci_in_cfg.append(pci_info)
> + match = tester_pci_in_cfg[:]
> + else:
> + dut_pci_in_cfg = []
> + for key in configed_pcis.keys():
> + for pci_info in match:
> + if key == pci_info[0]:
> + dut_pci_in_cfg.append(pci_info)
> + match = dut_pci_in_cfg[:]
> + # keep the original pci sequence
> + match = 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 only 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=self.get_password())
>
> - def kill_all(self, alt_session=True):
> + def get_dpdk_pids(self, prefix_list, alt_session):
> """
> - Kill all dpdk applications on CRB.
> + get all dpdk applications on CRB.
> """
> + file_directorys = ['/var/run/dpdk/%s/config' % file_prefix for
> + file_prefix in prefix_list]
> pids = []
> pid_reg = r'p(\d+)'
> - cmd = 'lsof -Fp /var/run/dpdk/rte/config'
> - out = self.send_expect(cmd, "# ", 20, alt_session)
> - if len(out):
> - lines = out.split('\r\n')
> - for line in lines:
> - m = 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=2)
> -
> - cmd = 'lsof -Fp /var/run/dpdk/rte/hugepage_info'
> - out = 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 hugepage")
> - self.logger.warning("**************************************")
> - self.logger.warning(out)
> - self.logger.warning("**************************************")
> + for config_file in file_directorys:
> + cmd = 'lsof -Fp %s' % config_file
> + out = self.send_expect(cmd, "# ", 20, alt_session)
> + if len(out):
> + lines = out.split('\r\n')
> + for line in lines:
> + m = 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=2)
> +
> + hugepage_info = ['/var/run/dpdk/%s/hugepage_info' % file_prefix for
> file_prefix in prefix_list]
> + for hugepage in hugepage_info:
> + cmd = 'lsof -Fp %s' % hugepage
> + out = 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 hugepage")
> + self.logger.warning("**************************************")
> + self.logger.warning(out)
> +
> + self.logger.warning("**************************************")
> +
> + # remove directory
> + directorys = ['/var/run/dpdk/%s' % file_prefix for file_prefix in prefix_list]
> + for directory in directorys:
> + cmd = 'rm -rf %s' % directory
> + self.send_expect(cmd, "# ", 20, alt_session)
> +
> + def kill_all(self, alt_session=True):
> + """
> + 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 list has value.')
> + self.get_dpdk_pids(self.prefix_list, alt_session)
> + # init prefix_list
> + self.prefix_list = []
> + else:
> + self.logger.info('kill_all: called by dut and has no prefix list.')
> + session = self.create_session('dut_session')
> + out = session.send_command("ls -l /var/run/dpdk |awk '/^d/ {print $NF}'",
> timeout=0.5)
> + # the last directory is expect string, eg: [PEXPECT]#
> + if out != '':
> + dir_list = out.split('\r\n')
> + self.get_dpdk_pids(dir_list[:-1], alt_session)
>
> def close(self):
> """
> --
> 1.8.3.1
next prev parent reply other threads:[~2019-10-08 2:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 17:34 [dts] [PATCH V1 1/6] conf/crbs.cfg:add dut_cores parameter Jianwei Mei
2019-09-27 17:34 ` [dts] [PATCH V1 2/6] framework/config.py: deal with " Jianwei Mei
2019-10-08 2:22 ` Chen, Zhaoyan
2019-09-27 17:34 ` [dts] [PATCH V1 3/6] framework/crb.py: only scan configured ports from ports.cfg and overwrite kill all Jianwei Mei
2019-10-08 2:22 ` Chen, Zhaoyan [this message]
2019-09-27 17:34 ` [dts] [PATCH V1 4/6] framework/dut.py: add function create_eal_parameters Jianwei Mei
2019-10-08 2:22 ` Chen, Zhaoyan
2019-09-27 17:34 ` [dts] [PATCH V1 5/6] framework/pmd_output.py: overwrite function start_testpmd Jianwei Mei
2019-10-08 2:22 ` Chen, Zhaoyan
2019-09-27 17:34 ` [dts] [PATCH V1 6/6] framework/virt_dut.py: add prefix list for virt dut Jianwei Mei
2019-10-08 2:22 ` Chen, Zhaoyan
2019-10-08 2:22 ` [dts] [PATCH V1 1/6] conf/crbs.cfg:add dut_cores parameter Chen, Zhaoyan
2019-10-12 5:30 ` Tu, Lijuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9DEEADBC57E43F4DA73B571777FECECA41DD73B2@SHSMSX104.ccr.corp.intel.com \
--to=zhaoyan.chen@intel.com \
--cc=dts@dpdk.org \
--cc=jianweix.mei@intel.com \
--cc=lihongx.ma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).