[V1] framework/crb:add check link status public method

Message ID 20220105195613.15561-1-zhiminx.huang@intel.com (mailing list archive)
State Superseded
Headers
Series [V1] framework/crb:add check link status public method |

Checks

Context Check Description
ci/Intel-dts-suite-test fail Testing issues

Commit Message

Huang, ZhiminX Jan. 5, 2022, 7:56 p.m. UTC
  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 <zhiminx.huang@intel.com>
---
 framework/crb.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Tu, Lijuan Jan. 12, 2022, 5:56 a.m. UTC | #1
> -----Original Message-----
> From: Zhimin Huang <zhiminx.huang@intel.com>
> Sent: 2022年1月6日 3:56
> To: dts@dpdk.org
> Cc: Huang, ZhiminX <zhiminx.huang@intel.com>
> Subject: [dts] [PATCH V1] framework/crb:add check link status public method
> 
> 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 <zhiminx.huang@intel.com>
> ---
>  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):

It only accept 1 interface, so the function name should be " check_interface_link "
  

Patch

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