test suite reviews and discussions
 help / color / mirror / Atom feed
From: yufengx.mo@intel.com
To: dts@dpdk.org
Cc: yufengmx <yufengx.mo@intel.com>
Subject: [dts] [PATCH V1 2/2] userspace_ethtool: update automation testing script.
Date: Mon, 16 Jan 2017 11:48:32 +0800	[thread overview]
Message-ID: <1484538512-45811-3-git-send-email-yufengx.mo@intel.com> (raw)
In-Reply-To: <1484538512-45811-1-git-send-email-yufengx.mo@intel.com>

From: yufengmx <yufengx.mo@intel.com>


*. add nic's firmware/bus-info information query checking, which is corresponding with
Qiming Yang's
patchset 18597-18600(accepted)
patchset 18601(accepted)

Signed-off-by: yufengmx <yufengx.mo@intel.com>
---
 tests/TestSuite_userspace_ethtool.py | 119 +++++++++++++++++++++++++++++++----
 1 file changed, 106 insertions(+), 13 deletions(-)

diff --git a/tests/TestSuite_userspace_ethtool.py b/tests/TestSuite_userspace_ethtool.py
index ced7e96..6024b87 100644
--- a/tests/TestSuite_userspace_ethtool.py
+++ b/tests/TestSuite_userspace_ethtool.py
@@ -153,25 +153,118 @@ class TestUserspaceEthtool(TestCase, IxiaPacketGenerator):
         else:
             return ""
 
+    def get_driver_info(self, dpdk_driver_msg):
+        # get nic driver information using dpdk's ethtool
+        info_lines = dpdk_driver_msg.strip().splitlines()
+        driver_pattern = r"Port (\d+) driver: (.*) \(ver: (.*)\)"
+        pattern = "(.*): (.*)"
+        firmwarePat = "0x([0-9a-f]+)"
+        check_content = ['firmware-version', 'driver']
+        dpdk_drv_infos = {}
+        port = None
+        cnt = 0
+        while cnt < len(info_lines):
+            if not info_lines[cnt]:
+                pass
+            else:
+                m = re.match(driver_pattern, info_lines[cnt])
+                if m:
+                    port = m.group(1)
+                    dpdk_drv_infos[port] = {}
+                    dpdk_drv_infos[port]['driver'] = m.group(2).split('_').pop()
+                    dpdk_version = m.group(3)
+                else:
+                    if port:
+                        out = re.findall(pattern, info_lines[cnt], re.M)[0]
+                        if len(out) == 2:
+                            if out[0] == 'firmware-version':
+                                dpdk_drv_infos[port][out[0]] = "0x" + re.findall(firmwarePat, out[1], re.M)[0]
+                            else:
+                                dpdk_drv_infos[port][out[0]] = out[1]
+            cnt += 1
+        # check driver content
+        msg = ''
+        if 'firmware-version' not in dpdk_driver_msg:
+            self.logger.warning('firmware-version query not supported by current dpdk version')
+            return dpdk_drv_infos, msg
+        for port_no in dpdk_drv_infos:
+            dpdk_drv_info = dpdk_drv_infos[port_no]
+            for item in check_content:
+                if item not in dpdk_drv_info.keys():
+                    msg = os.linesep.join([msg, "port {0} get {1} failed".format(port_no, item)])
+                    dpdk_drv_infos = None
+                    break
+
+        return dpdk_drv_infos, msg
+
+    def check_driver_info(self, port_name, dpdk_drv_info):
+        # get nic driver information using linux's ethtool
+        pattern = "(.*): (.*)"
+        firmwarePat = "0x([0-9a-f]+)"
+        infos = self.dut.send_expect("ethtool -i %s"%port_name, "# ").splitlines()
+        sys_nic_info = {}
+        for info in infos:
+            if not info:
+                continue
+            result = re.findall(pattern, info, re.M)
+            if not result:
+                continue
+            out = result[0]
+            if len(out) == 2:
+                if out[0] == 'firmware-version':
+                    sys_nic_info[out[0]] = "0x" + re.findall(firmwarePat, out[1], re.M)[0]
+                else:
+                    sys_nic_info[out[0]] = out[1]
+        # compare two information data 
+        for item, value in dpdk_drv_info.items():
+            if item not in sys_nic_info.keys():
+                msg = "linux ethtool failed to dump driver info"
+                status = False
+                break
+            if value != sys_nic_info[item]:
+                msg = "Userspace ethtool failed to dump driver info"
+                status = False
+                break
+        else:
+            msg = "{0}: dpdk ethtool dump driver info done".format(port_name)
+            status = True
+
+        return status, msg
+
     def test_dump_driver_info(self):
         """
         Test ethtool can dump basic information
         """
         self.dut.send_expect(self.cmd, "EthApp>", 60)
-        out = self.dut.send_expect("drvinfo", "EthApp>")
-        driver_pattern = r"Port (\d+) driver: rte_(.*)_pmd \(ver: RTE (.*)\)"
-        driver_infos = out.split("\r\n")
-        self.verify(len(driver_infos) > 1, "Userspace tool failed to dump driver infor")
-
-        # check dump driver info function
-        for driver_info in driver_infos:
-            m = re.match(driver_pattern, driver_info)
-            if m:
-                port = m.group(1)
-                driver = m.group(2)
-                version = m.group(3)
-                print utils.GREEN("Detect port %s with %s driver\n" % (port, driver))
+        dpdk_driver_msg = self.dut.send_expect("drvinfo", "EthApp>")
+        self.dut.send_expect("quit", "# ")
+        dpdk_drv_infos, msg = self.get_driver_info(dpdk_driver_msg)
+        self.verify(dpdk_drv_infos, msg)
+        
+        portsinfo = {}
+        for index in range(len(self.ports)):
+            portsinfo[index] = {}
+            portinfo = portsinfo[index]
+            port = self.ports[index]
+            netdev = self.dut.ports_info[port]['port']
+            intf_name = self.dut.ports_info[port]['intf']
+            # strip orignal driver
+            portinfo['ori_driver'] = netdev.get_nic_driver()
+            portinfo['net_dev'] = netdev
+            # bind to default driver
+            netdev.bind_driver()
+            # get linux interface
+            intf = netdev.get_interface_name()
+            status, msg = self.check_driver_info(intf_name, dpdk_drv_infos[str(index)])
+            self.logger.info(msg)
+            self.verify(status, msg)
 
+        for index in range(len(self.ports)):
+            # bind to original driver
+            portinfo = portsinfo[index]
+            portinfo['net_dev'].bind_driver(portinfo['ori_driver'])
+
+        self.dut.send_expect(self.cmd, "EthApp>", 60)
         # ethtool doesn't support port disconnect by tools of linux 
         # only detect physical link disconnect status
         if self.nic.startswith("fortville") == False:  
-- 
1.9.3

  parent reply	other threads:[~2017-01-16  3:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16  3:48 [dts] [PATCH V1 0/2] userspace_ethtool: update automation testing script/test plan *. add nic's firmware/bus-info information query checking, which is corresponding with Qiming Yang's patchset 18597-18600 patchset 18601 yufengx.mo
2017-01-16  3:48 ` [dts] [PATCH V1 1/2] userspace_ethtool: update test plan yufengx.mo
2017-01-16  3:48 ` yufengx.mo [this message]
2017-01-16  5:56   ` [dts] [PATCH V1 2/2] userspace_ethtool: update automation testing script Liu, Yong
  -- strict thread matches above, loose matches on Subject: below --
2017-01-06  7:47 [dts] [PATCH V1 0/2] userspace_ethtool: update automation testing script/test plan *. add nic's firmware/bus-info information query checking yufengx.mo
2017-01-06  7:47 ` [dts] [PATCH V1 2/2] userspace_ethtool: update automation testing script yufengx.mo

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=1484538512-45811-3-git-send-email-yufengx.mo@intel.com \
    --to=yufengx.mo@intel.com \
    --cc=dts@dpdk.org \
    /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).