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 05EC58D3B for ; Thu, 13 Aug 2015 05:16:36 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 12 Aug 2015 20:16:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,666,1432623600"; d="scan'208";a="782589682" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 12 Aug 2015 20:16:35 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t7D3GXXO024697; Thu, 13 Aug 2015 11:16:33 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t7D3GVBJ018617; Thu, 13 Aug 2015 11:16:33 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t7D3GVIb018613; Thu, 13 Aug 2015 11:16:31 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 13 Aug 2015 11:16:30 +0800 Message-Id: <1439435790-18581-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH V2] Optimize kill_all function 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: Thu, 13 Aug 2015 03:16:37 -0000 From: Marvin Liu 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 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): """ -- 1.9.3