提交 03b4ff01 编写于 作者: F fengkai

analysis of function

Signed-off-by: Nfengkai <fengkai@kaihongdigi.com>
上级 a60f7d47
...@@ -24,24 +24,38 @@ from xdevice import platform_logger ...@@ -24,24 +24,38 @@ from xdevice import platform_logger
from core.constants import ConfigFileConst from core.constants import ConfigFileConst
LOG = platform_logger("config_manager") LOG = platform_logger("config_manager")
CONFIG_PATH = os.path.join(sys.framework_res_dir, "config")
# framework_res_dir = OpenHarmony/test/developertest
# CONFIG_PATH = OpenHarmony/test/developertest/config
CONFIG_PATH = os.path.join(sys.framework_res_dir, "config")
# framework_config.xml
class FrameworkConfigManager(object): class FrameworkConfigManager(object):
def __init__(self, filepath=""): def __init__(self, filepath=""):
if filepath == "": if filepath == "":
# filepath = OpenHarmony/test/developertest/config/framework_config.xml
self.filepath = os.path.abspath(os.path.join( self.filepath = os.path.abspath(os.path.join(
CONFIG_PATH, ConfigFileConst.FRAMECONFIG_FILEPATH)) CONFIG_PATH, ConfigFileConst.FRAMECONFIG_FILEPATH))
else: else:
self.filepath = filepath self.filepath = filepath
# 获取framework_config.xml中所有name的value,返回列表
def get_framework_config(self, target_name): def get_framework_config(self, target_name):
data_list = [] data_list = []
try: try:
if os.path.exists(self.filepath): if os.path.exists(self.filepath):
# 读取xml文件
tree = ET.parse(self.filepath) tree = ET.parse(self.filepath)
# 获取根节点
root = tree.getroot() root = tree.getroot()
# 获取节点的名字
node = root.find(target_name) node = root.find(target_name)
# 遍历 name 节点 获取value 添加到data_list中
for sub in node: for sub in node:
value = sub.attrib.get("name") value = sub.attrib.get("name")
if value and value != "": if value and value != "":
...@@ -50,6 +64,7 @@ class FrameworkConfigManager(object): ...@@ -50,6 +64,7 @@ class FrameworkConfigManager(object):
LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args)
return data_list return data_list
# 获取framework_config.xml中test_category标签里name、desc、timeout的value,返回字典
def get_test_category_info(self, target_name="test_category"): def get_test_category_info(self, target_name="test_category"):
test_type_timeout_dic = {} test_type_timeout_dic = {}
try: try:
...@@ -69,13 +84,17 @@ class FrameworkConfigManager(object): ...@@ -69,13 +84,17 @@ class FrameworkConfigManager(object):
LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args)
return test_type_timeout_dic return test_type_timeout_dic
# 获取framework_config.xml中all_category标签里name的value,返回列表 如:unittest、moduletest、systemtest、performance
def get_all_category_info(self, target_name="all_category"): def get_all_category_info(self, target_name="all_category"):
return self.get_framework_config(target_name) return self.get_framework_config(target_name)
# filter_config.xml
class FilterConfigManager(object): class FilterConfigManager(object):
def __init__(self, filepath=""): def __init__(self, filepath=""):
if filepath == "": if filepath == "":
# filepath = OpenHarmony/test/developertest/config/filter_config.xml
self.filepath = os.path.abspath( self.filepath = os.path.abspath(
os.path.join(CONFIG_PATH, os.path.join(CONFIG_PATH,
ConfigFileConst.FILTERCONFIG_FILEPATH)) ConfigFileConst.FILTERCONFIG_FILEPATH))
...@@ -106,7 +125,7 @@ class FilterConfigManager(object): ...@@ -106,7 +125,7 @@ class FilterConfigManager(object):
def get_filter_config_path(self): def get_filter_config_path(self):
return self.filepath return self.filepath
# 这里的filepath不存在
class ResourceConfigManager(object): class ResourceConfigManager(object):
def __init__(self, filepath=""): def __init__(self, filepath=""):
if filepath == "": if filepath == "":
...@@ -142,6 +161,8 @@ class ResourceConfigManager(object): ...@@ -142,6 +161,8 @@ class ResourceConfigManager(object):
class UserConfigManager(object): class UserConfigManager(object):
def __init__(self, config_file=""): def __init__(self, config_file=""):
if config_file == "": if config_file == "":
# filepath = OpenHarmony/test/developertest/config/user_config.xml
self.filepath = os.path.abspath(os.path.join( self.filepath = os.path.abspath(os.path.join(
CONFIG_PATH, ConfigFileConst.USERCONFIG_FILEPATH)) CONFIG_PATH, ConfigFileConst.USERCONFIG_FILEPATH))
else: else:
...@@ -261,6 +282,8 @@ class UserConfigManager(object): ...@@ -261,6 +282,8 @@ class UserConfigManager(object):
class BuildConfigManager(object): class BuildConfigManager(object):
def __init__(self, filepath=""): def __init__(self, filepath=""):
if filepath == "": if filepath == "":
# filepath = OpenHarmony/test/developertest/config/build_config.xml
self.filepath = os.path.abspath(os.path.join( self.filepath = os.path.abspath(os.path.join(
CONFIG_PATH, ConfigFileConst.BUILDCONFIG_FILEPATH)) CONFIG_PATH, ConfigFileConst.BUILDCONFIG_FILEPATH))
else: else:
...@@ -287,6 +310,8 @@ class BuildConfigManager(object): ...@@ -287,6 +310,8 @@ class BuildConfigManager(object):
class FuzzerConfigManager(object): class FuzzerConfigManager(object):
def __init__(self, config_path=""): def __init__(self, config_path=""):
if config_path == "": if config_path == "":
# filepath = OpenHarmony/test/developertest/config/fuzz_config.xml
self.filepath = self.filepath = os.path.abspath(os.path.join( self.filepath = self.filepath = os.path.abspath(os.path.join(
CONFIG_PATH, ConfigFileConst.FUZZCONFIG_FILEPATH)) CONFIG_PATH, ConfigFileConst.FUZZCONFIG_FILEPATH))
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册