[dts] [PATCH v1] framework/config: utilize eval to parse configurations

Marvin Liu yong.liu at intel.com
Sun Jan 7 21:23:22 CET 2018


Suite config will utilize python eval command to parse configurations.
It will be easy to generate list or dictionary type of suite/case
configuration.

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

diff --git a/conf/global_suite.cfg b/conf/global_suite.cfg
index d784fc5..91885a2 100644
--- a/conf/global_suite.cfg
+++ b/conf/global_suite.cfg
@@ -1,2 +1,2 @@
 [global]
-vf_driver=pci-stub
\ No newline at end of file
+vf_driver="vfio-pci"
diff --git a/conf/suite_sample.cfg b/conf/suite_sample.cfg
index 434a31e..2467213 100644
--- a/conf/suite_sample.cfg
+++ b/conf/suite_sample.cfg
@@ -1,9 +1,8 @@
 # sample for suite configuration
 [suite]
-int_value=value_int:10
-hex_value=value_hex:ff
+int_value=int(10)
+hex_value=int("0xff", 16)
 [case1]
-string=testpmd
-command=help
-packet_sizes=list_int:64,128,256
-protocals=list_str:TCP,UDP,SCTP
+string="testpmd"
+packet_sizes=[64, 128, 256]
+protocals=["TCP", "UDP", "SCTP"]
diff --git a/framework/config.py b/framework/config.py
index 80f1dd3..f7f347a 100644
--- a/framework/config.py
+++ b/framework/config.py
@@ -44,7 +44,6 @@ PORTCONF = "%s/ports.cfg" % CONFIG_ROOT_PATH
 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
 
 
@@ -142,23 +141,7 @@ class SuiteConf(UserConf):
 
         conf = dict(case_confs)
         for key, data_string in conf.items():
-            if data_string.startswith("value_int:"):
-                value = data_string[len("value_int:"):]
-                case_cfg[key] = int(value)
-            elif data_string.startswith("value_hex:"):
-                value = data_string[len("value_hex:"):]
-                case_cfg[key] = int(value, 16)
-            elif data_string.startswith("list_int:"):
-                value = data_string[len("list_int:"):]
-                datas = value.split(',')
-                int_list = map(lambda x: int(x), datas)
-                case_cfg[key] = int_list
-            elif data_string.startswith("list_str:"):
-                value = data_string[len("list_str:"):]
-                str_list = value.split(',')
-                case_cfg[key] = str_list
-            else:
-                case_cfg[key] = data_string
+            case_cfg[key] = eval(data_string)
 
         return case_cfg
 
@@ -422,6 +405,6 @@ if __name__ == '__main__':
     print ixiaconf.load_ixia_config()
 
     # example for suite configure file
-    suiteconf = SuiteConf(SUITECONF_SAMPLE)
+    suiteconf = SuiteConf("suite_sample")
     print suiteconf.load_case_config("case1")
     print suiteconf.load_case_config("case2")
-- 
1.9.3



More information about the dts mailing list