[dts] [PATCH 1/3] framework dut: add port stop when execution exit

Yong Liu yong.liu at intel.com
Wed Jan 20 02:47:41 CET 2016


Some nic like RRC required additional setup like testpoint start-up. So
when execution done, need call additional stop function.

Signed-off-by: Marvin Liu <yong.liu at intel.com>

diff --git a/framework/dts.py b/framework/dts.py
index 2dd511b..1e60a01 100644
--- a/framework/dts.py
+++ b/framework/dts.py
@@ -341,6 +341,7 @@ def dts_run_target(crbInst, targets, test_suites, nic, scenario):
         scene.destroy_scene()
         scene = None
 
+    dut.stop_ports()
     dut.restore_interfaces()
     tester.restore_interfaces()
 
diff --git a/framework/dut.py b/framework/dut.py
index 178c35f..afb5204 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -225,6 +225,23 @@ class Dut(Crb):
         self.send_expect("kldunload contigmem.ko", "#")
         self.send_expect("kldload if_ixgbe.ko", "#", 20)
 
+    def stop_ports(self):
+        """
+        After all execution done, some special nic like fm10k should be stop
+        """
+        for port in self.ports_info:
+            pci_bus = port['pci']
+            pci_id = port['type']
+            # get device driver
+            driver = settings.get_nic_driver(pci_id)
+            if driver is not None:
+                # unbind device driver
+                addr_array = pci_bus.split(':')
+                bus_id = addr_array[0]
+                devfun_id = addr_array[1]
+                port = GetNicObj(self, bus_id, devfun_id)
+                port.stop()
+
     def restore_interfaces_linux(self):
         """
         Restore Linux interfaces.
@@ -824,7 +841,7 @@ class Dut(Crb):
             dutpci = self.ports_info[dutPort]['pci']
             if peer is not None:
                 for remotePort in range(len(self.tester.ports_info)):
-                    if self.tester.ports_info[remotePort]['pci'] == peer:
+                    if self.tester.ports_info[remotePort]['pci'].lower() == peer.lower():
                         hits[remotePort] = True
                         self.ports_map[dutPort] = remotePort
                         break
diff --git a/nics/net_device.py b/nics/net_device.py
index 2b0517b..c3b3755 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -64,6 +64,9 @@ class NetDevice(object):
         self.get_interface_name()
         self.socket = self.get_nic_socket()
 
+    def stop(self):
+        pass
+
     def close(self):
         pass
 
-- 
2.4.3



More information about the dts mailing list