test suite reviews and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Cc: Marvin Liu <yong.liu@intel.com>
Subject: [dts] [PATCH 3/9] framework dut: remove dependency on dts module
Date: Thu,  4 Aug 2016 13:38:16 +0800	[thread overview]
Message-ID: <1470289102-12677-4-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1470289102-12677-1-git-send-email-yong.liu@intel.com>

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

diff --git a/framework/crb.py b/framework/crb.py
index 066bb3f..44ddc42 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -30,7 +30,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import time
-import dts
 import re
 import os
 from settings import TIMEOUT, IXIA
diff --git a/framework/debugger.py b/framework/debugger.py
index f776327..b6f00b8 100644
--- a/framework/debugger.py
+++ b/framework/debugger.py
@@ -27,9 +27,9 @@ import os
 import signal
 import code
 import time
-import dts
 import imp
-import dts
+from settings import load_global_setting, DEBUG_SETTING
+from utils import get_subclasses, copy_instance_attr
 
 from test_case import TestCase
 
@@ -90,20 +90,20 @@ def rerun_command():
     target = AliveSuite.__dict__['target']
     suite = AliveSuite.__dict__['suite']
 
-    for test_classname, test_class in dts.get_subclasses(new_module, TestCase):
+    for test_classname, test_class in get_subclasses(new_module, TestCase):
         suite_obj = test_class(duts, tester, target, suite)
 
         # copy all element from previous suite to reloaded suite
-        dts.copy_instance_attr(AliveSuite, suite_obj)
+        copy_instance_attr(AliveSuite, suite_obj)
         # re-run specified test case
-        for case in dts.get_test_cases(suite_obj, r'%s' % AliveCase):
+        for case in suite_obj._get_test_cases(suite_obj, r'%s' % AliveCase):
             if callable(case):
                 case()
 
 
 def exit_command():
     """
-    Exit dts framework.
+    Exit framework.
     """
     global debug_cmd
     debug_cmd = 'exit'
@@ -163,7 +163,7 @@ def ignore_keyintr():
     """
     Temporary disable interrupt handler.
     """
-    if dts.debug_mode is False:
+    if load_global_setting(DEBUG_SETTING) != 'yes':
         return
 
     global debug_cmd
@@ -179,7 +179,7 @@ def aware_keyintr():
     """
     Reenable interrupt handler.
     """
-    if dts.debug_mode is False:
+    if load_global_setting(DEBUG_SETTING) != 'yes':
         return
 
     return signal.signal(signal.SIGINT, keyboard_handle)
diff --git a/framework/dut.py b/framework/dut.py
index 2f4e53a..88c4679 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -32,7 +32,6 @@
 import os
 import re
 import time
-import dts
 import settings
 from config import PortConf
 from settings import NICS, LOG_NAME_SEP
@@ -307,9 +306,9 @@ class Dut(Crb):
                 arch_huge_pages = hugepages if hugepages > 0 else 512
 
             if total_huge_pages != arch_huge_pages:
-                 # before all hugepage average distribution  by all socket,
-                 # but sometimes create mbuf pool on socket 0 failed when setup testpmd,
-                 # so set all huge page on socket 0
+                # before all hugepage average distribution  by all socket,
+                # but sometimes create mbuf pool on socket 0 failed when setup testpmd,
+                # so set all huge page on socket 0
                 if force_socket:
                     self.set_huge_pages(arch_huge_pages, 0)
                 else:
@@ -362,7 +361,7 @@ class Dut(Crb):
 
         current_nic = 0
         for (pci_bus, pci_id) in self.pci_devices_info:
-            if dts.accepted_nic(pci_id):
+            if settings.accepted_nic(pci_id):
                 if self.is_ssh_session_port(pci_bus):
                     continue
 
@@ -385,7 +384,7 @@ class Dut(Crb):
 
         current_nic = 0
         for (pci_bus, pci_id) in self.pci_devices_info:
-            if dts.accepted_nic(pci_id):
+            if settings.accepted_nic(pci_id):
                 if self.is_ssh_session_port(pci_bus):
                     continue
 
@@ -408,9 +407,6 @@ class Dut(Crb):
         ports = []
         candidates = []
 
-        if perf is None:
-            perf = self.want_perf_tests
-
         nictypes = []
         if nic_type == 'any':
             for portid in range(len(self.ports_info)):
@@ -508,17 +504,17 @@ class Dut(Crb):
 
     def lcore_table_print(self, horizontal=False):
         if not horizontal:
-            dts.results_table_add_header(['Socket', 'Core', 'Thread'])
+            result_table = ResultTable(['Socket', 'Core', 'Thread'])
 
             for lcore in self.cores:
-                dts.results_table_add_row([lcore['socket'], lcore['core'], lcore['thread']])
-            dts.results_table_print()
+                result_table.add_row([lcore['socket'], lcore['core'], lcore['thread']])
+            result_table.table_print()
         else:
-            dts.results_table_add_header(['X'] + [''] * len(self.cores))
-            dts.results_table_add_row(['Thread'] + [n['thread'] for n in self.cores])
-            dts.results_table_add_row(['Core'] + [n['core'] for n in self.cores])
-            dts.results_table_add_row(['Socket'] + [n['socket'] for n in self.cores])
-            dts.results_table_print()
+            result_table = ResultTable(['X'] + [''] * len(self.cores))
+            result_table.add_row(['Thread'] + [n['thread'] for n in self.cores])
+            result_table.add_row(['Core'] + [n['core'] for n in self.cores])
+            result_table.add_row(['Socket'] + [n['socket'] for n in self.cores])
+            result_table.table_print()
 
     def get_memory_channels(self):
         n = self.crb['memory channels']
@@ -556,7 +552,7 @@ class Dut(Crb):
         if self.ports_info:
             self.rescan_ports_uncached()
             self.save_serializer_ports()
- 
+
     def rescan_ports_uncached(self):
         """
         rescan ports and update port's mac adress, intf, ipv6 address.
@@ -652,7 +648,7 @@ class Dut(Crb):
             intf = port.get_interface_name()
 
             self.logger.info("DUT cached: [%s %s] %s" % (port_info['pci'],
-                             port_info['type'], intf))
+                                                         port_info['type'], intf))
 
             port_info['port'] = port
 
@@ -675,7 +671,7 @@ class Dut(Crb):
         for (pci_bus, pci_id) in self.pci_devices_info:
             if self.check_ports_available(pci_bus, pci_id) is False:
                 self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id,
-                                                          skipped))
+                                                      skipped))
                 continue
 
             addr_array = pci_bus.split(':')
@@ -721,7 +717,7 @@ class Dut(Crb):
 
         for (pci_bus, pci_id) in self.pci_devices_info:
 
-            if not dts.accepted_nic(pci_id):
+            if not settings.accepted_nic(pci_id):
                 self.logger.info("DUT: [%s %s] %s" % (pci_bus, pci_id,
                                                       skipped))
                 continue
@@ -836,8 +832,6 @@ class Dut(Crb):
                 if port_cfg['numa'] != port['numa']:
                     self.logger.warning("CONFIGURED NUMA NOT SAME AS SCANNED!!!")
                 port['numa'] = port_cfg['numa']
-                
-                
 
     def map_available_ports(self):
         """
diff --git a/framework/etgen.py b/framework/etgen.py
index 79dc505..a3ed9a0 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -32,18 +32,20 @@
 import re
 import string
 import time
-import dts
 from config import IxiaConf
 from ssh_connection import SSHConnection
 from settings import SCAPY2IXIA
 from logger import getLogger
 from exception import VerifyFailure
+from utils import create_mask
 
 
 class SoftwarePacketGenerator():
+
     """
     Software WindRiver packet generator for performance measurement.
     """
+
     def __init__(self, tester):
         self.tester = tester
 
@@ -86,7 +88,7 @@ class SoftwarePacketGenerator():
             pcap_cmd += " -s %d:%s" % (port_map[tx_port], pcap_file)
 
         # Selected 2 for -n to optimize results on Burage
-        cores_mask = dts.create_mask(self.tester.get_core_list("all"))
+        cores_mask = create_mask(self.tester.get_core_list("all"))
 
         self.tester.send_expect("./pktgen -n 2 -c %s --proc-type auto --socket-mem 256,256 -- -P -m \"%s\" %s"
                                 % (cores_mask, map_cmd, pcap_cmd), "Pktgen >", 100)
@@ -156,10 +158,10 @@ class IxiaPacketGenerator(SSHConnection):
         self.ixiaVersion = ixiaPorts[ixiaRef]["Version"]
         self.ports = ixiaPorts[ixiaRef]["Ports"]
 
-        if ixiaPorts[ixiaRef].has_key('force100g'): 
+        if ixiaPorts[ixiaRef].has_key('force100g'):
             self.enable100g = ixiaPorts[ixiaRef]['force100g']
         else:
-            self.enable100g = 'disable' 
+            self.enable100g = 'disable'
 
         self.logger.info(self.ixiaVersion)
         self.logger.info(self.ports)
@@ -416,8 +418,8 @@ class IxiaPacketGenerator(SSHConnection):
         for item in pList:
             self.add_tcl_cmd("port setFactoryDefaults chasId %d %d" % (
                 item['card'], item['port']))
-            #if the line rate is 100G and we need this port work in 100G mode,
-            #we need to add some configure to make it so.
+            # if the line rate is 100G and we need this port work in 100G mode,
+            # we need to add some configure to make it so.
             if int(self.get_line_rate(self.chasId, item).strip()) == 100000 and self.enable100g == 'enable':
                 self.add_tcl_cmd("port config -ieeeL1Defaults 0")
                 self.add_tcl_cmd("port config -autonegotiate false")
@@ -818,11 +820,11 @@ class IxiaPacketGenerator(SSHConnection):
         Returns the number of packets captured by IXIA on a previously set
         port. Call self.stat_get_stat_all_stats(port) before.
         """
-        if self._stat_cget_value('framesReceived') !=0:
+        if self._stat_cget_value('framesReceived') != 0:
             return self._stat_cget_value('framesReceived')
         else:
-        #if the packet size is large than 1518, this line will avoid return
-        #a wrong number
+            # if the packet size is large than 1518, this line will avoid return
+            # a wrong number
             return self._stat_cget_value('oversize')
 
     def get_flow_control_frames(self):
diff --git a/framework/plotting.py b/framework/plotting.py
index a9f5d2c..9e0ae54 100644
--- a/framework/plotting.py
+++ b/framework/plotting.py
@@ -30,12 +30,13 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import os
-import dts
 import shutil
 from plotgraph import Plot2DGraph
 from docutils.parsers.rst.directives import path
 from rst import path2Result
 import plotgraph
+import utils
+from exception import VerifyFailure
 
 
 """
@@ -94,7 +95,7 @@ class Plotting(object):
             self.plots_path = path
 
         except Exception as e:
-            raise dts.VerifyFailure("Plot Error: " + str(e))
+            raise VerifyFailure("Plot Error: " + str(e))
 
     def clear_all_plots(self, crb, target):
         shutil.rmtree(self.plots_path, True)
@@ -105,7 +106,7 @@ class Plotting(object):
 
         for yseries in ydata:
             if len(xdata) != len(yseries):
-                print dts.RED("The number of items in X axis (%s) and Y axis (%s) does not match." % (xdata, ydata))
+                print utils.RED("The number of items in X axis (%s) and Y axis (%s) does not match." % (xdata, ydata))
                 return ''
 
         image_path = "%s/%s.%s" % (self.plots_path, image_filename,
@@ -204,7 +205,7 @@ class Plotting(object):
         pgraph.titleYOffset = 0.96
         pgraph.titleXOffset = 0.35
 
-        if True == addHline:
+        if addHline:
             pgraph.horizontalLine = True
             pgraph.hLineName = hLine['name']
             pgraph.hLine = hLine['value']
diff --git a/framework/pmd_output.py b/framework/pmd_output.py
index f8e6088..d982c89 100644
--- a/framework/pmd_output.py
+++ b/framework/pmd_output.py
@@ -31,8 +31,8 @@
 
 import os
 import re
-import dts
 from settings import TIMEOUT
+from utils import create_mask
 
 
 class PmdOutput():
@@ -110,7 +110,7 @@ class PmdOutput():
             core_list = self.dut.get_core_list(self.default_cores)
         else:
             core_list = self.dut.get_core_list(cores, socket=socket)
-        self.coremask = dts.create_mask(core_list)
+        self.coremask = create_mask(core_list)
         command = "./%s/app/testpmd -c %s -n %d %s -- -i %s" \
             % (self.dut.target, self.coremask, self.dut.get_memory_channels(), eal_param, param)
         out = self.dut.send_expect(command, "testpmd> ", 120)
diff --git a/framework/project_dpdk.py b/framework/project_dpdk.py
index 4e44793..a8d44af 100644
--- a/framework/project_dpdk.py
+++ b/framework/project_dpdk.py
@@ -31,9 +31,9 @@
 
 import os
 import re
-import dts
 
-from settings import NICS
+from settings import NICS, load_global_setting, accepted_nic
+from settings import DPDK_RXMODE_SETTING, HOST_DRIVER_SETTING
 from ssh_connection import SSHConnection
 from crb import Crb
 from dut import Dut
@@ -71,10 +71,11 @@ class DPDKdut(Dut):
 
         self.set_rxtx_mode()
 
-        #Enable MLNX driver before installing dpdk
-        if dts.drivername == DRIVERS['ConnectX4']:
+        # Enable MLNX driver before installing dpdk
+        drivername = load_global_setting(HOST_DRIVER_SETTING)
+        if drivername == DRIVERS['ConnectX4']:
             self.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_MLX5_PMD=n/"
-                             + "CONFIG_RTE_LIBRTE_MLX5_PMD=y/' config/common_base" , "# ", 30)
+                             + "CONFIG_RTE_LIBRTE_MLX5_PMD=y/' config/common_base", "# ", 30)
 
         if not self.skip_setup:
             self.build_install_dpdk(target)
@@ -83,7 +84,7 @@ class DPDKdut(Dut):
         self.setup_modules(target)
 
         if bind_dev and self.get_os_type() == 'linux':
-            self.bind_interfaces_linux(dts.drivername)
+            self.bind_interfaces_linux(drivername)
         self.extra_nic_setup()
 
     def setup_modules(self, target):
@@ -94,7 +95,8 @@ class DPDKdut(Dut):
         setup_modules(target)
 
     def setup_modules_linux(self, target):
-        if dts.drivername == "vfio-pci":
+        drivername = load_global_setting(HOST_DRIVER_SETTING)
+        if drivername == "vfio-pci":
             self.send_expect("rmmod vfio_pci", "#", 70)
             self.send_expect("rmmod vfio_iommu_type1", "#", 70)
             self.send_expect("rmmod vfio", "#", 70)
@@ -119,7 +121,7 @@ class DPDKdut(Dut):
         binding_list = ''
 
         for (pci_bus, pci_id) in self.pci_devices_info:
-            if dts.accepted_nic(pci_id):
+            if accepted_nic(pci_id):
                 binding_list += '%s,' % (pci_bus)
 
         self.send_expect("kldunload if_ixgbe.ko", "#")
@@ -133,11 +135,8 @@ class DPDKdut(Dut):
         Set default RX/TX PMD function, now only take effect on ixgbe.
         """
         [arch, machine, env, toolchain] = self.target.split('-')
-        if dts.rx_mode is None:
-            mode = 'default'
-        else:
-            mode = dts.rx_mode
 
+        mode = load_global_setting(DPDK_RXMODE_SETTING)
         if mode == 'scalar':
             self.send_expect("sed -i -e 's/CONFIG_RTE_IXGBE_INC_VECTOR=.*$/"
                              + "CONFIG_RTE_IXGBE_INC_VECTOR=n/' config/common_%s" % env, "# ", 30)
@@ -154,6 +153,10 @@ class DPDKdut(Dut):
             self.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=.*$/"
                              + "CONFIG_RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC=y/' config/common_%s" % env, "# ", 30)
 
+    def set_package(self, pkg_name="", patch_list=[]):
+        self.package = pkg_name
+        self.patches = patch_list
+
     def build_install_dpdk(self, target, extra_options=''):
         """
         Build DPDK source code with specified target.
@@ -203,9 +206,9 @@ class DPDKdut(Dut):
         assert ("Error" not in out), "Compilation error..."
         assert ("No rule to make" not in out), "No rule to make error..."
 
-    def prepare_package(self, pkgName, patch):
+    def prepare_package(self):
         if not self.skip_setup:
-            assert (os.path.isfile(pkgName) is True), "Invalid package"
+            assert (os.path.isfile(self.package) is True), "Invalid package"
 
             p_dir, _ = os.path.split(self.base_dir)
             # ToDo: make this configurable
@@ -217,11 +220,11 @@ class DPDKdut(Dut):
                 raise ValueError("Directiry %s or %s does not exist,"
                                  "please check params -d"
                                  % (p_dir, dst_dir))
-            self.session.copy_file_to(pkgName, dst_dir)
+            self.session.copy_file_to(self.package, dst_dir)
 
             # put patches to p_dir/patches/
-            if (patch is not None):
-                for p in patch:
+            if (self.patches is not None):
+                for p in self.patches:
                     self.session.copy_file_to('dep/' + p, dst_dir)
 
             self.kill_all()
@@ -234,7 +237,7 @@ class DPDKdut(Dut):
 
             # unpack dpdk
             out = self.send_expect("tar zxf %s%s -C %s" %
-                                   (dst_dir, pkgName.split('/')[-1], p_dir),
+                                   (dst_dir, self.package.split('/')[-1], p_dir),
                                    "# ", 20, verify=True)
             if out == -1:
                 raise ValueError("Extract dpdk package to %s failure,"
@@ -248,17 +251,17 @@ class DPDKdut(Dut):
                 raise ValueError("dpdk dir %s mismatch, please check params -d"
                                  % self.base_dir)
 
-            if (patch is not None):
-                for p in patch:
+            if (self.patches is not None):
+                for p in self.patches:
                     out = self.send_expect("patch -d %s -p1 < %s" %
                                            (self.base_dir, dst_dir + p), "# ")
                     assert "****" not in out
 
-    def prerequisites(self, pkgName, patch):
+    def prerequisites(self):
         """
         Copy DPDK package to DUT and apply patch files.
         """
-        self.prepare_package(pkgName, patch)
+        self.prepare_package()
         self.dut_prerequisites()
         self.stage = "post-init"
 
@@ -275,7 +278,6 @@ class DPDKdut(Dut):
         Bind the interfaces to the selected driver. nics_to_bind can be None
         to bind all interfaces or an array with the port indexes
         """
-
         binding_list = '--bind=%s ' % driver
 
         current_nic = 0
diff --git a/framework/qemu_libvirt.py b/framework/qemu_libvirt.py
index de69d8f..ed8e0e6 100644
--- a/framework/qemu_libvirt.py
+++ b/framework/qemu_libvirt.py
@@ -33,7 +33,7 @@ import time
 import re
 import os
 
-import dts
+import utils
 from dut import Dut
 from ssh_connection import SSHConnection
 from virt_base import VirtBase
@@ -326,12 +326,12 @@ class LibvirtKvm(VirtBase):
                                    'managed': 'yes'})
 
         if 'pf_idx' not in options.keys():
-            print dts.RED("Missing device index for device option!!!")
+            print utils.RED("Missing device index for device option!!!")
             return False
 
         pf = int(options['pf_idx'])
         if pf > len(self.host_dut.ports_info):
-            print dts.RED("PF device index over size!!!")
+            print utils.RED("PF device index over size!!!")
             return False
 
         pci_addr = self.host_dut.ports_info[pf]['pci']
@@ -360,7 +360,7 @@ class LibvirtKvm(VirtBase):
             pci_map['guestpci'] = options['guestpci']
             self.pci_maps.append(pci_map)
         else:
-            print dts.RED('Host device pass-through need guestpci option!!!')
+            print utils.RED('Host device pass-through need guestpci option!!!')
 
     def add_vm_net(self, **options):
         """
diff --git a/framework/tester.py b/framework/tester.py
index 2781376..2d99daa 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -36,7 +36,7 @@ Interface for bulk traffic generators.
 import re
 import subprocess
 from time import sleep
-from settings import NICS
+from settings import NICS, load_global_setting, PERF_SETTING
 from crb import Crb
 from net_device import GetNicObj
 from etgen import IxiaPacketGenerator, SoftwarePacketGenerator
@@ -111,7 +111,7 @@ class Tester(Crb):
         """
         Check whether IXIA generator is ready for performance test.
         """
-        return self.want_perf_tests and self.has_external_traffic_generator()
+        return load_global_setting(PERF_SETTING) == 'yes' and self.has_external_traffic_generator()
 
     def tester_prerequisites(self):
         """
diff --git a/framework/virt_base.py b/framework/virt_base.py
index 5cd2854..e6a6d08 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -33,7 +33,7 @@ import traceback
 from random import randint
 from itertools import imap
 
-import dts
+import utils
 import exception
 from dut import Dut
 from config import VirtConf
@@ -167,9 +167,9 @@ class VirtBase(object):
                     for option in value:
                         param_func(**option)
                 else:
-                    print dts.RED("Virt %s function not callable!!!" % key)
+                    print utils.RED("Virt %s function not callable!!!" % key)
             except AttributeError:
-                    print dts.RED("Virt %s function not implemented!!!" % key)
+                    print utils.RED("Virt %s function not implemented!!!" % key)
             except Exception:
                 raise exception.VirtConfigParamException(key)
 
@@ -252,9 +252,9 @@ class VirtBase(object):
 
         except Exception as vm_except:
             if self.handle_exception(vm_except):
-                print dts.RED("Handled expection " + str(type(vm_except)))
+                print utils.RED("Handled expection " + str(type(vm_except)))
             else:
-                print dts.RED("Unhandled expection " + str(type(vm_except)))
+                print utils.RED("Unhandled expection " + str(type(vm_except)))
 
             if callable(self.callback):
                 self.callback()
@@ -273,9 +273,9 @@ class VirtBase(object):
                 vm_dut = self.instantiate_vm_dut(set_target, cpu_topo, bind_dev=False)
         except Exception as vm_except:
             if self.handle_exception(vm_except):
-                print dts.RED("Handled expection " + str(type(vm_except)))
+                print utils.RED("Handled expection " + str(type(vm_except)))
             else:
-                print dts.RED("Unhandled expection " + str(type(vm_except)))
+                print utils.RED("Unhandled expection " + str(type(vm_except)))
 
             return None
 
@@ -372,7 +372,7 @@ class VirtBase(object):
 
         try:
             # setting up dpdk in vm, must call at last
-            vm_dut.prerequisites(dts.Package, dts.Patches)
+            vm_dut.prerequisites(self.host_dut.package, self.host_dut.patches)
             if set_target:
                 target = self.host_dut.target
                 vm_dut.set_target(target, bind_dev)
diff --git a/framework/virt_dut.py b/framework/virt_dut.py
index 0010e08..e13c48c 100644
--- a/framework/virt_dut.py
+++ b/framework/virt_dut.py
@@ -32,7 +32,7 @@
 import os
 import re
 import time
-import dts
+import utils
 import settings
 from config import PortConf
 from settings import NICS, LOG_NAME_SEP, get_netdev
@@ -110,7 +110,7 @@ class VirtDut(DPDKdut):
         for key in self.ports_cfg.keys():
             index = int(key)
             if index >= port_num:
-                print dts.RED("Can not found [%d ]port info" % index)
+                print utils.RED("Can not found [%d ]port info" % index)
                 continue
 
             if 'peer' in self.ports_cfg[key].keys():
@@ -210,7 +210,7 @@ class VirtDut(DPDKdut):
                 total_phycores = socks * cores
                 # cores should match cpu_topo
                 if total != len(cpuinfo):
-                    print dts.RED("Core number not matched!!!")
+                    print utils.RED("Core number not matched!!!")
                 else:
                     for core in range(total):
                         thread = core / total_phycores
@@ -378,7 +378,7 @@ class VirtDut(DPDKdut):
                         vfs = remoteport.get_sriov_vfs_pci()
                         # if hostpci is vf of tester port
                         if hostpci == remotepci or hostpci in vfs:
-                            print dts.RED("Skip ping from same PF device")
+                            print utils.RED("Skip ping from same PF device")
                             continue
 
                 ipv6 = self.get_ipv6_address(vmPort)
diff --git a/framework/virt_scene.py b/framework/virt_scene.py
index 896d86b..fd7497d 100644
--- a/framework/virt_scene.py
+++ b/framework/virt_scene.py
@@ -30,7 +30,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 import time
-import dts
+import utils
 
 from settings import CONFIG_ROOT_PATH, get_netdev
 from config import VirtConf
@@ -38,6 +38,7 @@ from config import VIRTCONF
 from exception import *
 from qemu_kvm import QEMUKvm
 from pmd_output import PmdOutput
+from utils import create_mask
 
 # scenario module for handling scenario
 # 1. load configurations
@@ -136,11 +137,11 @@ class VirtScene(object):
 
     def prepare_host(self, **opts):
         if 'dpdk' not in opts.keys():
-            print dts.RED("Scenario host parameter request dpdk option!!!")
+            print utils.RED("Scenario host parameter request dpdk option!!!")
             raise VirtConfigParamException('host')
 
         if 'cores' not in opts.keys():
-            print dts.RED("Scenario host parameter request cores option!!!")
+            print utils.RED("Scenario host parameter request cores option!!!")
             raise VirtConfigParamException('host')
 
         if 'target' in opts.keys():
@@ -171,7 +172,7 @@ class VirtScene(object):
                 if int(cpu) not in self.host_dut.virt_pool.cores:
                     cpus.remove(cpu)
             # create core mask for reserver cores
-            core_mask = dts.create_mask(cpus)
+            core_mask = create_mask(cpus)
             # reserve those skipped cores
             self.host_dut.virt_pool.reserve_cpu(core_mask)
 
@@ -284,7 +285,7 @@ class VirtScene(object):
             if 'mac' in param.keys():
                 pf_net.set_vf_mac_addr(vf_idx, param['mac'])
         else:
-            print dts.RED("Invalid vf device config, request pf_dev")
+            print utils.RED("Invalid vf device config, request pf_dev")
 
         return vf_param
 
@@ -302,17 +303,17 @@ class VirtScene(object):
             if 'vf_num' in opts.keys():
                 vf_num = int(opts['vf_num'])
             else:
-                print dts.RED("No vf_num for port %d, assum one VF" % port)
+                print utils.RED("No vf_num for port %d, assum one VF" % port)
                 vf_num = 1
             if 'driver' in opts.keys():
                 driver = opts['driver']
 
             try:
-                print dts.GREEN("create vf %d %d %s" % (port, vf_num, driver))
+                print utils.GREEN("create vf %d %d %s" % (port, vf_num, driver))
                 self.host_dut.generate_sriov_vfs_by_port(port, vf_num, driver)
                 self.reset_pf_cmds(port)
             except:
-                print dts.RED("Failed to create vf as requested!!!")
+                print utils.RED("Failed to create vf as requested!!!")
                 raise VirtDeviceCreateException
 
     def handle_dev_destroy(self, **opts):
@@ -320,10 +321,10 @@ class VirtScene(object):
             port = int(opts['pf_idx'])
 
             try:
-                print dts.GREEN("destroy vfs on port %d" % port)
+                print utils.GREEN("destroy vfs on port %d" % port)
                 self.host_dut.destroy_sriov_vfs_by_port(port)
             except:
-                print dts.RED("Failed to destroy vf as requested!!!")
+                print utils.RED("Failed to destroy vf as requested!!!")
 
     def reg_prevm_cmds(self, command):
         """
@@ -343,7 +344,7 @@ class VirtScene(object):
     def run_pre_cmds(self):
         for cmd in self.pre_cmds:
             if cmd['type'] == 'vm':
-                print dts.RED("Can't run vm command when vm not ready")
+                print utils.RED("Can't run vm command when vm not ready")
             elif cmd['type'] == 'host':
                 crb = self.host_dut
             elif cmd['type'] == 'tester':
@@ -370,7 +371,7 @@ class VirtScene(object):
                                   verify=verify)
 
             if type(ret) is int and ret != 0:
-                print dts.RED("Failed to run command %s" % cmd['command'])
+                print utils.RED("Failed to run command %s" % cmd['command'])
                 raise VirtVmOperationException
 
     def reg_postvm_cmds(self, command):
@@ -417,7 +418,7 @@ class VirtScene(object):
                                   verify=verify)
 
             if type(ret) is int and ret != 0:
-                print dts.RED("Failed to run command %s" % cmd['command'])
+                print utils.RED("Failed to run command %s" % cmd['command'])
                 raise VirtVmOperationException
 
     def merge_params(self, vm, params):
@@ -467,7 +468,7 @@ class VirtScene(object):
                     self.vms.append(vm_info)
 
                 except Exception as e:
-                    print dts.RED("Failure for %s" % str(e))
+                    print utils.RED("Failure for %s" % str(e))
 
     def get_vm_duts(self):
         duts = []
-- 
1.9.3

  parent reply	other threads:[~2016-08-04  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04  5:38 [dts] [PATCH 0/9] optimize overall execution process Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 1/9] framework dts: optimize " Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 2/9] framework config: add concept for dut board Marvin Liu
2016-08-04  5:38 ` Marvin Liu [this message]
2016-08-04  5:38 ` [dts] [PATCH 4/9] framework rst: add class to handle RST report Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 5/9] framework settings: support global setting load and save Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 6/9] framework test_result: add class to handle result Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 7/9] framework test_case: add test case handle logic Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 8/9] framework utils: move shared function from dts module Marvin Liu
2016-08-04  5:38 ` [dts] [PATCH 9/9] tests: remove dependencies of " Marvin Liu
2016-08-04  6:07 ` [dts] [PATCH 0/9] optimize overall execution process 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=1470289102-12677-4-git-send-email-yong.liu@intel.com \
    --to=yong.liu@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).