test suite reviews and discussions
 help / color / mirror / Atom feed
From: DongJunX <junx.dong@intel.com>
To: dts@dpdk.org
Cc: lijuan.tu@intel.com, qingx.sun@intel.com, junx.dong@intel.com
Subject: [V1] framework/crb: Add functions of check and wait link status up
Date: Mon, 17 Jan 2022 18:08:23 +0800	[thread overview]
Message-ID: <20220117100823.4747-1-junx.dong@intel.com> (raw)

Signed-off-by: DongJunX <junx.dong@intel.com>
---
 framework/crb.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/framework/crb.py b/framework/crb.py
index bd4f565d..c97b01ce 100755
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -907,3 +907,21 @@ class Crb(object):
         else:
             self.logger.info("NIC %s may be not find %s" % (intf, flag))
             return False
+
+    def is_interface_up(self, intf, timeout=15):
+        """
+        check and wait port link status up until timeout
+        """
+        for i in range(timeout):
+            link_status = self.get_interface_link_status(intf)
+            if link_status == 'Up':
+                return True
+            time.sleep(1)
+        self.logger.error(f"check and wait {intf} link up timeout")
+        return False
+
+    def get_interface_link_status(self, intf):
+        out = self.send_expect(f"ethtool {intf}", "#")
+        link_status_matcher = r'Link detected: (\w+)'
+        link_status = re.search(link_status_matcher, out).groups()[0]
+        return 'Up' if link_status == 'yes' else 'Down'
-- 
2.33.1.windows.1


                 reply	other threads:[~2022-01-17 10:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117100823.4747-1-junx.dong@intel.com \
    --to=junx.dong@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=qingx.sun@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).