test suite reviews and discussions
 help / color / mirror / Atom feed
* [DTS][V2] framework/crb: Add functions of check and wait specified link status
@ 2022-01-25  7:08 DongJunX
  2022-01-26  3:18 ` Jiang, YuX
  0 siblings, 1 reply; 3+ messages in thread
From: DongJunX @ 2022-01-25  7:08 UTC (permalink / raw)
  To: dts; +Cc: lijuan.tu, qingx.sun, junx.dong

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

diff --git a/framework/crb.py b/framework/crb.py
index bd4f565d..7875510f 100755
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -907,3 +907,33 @@ 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 is_interface_down(self, intf, timeout=15):
+        """
+        check and wait port link status down until timeout
+        """
+        for i in range(timeout):
+            link_status = self.get_interface_link_status(intf)
+            if link_status == 'Down':
+                return True
+            time.sleep(1)
+        self.logger.error(f"check and wait {intf} link down 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [DTS][V2] framework/crb: Add functions of check and wait specified link status
  2022-01-25  7:08 [DTS][V2] framework/crb: Add functions of check and wait specified link status DongJunX
@ 2022-01-26  3:18 ` Jiang, YuX
  2022-01-29  3:12   ` Tu, Lijuan
  0 siblings, 1 reply; 3+ messages in thread
From: Jiang, YuX @ 2022-01-26  3:18 UTC (permalink / raw)
  To: Dong, JunX, dts; +Cc: Tu, Lijuan, Sun, QingX, Dong, JunX, Jiang, YuX

> -----Original Message-----
> From: DongJunX <junx.dong@intel.com>
> Sent: Tuesday, January 25, 2022 3:08 PM
> To: dts@dpdk.org
> Cc: Tu, Lijuan <lijuan.tu@intel.com>; Sun, QingX <qingx.sun@intel.com>;
> Dong, JunX <junx.dong@intel.com>
> Subject: [DTS][V2] framework/crb: Add functions of check and wait specified
> link status
> 
> Signed-off-by: DongJunX <junx.dong@intel.com>
> ---
Tested-by: Yu Jiang <YuX.Jiang@intel.com>

>  framework/crb.py | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/framework/crb.py b/framework/crb.py index bd4f565d..7875510f
> 100755
> --- a/framework/crb.py
> +++ b/framework/crb.py
> @@ -907,3 +907,33 @@ 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 is_interface_down(self, intf, timeout=15):
> +        """
> +        check and wait port link status down until timeout
> +        """
> +        for i in range(timeout):
> +            link_status = self.get_interface_link_status(intf)
> +            if link_status == 'Down':
> +                return True
> +            time.sleep(1)
> +        self.logger.error(f"check and wait {intf} link down 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [DTS][V2] framework/crb: Add functions of check and wait specified link status
  2022-01-26  3:18 ` Jiang, YuX
@ 2022-01-29  3:12   ` Tu, Lijuan
  0 siblings, 0 replies; 3+ messages in thread
From: Tu, Lijuan @ 2022-01-29  3:12 UTC (permalink / raw)
  To: Jiang, YuX, Dong, JunX, dts; +Cc: Sun, QingX, Dong, JunX

> > Subject: [DTS][V2] framework/crb: Add functions of check and wait
> > specified link status
> >
> > Signed-off-by: DongJunX <junx.dong@intel.com>
> > ---
> Tested-by: Yu Jiang <YuX.Jiang@intel.com>

Applied

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-29  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25  7:08 [DTS][V2] framework/crb: Add functions of check and wait specified link status DongJunX
2022-01-26  3:18 ` Jiang, YuX
2022-01-29  3:12   ` Tu, Lijuan

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).