test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH v1] framework/config: utilize eval to parse configurations
@ 2018-01-07 20:23 Marvin Liu
  2018-01-09 22:55 ` [dts] [PATCH v2] " Marvin Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Marvin Liu @ 2018-01-07 20:23 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

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@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [dts] [PATCH v2] framework/config: utilize eval to parse configurations
  2018-01-07 20:23 [dts] [PATCH v1] framework/config: utilize eval to parse configurations Marvin Liu
@ 2018-01-09 22:55 ` Marvin Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Marvin Liu @ 2018-01-09 22:55 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

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

v2: by default paramater will taken as string, no need to use quotation
marks

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

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-10  6:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-07 20:23 [dts] [PATCH v1] framework/config: utilize eval to parse configurations Marvin Liu
2018-01-09 22:55 ` [dts] [PATCH v2] " Marvin Liu

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).