test suite reviews and discussions
 help / color / mirror / Atom feed
From: Michael Qiu <michael.qiu@intel.com>
To: dts@dpdk.org
Cc: yong.liu@intel.com
Subject: [dts] [PATCH 5/6] framework: Fix ifname not found error
Date: Tue, 13 Jan 2015 21:42:19 +0800	[thread overview]
Message-ID: <1421156540-25810-6-git-send-email-michael.qiu@intel.com> (raw)
In-Reply-To: <1421156540-25810-1-git-send-email-michael.qiu@intel.com>

Currently, DTS try to get ifname by the file name below the dir:
	/sys/bus/pci/devices/xxxx:xx:xx.x/net

But if the device driver has been unbind or not loaded successful,
kernel will not create that entry, so the ifname will not exist.

This will cause DTS failure.

Check that entry to avoid this issue.

Signed-off-by: Michael Qiu <michael.qiu@intel.com>
---
 framework/crb.py    | 21 +++++++++++++++------
 framework/dut.py    | 10 ++++++++++
 framework/tester.py |  2 +-
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index aca62c1..ee005c4 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -55,7 +55,8 @@ class Crb(object):
         self.serializer = serializer
         self.ports_info = None
 
-    def send_expect(self, cmds, expected, timeout=TIMEOUT, alt_session=False):
+    def send_expect(self, cmds, expected, timeout=TIMEOUT,
+                    alt_session=False, verify = False):
         """
         Send commands to crb and return string before expected string. If
         there's no expected string found before timeout, TimeoutException will
@@ -63,9 +64,10 @@ class Crb(object):
         """
 
         if alt_session:
-            return self.alt_session.session.send_expect(cmds, expected, timeout)
+            return self.alt_session.session.send_expect(cmds, expected,
+                                                        timeout, verify)
 
-        return self.session.send_expect(cmds, expected, timeout)
+        return self.session.send_expect(cmds, expected, timeout, verify)
 
     def set_test_types(self, func_tests, perf_tests):
         """
@@ -166,7 +168,9 @@ class Crb(object):
 
                 addr_array = pci_bus.split(':')
                 itf = self.get_interface_name(addr_array[0], addr_array[1])
-                self.send_expect("ifconfig %s up" % itf, "# ")
+                # In case the device driver has already been unbind
+                if itf:
+                    self.send_expect("ifconfig %s up" % itf, "# ")
 
         except Exception as e:
             self.logger.error("   !!! Restore ITF: " + e.message)
@@ -226,8 +230,13 @@ class Crb(object):
         """
         Get interface name of specified pci device on linux.
         """
-        command = 'ls /sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
-        return self.send_expect(command, '# ')
+        ifname_path = '/sys/bus/pci/devices/0000:%s:%s/net' % (bus_id, devfun_id)
+        # In case the device driver has already been unbind
+        ret = self.send_expect("ls %s"% ifname_path, '# ', verify=True)
+        if ret == -1:
+            return None
+        else:
+            return ret
 
     def get_interface_name_freebsd(self, bus_id, devfun_id):
         """
diff --git a/framework/dut.py b/framework/dut.py
index d7099ef..96b8bd6 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -424,6 +424,11 @@ class Dut(Crb):
             if pci_id == '8086:10fb':
                 self.send_expect("echo 0000:%s > /sys/bus/pci/drivers/ixgbe/bind" % pci_bus, "# ")
             intf = self.get_interface_name(bus_id, devfun_id)
+            # Skip undrived pci Eth device
+            if not intf:
+                self.logger.info("DUT: [000:%s %s] %s" % (pci_bus, pci_id,
+                                                          skipped))
+                continue
 
             out = self.send_expect("ip link show %s" % intf, "# ")
             if "DOWN" in out:
@@ -478,6 +483,11 @@ class Dut(Crb):
                 continue
 
             intf = self.get_interface_name(pci_bus)
+            # Skip undrived pci devices
+            if not intf:
+                self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id,
+                                                      skipped))
+                continue
 
             macaddr = self.get_mac_addr(intf)
             ipv6 = self.get_ipv6_addr(intf)
diff --git a/framework/tester.py b/framework/tester.py
index 0ebe29a..40f9344 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -213,7 +213,7 @@ class Tester(Crb):
 
             intf = self.get_interface_name(bus_id, devfun_id)
 
-            if "No such file" in intf:
+            if not intf:
                 self.logger.info("Tester: [000:%s %s] %s" % (pci_bus, pci_id,
                                                              "unknow_interface"))
                 continue
-- 
1.9.3

  parent reply	other threads:[~2015-01-13 13:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 13:42 [dts] [PATCH 0/6] DTS enhancement and clean up Michael Qiu
2015-01-13 13:42 ` [dts] [PATCH 1/6] framework/tester: Fix NoneType Error of port_map Michael Qiu
2015-01-14  1:15   ` Liu, Yong
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 2/6] framework/crbs: Info clean up of crbs Michael Qiu
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 3/6] framework: Add login password support Michael Qiu
2015-01-14  1:18   ` Liu, Yong
2015-01-25  1:07   ` Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 4/6] framework/ssh: Add verify ability for command execution Michael Qiu
2015-01-14  1:24   ` Liu, Yong
2015-01-27  5:22   ` [dts] [PATCH v2] " Michael Qiu
2015-02-15  5:05     ` Liu, Yong
2015-01-13 13:42 ` Michael Qiu [this message]
2015-01-14  1:35   ` [dts] [PATCH 5/6] framework: Fix ifname not found error Liu, Yong
2015-01-13 13:42 ` [dts] [PATCH 6/6] framework/crb: rework restore_interfaces() Michael Qiu
2015-01-14  1:35   ` Liu, Yong

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=1421156540-25810-6-git-send-email-michael.qiu@intel.com \
    --to=michael.qiu@intel.com \
    --cc=dts@dpdk.org \
    --cc=yong.liu@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).