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 29A63CE7 for ; Thu, 13 Aug 2015 05:06:04 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 12 Aug 2015 20:06:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,666,1432623600"; d="scan'208";a="767732291" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 12 Aug 2015 20:06:02 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t7D361wq013089; Thu, 13 Aug 2015 11:06:01 +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 t7D35w2v018384; Thu, 13 Aug 2015 11:06:00 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t7D35wk8018380; Thu, 13 Aug 2015 11:05:58 +0800 From: Yong Liu To: dts@dpdk.org Date: Thu, 13 Aug 2015 11:05:57 +0800 Message-Id: <1439435157-18348-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] 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:06:05 -0000 From: Marvin Liu Before call system kill, strip all dpdk process pids. After kill all, check there's no dpdk process alive. Signed-off-by: Marvin Liu diff --git a/framework/crb.py b/framework/crb.py index dd18207..51dd723 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, '# ') + time.sleep(.7) + + 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