[dts] [PATCH v1] add a global config file to all test suites

Yuwei Zhang yuwei1.zhang at intel.com
Fri Oct 6 03:13:55 CEST 2017


Signed-off-by: Yuwei Zhang <yuwei1.zhang at intel.com>
---
 conf/global_suite.cfg |  2 ++
 framework/config.py   | 28 +++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
 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..d784fc5
--- /dev/null
+++ b/conf/global_suite.cfg
@@ -0,0 +1,2 @@
+[global]
+vf_driver=pci-stub
\ No newline at end of file
diff --git a/framework/config.py b/framework/config.py
index 9e514a7..80f1dd3 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,11 +88,36 @@ 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.suite_cfg = GlobalConf().load_global_config()
         self.config_file = CONFIG_ROOT_PATH + os.sep + suite_name + ".cfg"
-        self.suite_cfg = {}
         try:
             self.suite_conf = UserConf(self.config_file)
         except ConfigParseException:
-- 
2.14.1.windows.1



More information about the dts mailing list