diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index 3b463f63ae52793e96ea81cfcf619f5715ca9f77..44a5898cf38b32f2df20a96d1525edd538ba86e7 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -24,24 +24,38 @@ from xdevice import platform_logger from core.constants import ConfigFileConst 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): def __init__(self, filepath=""): if filepath == "": + + # filepath = OpenHarmony/test/developertest/config/framework_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.FRAMECONFIG_FILEPATH)) else: self.filepath = filepath + # 获取framework_config.xml中所有name的value,返回列表 def get_framework_config(self, target_name): data_list = [] try: if os.path.exists(self.filepath): + + # 读取xml文件 tree = ET.parse(self.filepath) + + # 获取根节点 root = tree.getroot() + + # 获取节点的名字 node = root.find(target_name) + + # 遍历 name 节点 获取value 添加到data_list中 for sub in node: value = sub.attrib.get("name") if value and value != "": @@ -50,6 +64,7 @@ class FrameworkConfigManager(object): LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) return data_list + # 获取framework_config.xml中test_category标签里name、desc、timeout的value,返回字典 def get_test_category_info(self, target_name="test_category"): test_type_timeout_dic = {} try: @@ -69,13 +84,17 @@ class FrameworkConfigManager(object): LOG.error(("Parse %s fail!" % self.filepath) + xml_exception.args) 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"): return self.get_framework_config(target_name) +# filter_config.xml class FilterConfigManager(object): def __init__(self, filepath=""): if filepath == "": + + # filepath = OpenHarmony/test/developertest/config/filter_config.xml self.filepath = os.path.abspath( os.path.join(CONFIG_PATH, ConfigFileConst.FILTERCONFIG_FILEPATH)) @@ -106,7 +125,7 @@ class FilterConfigManager(object): def get_filter_config_path(self): return self.filepath - +# 这里的filepath不存在 class ResourceConfigManager(object): def __init__(self, filepath=""): if filepath == "": @@ -142,6 +161,8 @@ class ResourceConfigManager(object): class UserConfigManager(object): def __init__(self, config_file=""): if config_file == "": + + # filepath = OpenHarmony/test/developertest/config/user_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.USERCONFIG_FILEPATH)) else: @@ -261,6 +282,8 @@ class UserConfigManager(object): class BuildConfigManager(object): def __init__(self, filepath=""): if filepath == "": + + # filepath = OpenHarmony/test/developertest/config/build_config.xml self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.BUILDCONFIG_FILEPATH)) else: @@ -287,6 +310,8 @@ class BuildConfigManager(object): class FuzzerConfigManager(object): def __init__(self, config_path=""): if config_path == "": + + # filepath = OpenHarmony/test/developertest/config/fuzz_config.xml self.filepath = self.filepath = os.path.abspath(os.path.join( CONFIG_PATH, ConfigFileConst.FUZZCONFIG_FILEPATH)) else: