[dts] [PATCH V1] Add vfio-pci cases to vf_packet_rxtx test suite. use a global configuration file to determin vf driver.
Liu, Yong
yong.liu at intel.com
Fri Sep 29 04:50:39 CEST 2017
Yuwei,
One comment below.
Thanks,
Marvin
> -----Original Message-----
> From: dts [mailto:dts-bounces at dpdk.org] On Behalf Of Yuwei Zhang
> Sent: Friday, September 29, 2017 10:16 AM
> To: dts at dpdk.org
> Cc: Zhang, Yuwei1 <yuwei1.zhang at intel.com>
> Subject: [dts] [PATCH V1] Add vfio-pci cases to vf_packet_rxtx test suite.
> use a global configuration file to determin vf driver.
>
> Signed-off-by: Yuwei Zhang <yuwei1.zhang at intel.com>
> ---
> conf/global_suite.cfg | 2 ++
> framework/config.py | 26 ++++++++++++++++++++++++++
> framework/test_case.py | 11 +++++++++++
> tests/TestSuite_vf_packet_rxtx.py | 30 ++++++++++++++++++++++--------
> 4 files changed, 61 insertions(+), 8 deletions(-)
> create mode 100644 conf/global_suite.cfg
>
> diff --git a/conf/global_suite.cfg b/conf/global_suite.cfg
> new file mode 100644
> index 0000000..b456477
> --- /dev/null
> +++ b/conf/global_suite.cfg
> @@ -0,0 +1,2 @@
> +[global]
> +vf_driver=vfio-pci
> \ No newline at end of file
> diff --git a/framework/config.py b/framework/config.py
> index 9e514a7..5323b80 100644
> --- a/framework/config.py
> +++ b/framework/config.py
> @@ -45,6 +45,7 @@ CRBCONF = "%s/crbs.cfg" % CONFIG_ROOT_PATH
> VIRTCONF = "%s/virt_global.cfg" % CONFIG_ROOT_PATH
> IXIACONF = "%s/ixia.cfg" % CONFIG_ROOT_PATH
> SUITECONF_SAMPLE = "%s/suite_sample.cfg" % CONFIG_ROOT_PATH
> +GLOBALCONF = "%s/global_suite.cfg" % CONFIG_ROOT_PATH
>
>
> class UserConf():
> @@ -87,7 +88,32 @@ class UserConf():
> paramDict[key] = value
> return paramDict
>
> +class GlobalConf(UserConf):
> + def __init__(self):
> + self.global_cfg = {}
> + try:
> + self.global_conf = UserConf(GLOBALCONF)
> + except ConfigParseException:
> + self.global_conf = None
> +
> + # load global configuration
> + self.global_cfg = self.load_global_config()
> +
> + def load_global_config(self, section_name='global'):
> + global_cfg = self.global_cfg.copy()
> + try:
> + section_confs = self.global_conf.load_section(section_name)
> + except:
> + print "FAILED FIND SECTION[%s] CONFIG!!!" % section_name
> + return global_cfg
> +
> + if section_confs is None:
> + return global_cfg
>
> + global_cfg = dict(section_confs)
> +
> + return global_cfg
> +
> class SuiteConf(UserConf):
> def __init__(self, suite_name=""):
> self.config_file = CONFIG_ROOT_PATH + os.sep + suite_name +
> ".cfg"
> diff --git a/framework/test_case.py b/framework/test_case.py
> index c9d3574..be8c201 100644
> --- a/framework/test_case.py
> +++ b/framework/test_case.py
> @@ -44,6 +44,7 @@ from settings import PERF_SETTING, FUNC_SETTING,
> DEBUG_SETTING, DEBUG_CASE_SETTI
> from rst import RstReport
> from test_result import ResultTable, Result
> from logger import getLogger
> +from config import GlobalConf
> from config import SuiteConf
>
> class TestCase(object):
> @@ -109,6 +110,10 @@ class TestCase(object):
> # create rst format report for this suite
> self._rst_obj = RstReport('rst_report', target, self.nic,
> self.suite_name, self._enable_perf)
>
> + # load global config
> + self._global_conf = GlobalConf()
> + self._global_cfg = self._global_conf.global_cfg
> +
> # load suite configuration
> self._suite_conf = SuiteConf(self.suite_name)
> self._suite_cfg = self._suite_conf.suite_cfg
We can combine suite configuration with global configuration here. This will make suite handle configuration more easily.
There's no need to add global concept in suite.
> @@ -377,6 +382,12 @@ class TestCase(object):
> """
> return self._suite_cfg
>
> + def get_global_cfg(self):
> + """
> + Return global based configuration
> + """
> + return self._global_cfg
> +
> def execute_tear_downall(self):
> """
> execute suite tear_down_all function
> diff --git a/tests/TestSuite_vf_packet_rxtx.py
> b/tests/TestSuite_vf_packet_rxtx.py
> index 50451f6..30defbc 100644
> --- a/tests/TestSuite_vf_packet_rxtx.py
> +++ b/tests/TestSuite_vf_packet_rxtx.py
> @@ -12,6 +12,8 @@ VM_CORES_MASK = 'all'
>
> class TestVfPacketRxtx(TestCase):
>
> + supported_vf_driver = ['pci-stub', 'vfio-pci']
> +
> def set_up_all(self):
>
> self.dut_ports = self.dut.get_ports(self.nic)
> @@ -19,6 +21,18 @@ class TestVfPacketRxtx(TestCase):
> self.vm0 = None
> self.vm1 = None
>
> + # set vf assign method and vf driver
> + self.vf_driver = self.get_global_cfg()['vf_driver']
> + if self.vf_driver is None:
> + self.vf_driver = 'pci-stub'
> + self.verify(self.vf_driver in self.supported_vf_driver,
> "Unspported vf driver")
> + if self.vf_driver == 'pci-stub':
> + self.vf_assign_method = 'pci-assign'
> + else:
> + self.vf_assign_method = 'vfio-pci'
> +
> +
> +
> def set_up(self):
>
> self.setup_2pf_2vf_1vm_env_flag = 0
> @@ -37,10 +51,10 @@ class TestVfPacketRxtx(TestCase):
> try:
>
> for port in self.sriov_vfs_port_0:
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> for port in self.sriov_vfs_port_1:
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> time.sleep(1)
> vf0_prop = {'opt_host': self.sriov_vfs_port_0[0].pci}
> @@ -59,8 +73,8 @@ class TestVfPacketRxtx(TestCase):
>
> # set up VM0 ENV
> self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
> - self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> - self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + self.vm0.set_vm_device(driver=self.vf_assign_method,
> **vf0_prop)
> + self.vm0.set_vm_device(driver=self.vf_assign_method,
> **vf1_prop)
> self.vm_dut_0 = self.vm0.start()
> if self.vm_dut_0 is None:
> raise Exception("Set up VM0 ENV failed!")
> @@ -159,7 +173,7 @@ class TestVfPacketRxtx(TestCase):
>
> for port in self.sriov_vfs_port:
> print port.pci
> - port.bind_driver('pci-stub')
> + port.bind_driver(self.vf_driver)
>
> time.sleep(1)
> vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> @@ -181,14 +195,14 @@ class TestVfPacketRxtx(TestCase):
>
> # set up VM0 ENV
> self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_packet_rxtx')
> - self.vm0.set_vm_device(driver='pci-assign', **vf0_prop)
> - self.vm0.set_vm_device(driver='pci-assign', **vf1_prop)
> + self.vm0.set_vm_device(driver=self.vf_assign_method,
> **vf0_prop)
> + self.vm0.set_vm_device(driver=self.vf_assign_method,
> **vf1_prop)
> self.vm_dut_0 = self.vm0.start()
> if self.vm_dut_0 is None:
> raise Exception("Set up VM0 ENV failed!")
> # set up VM1 ENV
> self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_packet_rxtx')
> - self.vm1.set_vm_device(driver='pci-assign', **vf2_prop)
> + self.vm1.set_vm_device(driver=self.vf_assign_method,
> **vf2_prop)
> self.vm_dut_1 = self.vm1.start()
> if self.vm_dut_1 is None:
> raise Exception("Set up VM1 ENV failed!")
> --
> 2.14.1.windows.1
More information about the dts
mailing list