summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Liu <yong.liu@intel.com>2015-08-13 11:16:30 +0800
committerMarvin Liu <yong.liu@intel.com>2015-08-13 15:51:42 +0800
commit79d66898a96a3cdfb7d46ed7c89c63d578c5dba5 (patch)
tree5fc1c4c36bc9ecd19d43fa050af061db1b3a43fa
parent7fcd8f2ff2527192c88f570f66e4378f6efb8dcd (diff)
downloaddts-79d66898a96a3cdfb7d46ed7c89c63d578c5dba5.zip
dts-79d66898a96a3cdfb7d46ed7c89c63d578c5dba5.tar.gz
dts-79d66898a96a3cdfb7d46ed7c89c63d578c5dba5.tar.xz
Optimize kill_all function
Before call system kill, strip all dpdk process pids. After kill all, check there's no dpdk process alive and clean host session buffer. Signed-off-by: Marvin Liu <yong.liu@intel.com>
-rw-r--r--framework/crb.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/framework/crb.py b/framework/crb.py
index dd18207..c10f791 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -331,25 +331,27 @@ class Crb(object):
"""
Kill all dpdk applications on CRB.
"""
- cmd = "for i in `lsof /var/run/.rte_config /var/run/dpdk_config \
- | awk '/config/ {print $2}'` ; do kill -9 $i; done"
- self.alt_session.session.send_expect(cmd, "# ", 10)
- proce_cmd = "lsof /var/run/.rte_config /var/run/dpdk_config | awk '{print $2}'"
- hugepage_cmd = "lsof /var/run/.rte_hugepage_info | awk {print $2}"
- out = self.alt_session.session.send_expect(proce_cmd, "# ",10)
- if "PID" in out:
- self.logger.warning("There are some dpdk process not killed")
- self.logger.warning("**************************************")
- self.logger.warning(out)
- self.logger.warning("**************************************")
-
- out = self.alt_session.session.send_expect(hugepage_cmd, "# ",10)
- if "PID" in out:
+ pids = []
+ pid_reg = r'p(\d+)'
+ cmd = 'lsof -Fp /var/run/.rte_config'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ 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.alt_session.session.send_expect('kill -9 %s' % pid, '# ')
+ self.get_session_output(timeout=2)
+
+ cmd = 'lsof -Fp /var/run/.rte_hugepage_info'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ if len(out):
self.logger.warning("There are some dpdk process not free hugepage")
self.logger.warning("**************************************")
self.logger.warning(out)
self.logger.warning("**************************************")
- time.sleep(.7)
def close(self):
"""