From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D379A00C5; Wed, 5 Jan 2022 12:26:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0720A40685; Wed, 5 Jan 2022 12:26:34 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A6C244014F for ; Wed, 5 Jan 2022 12:26:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641381992; x=1672917992; h=from:to:cc:subject:date:message-id; bh=p/mf8L2vvp8qeeQHFBq0YccqtFS4g1MYdFzXpmXhpSU=; b=fHFtboUBtvHtGNvQIriQ8ZHFqW3lGhCR/8w0xGCNsYiLfZt9KDo2++w2 XEQG4UgZnBMxtci9uadvaRozhhTfIqt2Ui6fUBtKRBPiQYEUHUcMVD9Fo yIUZsPeJjcVmaUTrzr3dsZhkuiUdeWr5U9lCR6xWfS+qWCZvRtvT0xZ9D tXK4hliJJ1FEv7w7nDlpJrj/6fkEGJn0/8oW/6XamgCrUoNiRQMRbN8fE 06a71r1AmywfknXxz3x5CAAn3pBq78PMrvOlhPm96G1M8UDU6E0j4agG3 hsozB9VgW1sbxkM1bPEwZpgzFn8O5F048vxiuDbFKPlNomJXxifS7CKR3 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10217"; a="229738879" X-IronPort-AV: E=Sophos;i="5.88,263,1635231600"; d="scan'208";a="229738879" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2022 03:26:31 -0800 X-IronPort-AV: E=Sophos;i="5.88,263,1635231600"; d="scan'208";a="512915647" Received: from unknown (HELO localhost.localdomain) ([10.239.251.97]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2022 03:26:30 -0800 From: Zhimin Huang To: dts@dpdk.org Cc: Zhimin Huang Subject: [dts] [PATCH V1] framework/crb:add check link status public method Date: Thu, 6 Jan 2022 03:56:13 +0800 Message-Id: <20220105195613.15561-1-zhiminx.huang@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 when we meet testpmd or app start but link is not up. we can loop up the interface to ensure link. Signed-off-by: Zhimin Huang --- framework/crb.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/framework/crb.py b/framework/crb.py index bd4f565d..22af9ad3 100755 --- a/framework/crb.py +++ b/framework/crb.py @@ -907,3 +907,17 @@ class Crb(object): else: self.logger.info("NIC %s may be not find %s" % (intf, flag)) return False + + def check_interfaces_link(self, intf, timeout=15): + """ + loop to check port link status + """ + for i in range(timeout): + out = self.send_expect("ethtool {} | tail -1 ".format(intf), "# ") + if 'Link detected: yes' not in out: + self.send_expect("ifconfig {} up".format(intf), "# ") + time.sleep(1) + else: + return True + self.logger.error("{} link is down".format(intf)) + return False -- 2.17.1