From patchwork Thu Jul 28 19:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jiale, SongX" X-Patchwork-Id: 114351 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4171A00C4; Thu, 28 Jul 2022 13:08:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C1A2D40151; Thu, 28 Jul 2022 13:08:44 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 3BF384014F for ; Thu, 28 Jul 2022 13:08:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659006523; x=1690542523; h=from:to:cc:subject:date:message-id; bh=05Gps6qzJB9pUJ2TGgIxbV3RAuJ0xR6Y96O8IH/7W8E=; b=gsxlzy7aKkdyLclh6MUUrGY7kZyXPvJgG87/mHXtC/xbk9jJ7dsu9dHl rb+ttGkQHa49ky4JoJjuuM1ZrerOBqDMd5a9wjCtr9aMMzVZxNUIbTG/C Fi9QKAeMN8Z2w8Zwb0rzw77hKcvBXfEzVR7830CjMS9EEVFYnvMgLoJiK jG07oUgcoW1sybpPrLw96fd7CHJ39wOvteW0qYfGh3l/QOetSlKmU9ovS PXjOqwAQni8WRi1kO6oXq2ToFtiJ/OBKqNAWnYCQ89ocxpGLqANQ53jng Km+TbfyrhsUb90q8+OUfQJmhigBjZ/8K99DSfCJ3OLX7EhVS1vJrNubZy Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10421"; a="268866157" X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="268866157" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2022 04:08:42 -0700 X-IronPort-AV: E=Sophos;i="5.93,196,1654585200"; d="scan'208";a="597811041" Received: from unknown (HELO localhost.localdomain) ([10.239.252.94]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2022 04:08:41 -0700 From: Jiale Song To: dts@dpdk.org Cc: Jiale Song Subject: [dts] [PATCH V1] tests/ptpclient: add the method of checking process status Date: Thu, 28 Jul 2022 19:28:35 +0000 Message-Id: <20220728192835.17234-1-songx.jiale@intel.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 add method to check process status, ensure that the process is killed. Signed-off-by: Jiale Song Acked-by: Lijuan Tu --- tests/TestSuite_ptpclient.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/TestSuite_ptpclient.py b/tests/TestSuite_ptpclient.py index c7abdbc8..55ef98ff 100644 --- a/tests/TestSuite_ptpclient.py +++ b/tests/TestSuite_ptpclient.py @@ -7,7 +7,9 @@ DPDK Test suite. Test support of IEEE1588 Precise Time Protocol. """ +import os import re +import subprocess import time import framework.utils as utils @@ -146,11 +148,24 @@ class TestPtpClient(TestCase): self.verify(tester_out == dut_out, "the DUT time synchronous error") + def check_process_killed(self, name, timeout=5): + for one in range(timeout): + processes = subprocess.Popen( + ["pgrep", "-i", name], stdout=subprocess.PIPE, shell=False + ) + response = processes.communicate()[0] + pids = [int(pid) for pid in response.split()] + if pids: + time.sleep(1) + else: + return True + def tear_down(self): """ Run after each test case. """ self.tester.send_expect("killall ptp4l", "# ") + self.check_process_killed(name="ptp4l") def tear_down_all(self): """