diff --git a/libs/benchmark/report/generate_report.py b/libs/benchmark/report/generate_report.py index a268bf46dc65696149d56e6de0aba53f50324ff5..280b6179e8ef083e0ee1947c20897694e91be91a 100644 --- a/libs/benchmark/report/generate_report.py +++ b/libs/benchmark/report/generate_report.py @@ -161,9 +161,9 @@ class BenchmarkReport(object): self.benchmark_list = mdl_summary_list if sbs_name in system_summary_dic.keys() \ - and testsuit_name in system_summary_dic[sbs_name].keys(): + and testsuit_name in system_summary_dic.get(sbs_name, {}).keys(): subsystem_summary_dic = \ - system_summary_dic[sbs_name][testsuit_name] + system_summary_dic[sbs_name].get(testsuit_name, {}) subsystem_summary_dic["children"] += \ self._remove_iterations(mdl_summary_list) else: @@ -187,7 +187,7 @@ class BenchmarkReport(object): self._remove_iterations(mdl_summary_list) self.sbs_mdl_summary_list.append(subsystem_summary_dic) system_summary_dic[sbs_name] = {} - system_summary_dic[sbs_name][testsuit_name] = \ + system_summary_dic.get(sbs_name, {})[testsuit_name] = \ subsystem_summary_dic subsystem_summary_dic["pm"] = "unknown" subsystem_summary_dic["owner"] = "unknown" diff --git a/libs/fuzzlib/fuzzer_helper.py b/libs/fuzzlib/fuzzer_helper.py index b8c6217419047f2c6d31f1a22b6e03b4c5b3d2f9..53bd9a8a1fa63baf297cfbc3335965d3e7bdb4a4 100644 --- a/libs/fuzzlib/fuzzer_helper.py +++ b/libs/fuzzlib/fuzzer_helper.py @@ -92,11 +92,11 @@ def _get_fuzzer_yaml_config(fuzzer_name): "projects", fuzzer_name, "project.yaml") + yaml_config = {} if not os.path.exists(project_yaml_path): - return None - #log run stdout to fuzzlog dir - with open(project_yaml_path) as filehandle: - yaml_config = yaml.safe_load(filehandle) + # log run stdout to fuzzlog dir + with open(project_yaml_path) as filehandle: + yaml_config = yaml.safe_load(filehandle) return yaml_config diff --git a/libs/fuzzlib/tools/colored.py b/libs/fuzzlib/tools/colored.py index fae3edf70cf0862e416bc765c886b01a1faf79c8..21e0dc97b18457db5bb0c203701f19d48493ea6b 100644 --- a/libs/fuzzlib/tools/colored.py +++ b/libs/fuzzlib/tools/colored.py @@ -40,7 +40,7 @@ class Colored(object): @staticmethod def get_project_logger(log_project="default"): - if log_project in Colored.PROJECT_LOGGER_MAP: + if log_project in Colored.PROJECT_LOGGER_MAP.keys(): return Colored.PROJECT_LOGGER_MAP[log_project] logger = Colored(log_project) Colored.PROJECT_LOGGER_MAP[log_project] = logger diff --git a/libs/fuzzlib/tools/run_result.py b/libs/fuzzlib/tools/run_result.py index 5fb2b6edc683e9f0a27568eccde9384378da423f..17328ae951f804093a2acdb43146a3fc2e816fc1 100644 --- a/libs/fuzzlib/tools/run_result.py +++ b/libs/fuzzlib/tools/run_result.py @@ -79,7 +79,7 @@ class RunResult(): if html_format: f.write(RunResult.filter_log(render_detail(self.crash_info))) else: - f.write(RunResult.filter_log(self.crash_info["backtrace"])) + f.write(RunResult.filter_log(self.crash_info.get("backtrace", ""))) if __name__ == "__main__": diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index 3b463f63ae52793e96ea81cfcf619f5715ca9f77..165a644e56bbf57e1aa5a07c48454bd018072dff 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -215,12 +215,12 @@ class UserConfigManager(object): node = root.find(target_name) if not node: - return None + return data_dic if sub_target != "": node = node.find(sub_target) if not node: - return None + return data_dic for sub in node: if sub.text is None: diff --git a/src/core/config/parse_parts_config.py b/src/core/config/parse_parts_config.py index 3e51417d40a1786073203d8f0d6d31845ff044ae..1eaa280b49646be902b35c21ff29b2718017f05a 100755 --- a/src/core/config/parse_parts_config.py +++ b/src/core/config/parse_parts_config.py @@ -52,16 +52,14 @@ class ParsePartsConfig(object): def get_infos_data(self): config_filepath = self.get_config_file_path() + data_dic = {} if not os.path.exists(config_filepath): print("Error: %s is not exist." % config_filepath) - return None, None - - data_dic = None - with open(config_filepath, 'r') as file_handle: - data_dic = json.load(file_handle) - if not data_dic: - print("Error: json file load error.") - return None, None + else: + with open(config_filepath, 'r') as file_handle: + data_dic = json.load(file_handle) + if not data_dic: + print("Error: json file load error.") # open source branch, the part form of all product is "phone" if is_open_source_product(self.productform): @@ -70,7 +68,6 @@ class ParsePartsConfig(object): product_data_dic = data_dic.get(self.productform, None) if product_data_dic is None: print("Error: product_data_dic is None.") - return None, None subsystem_infos = product_data_dic.get("subsystem_infos", None) part_infos = product_data_dic.get("part_infos", None) diff --git a/src/core/driver/lite_driver.py b/src/core/driver/lite_driver.py index 1f755f46aec401fe2767ff81cddc6fe4157cd9f1..89fe5347c0a0ac9e848eca515342bc42fd743067 100755 --- a/src/core/driver/lite_driver.py +++ b/src/core/driver/lite_driver.py @@ -80,7 +80,6 @@ class LiteUnitTest(IDriver): def __check_failed__(self, msg): self.log.error("check failed {}".format(msg)) - return None def __check_environment__(self, device_options): pass @@ -298,7 +297,6 @@ class LiteUnitTest(IDriver): show driver info. """ self.log.info("this is test driver for cpp test") - return None def __result__(self): pass diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index d0ac52af924604fa789f25c1dff2895ea3282e7c..3c37a587c5c2b70c604eda659da6cc9e780ed02d 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -59,7 +59,7 @@ class TestCaseManager(object): test_type, options) for key, value in suit_file_dic.items(): - suit_file_dic[key] = value + temp_dic[key] + suit_file_dic[key] = value + temp_dic.get(key, "") return suit_file_dic def get_test_file_data_by_test_type(self, test_case_path, @@ -72,6 +72,28 @@ class TestCaseManager(object): else: LOG.error("Test case dir does not exist. %s" % test_case_out_path) return suit_file_dictionary + + def check_dic(self, suffix_name, suite_file_dictionary, suite_file): + """ + + :param suffix_name: + :param suite_file_dictionary: + :param suite_file: + :return: + """ + suffix_dic = { + ".dex": "DEX", + ".hap": "JST", + ".py": "PYT", + "": "CXX", + ".bin": "BIN" + } + if suffix_name in suffix_dic.keys(): + if suite_file_dictionary.get(suffix_name, []) and isinstance( + suite_file_dictionary.get(suffix_name, []), list): + suite_file_dictionary[suffix_dic[suffix_name]].append(suite_file) + else: + suite_file_dictionary[suffix_dic[suffix_name]] = [suite_file] def get_all_test_file(self, test_case_out_path, options): suite_file_dictionary = copy.deepcopy(TESTFILE_TYPE_DATA_DIC) @@ -107,18 +129,7 @@ class TestCaseManager(object): options): continue - if suffix_name == ".dex": - suite_file_dictionary["DEX"].append(suite_file) - elif suffix_name == ".hap": - suite_file_dictionary["JST"].append(suite_file) - elif suffix_name == ".py": - if not self.check_python_test_file(suite_file): - continue - suite_file_dictionary["PYT"].append(suite_file) - elif suffix_name == "": - suite_file_dictionary["CXX"].append(suite_file) - elif suffix_name == ".bin": - suite_file_dictionary["BIN"].append(suite_file) + self.check_dic(suffix_name, suite_file_dictionary, suite_file) return suite_file_dictionary diff --git a/src/core/utils.py b/src/core/utils.py index fc0a58974ee962884e90903d848494a39edd44bc..e7e4212fed783a8653c7ba923e690dfce254f5d3 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -124,14 +124,12 @@ def parse_device_name(product_form): device_json_file = os.path.join(sys.source_code_root_path, "productdefine", "common", "products", "{}.json".format(product_form)) - if not os.path.exists(device_json_file): - return None - - with open(device_json_file, 'r') as json_file: - json_info = json.load(json_file) - if not json_info: - return None - device_name = json_info.get('product_device') + json_info = {} + if os.path.exists(device_json_file): + with open(device_json_file, 'r') as json_file: + json_info = json.load(json_file) + + device_name = json_info.get('product_device', None) return device_name