From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id A37F05A93 for ; Tue, 13 Jan 2015 14:42:48 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2015 05:42:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,750,1413270000"; d="scan'208";a="650409228" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 13 Jan 2015 05:42:43 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t0DDgfN5012871; Tue, 13 Jan 2015 21:42:41 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t0DDgd9J025879; Tue, 13 Jan 2015 21:42:41 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t0DDgdH6025875; Tue, 13 Jan 2015 21:42:39 +0800 From: Michael Qiu To: dts@dpdk.org Date: Tue, 13 Jan 2015 21:42:19 +0800 Message-Id: <1421156540-25810-6-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1421156540-25810-1-git-send-email-michael.qiu@intel.com> References: <1421156540-25810-1-git-send-email-michael.qiu@intel.com> Cc: yong.liu@intel.com Subject: [dts] [PATCH 5/6] framework: Fix ifname not found error X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jan 2015 13:42:49 -0000 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 --- 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