From 652c53fd0641f54cff2774f78b009c2bb63c4734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3=E9=B9=8F=E4=BC=9F?= Date: Tue, 24 May 2022 06:48:46 +0000 Subject: [PATCH 1/5] Signed-off-by:mipengwei --- libs/benchmark/report/generate_report.py | 11 ++++++----- libs/fuzzlib/fuzzer_helper.py | 8 ++++---- libs/fuzzlib/tools/colored.py | 3 ++- libs/fuzzlib/tools/run_result.py | 4 +++- src/core/config/config_manager.py | 4 ++-- src/core/config/parse_parts_config.py | 15 ++++++--------- src/core/driver/lite_driver.py | 3 --- src/core/testcase/testcase_manager.py | 20 +++++++++++++++----- src/core/utils.py | 14 ++++++-------- 9 files changed, 44 insertions(+), 38 deletions(-) diff --git a/libs/benchmark/report/generate_report.py b/libs/benchmark/report/generate_report.py index a268bf4..67e7332 100644 --- a/libs/benchmark/report/generate_report.py +++ b/libs/benchmark/report/generate_report.py @@ -160,10 +160,10 @@ class BenchmarkReport(object): module_name, testsuit_name, json_file) self.benchmark_list = mdl_summary_list - if sbs_name in system_summary_dic.keys() \ - and testsuit_name in system_summary_dic[sbs_name].keys(): + if sbs_name in system_summary_dic.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.get(sbs_name).get(testsuit_name, {}) subsystem_summary_dic["children"] += \ self._remove_iterations(mdl_summary_list) else: @@ -187,8 +187,9 @@ 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] = \ - subsystem_summary_dic + if isinstance(system_summary_dic.get(sbs_name), dict): + 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 b8c6217..53bd9a8 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 fae3edf..db1b1c1 100644 --- a/libs/fuzzlib/tools/colored.py +++ b/libs/fuzzlib/tools/colored.py @@ -41,7 +41,8 @@ class Colored(object): @staticmethod def get_project_logger(log_project="default"): if log_project in Colored.PROJECT_LOGGER_MAP: - return Colored.PROJECT_LOGGER_MAP[log_project] + return Colored.PROJECT_LOGGER_MAP.get(log_project) + logger = Colored(log_project) Colored.PROJECT_LOGGER_MAP[log_project] = logger return logger diff --git a/libs/fuzzlib/tools/run_result.py b/libs/fuzzlib/tools/run_result.py index 5fb2b6e..ff72648 100644 --- a/libs/fuzzlib/tools/run_result.py +++ b/libs/fuzzlib/tools/run_result.py @@ -79,7 +79,9 @@ 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 3b463f6..165a644 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 3e51417..1eaa280 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 1f755f4..8a4296f 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 @@ -291,14 +290,12 @@ class LiteUnitTest(IDriver): show help info. """ self.log.info("this is test driver for cpp test") - return None def show_driver_info(self): """ 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 d0ac52a..4d48f50 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -108,17 +108,27 @@ class TestCaseManager(object): continue if suffix_name == ".dex": - suite_file_dictionary["DEX"].append(suite_file) + if suite_file_dictionary.get("DEX", []) and isinstance( + suite_file_dictionary.get("DEX", []), list): + suite_file_dictionary.get("DEX").append(suite_file) elif suffix_name == ".hap": - suite_file_dictionary["JST"].append(suite_file) + if suite_file_dictionary.get("JST", []) and isinstance( + suite_file_dictionary.get("JST", []), list): + suite_file_dictionary.get("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) + if suite_file_dictionary.get("PYT", []) and isinstance( + suite_file_dictionary.get("PYT", []), list): + suite_file_dictionary.get("PYT").append(suite_file) elif suffix_name == "": - suite_file_dictionary["CXX"].append(suite_file) + if suite_file_dictionary.get("CXX", []) and isinstance( + suite_file_dictionary.get("CXX", []), list): + suite_file_dictionary.get("CXX").append(suite_file) elif suffix_name == ".bin": - suite_file_dictionary["BIN"].append(suite_file) + if suite_file_dictionary.get("BIN", []) and isinstance( + suite_file_dictionary.get("BIN", []), list): + suite_file_dictionary.get("BIN").append(suite_file) return suite_file_dictionary diff --git a/src/core/utils.py b/src/core/utils.py index 45d10b2..cd6b37c 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 -- Gitee From e7c6cdd99e26fb86b3109f512f858ba6dd8759d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3=E9=B9=8F=E4=BC=9F?= Date: Tue, 24 May 2022 07:40:10 +0000 Subject: [PATCH 2/5] Signed-off-by:mipengwei --- src/core/testcase/testcase_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 4d48f50..f0c2426 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, -- Gitee From ccb408b19992af7d1a068d8c8335d583fa838783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3=E9=B9=8F=E4=BC=9F?= Date: Tue, 24 May 2022 10:05:26 +0000 Subject: [PATCH 3/5] Signed-off-by:mipengwei --- src/core/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/utils.py b/src/core/utils.py index cd6b37c..26525b6 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -129,7 +129,7 @@ def parse_device_name(product_form): with open(device_json_file, 'r') as json_file: json_info = json.load(json_file) - device_name = json_info.get('product_device', None) + device_name = json_info.get('product_device', None) return device_name -- Gitee From 66352a46bc9804a811f2b72dda1eab8bf37f57e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3=E9=B9=8F=E4=BC=9F?= Date: Wed, 25 May 2022 03:22:30 +0000 Subject: [PATCH 4/5] Signed-off-by:mipengwei --- src/core/config/parse_parts_config.py | 4 ++-- src/core/testcase/testcase_manager.py | 20 +++++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/core/config/parse_parts_config.py b/src/core/config/parse_parts_config.py index 1eaa280..33fc51f 100755 --- a/src/core/config/parse_parts_config.py +++ b/src/core/config/parse_parts_config.py @@ -63,9 +63,9 @@ class ParsePartsConfig(object): # open source branch, the part form of all product is "phone" if is_open_source_product(self.productform): - product_data_dic = data_dic.get("phone", None) + product_data_dic = data_dic.get("phone", {}) else: - product_data_dic = data_dic.get(self.productform, None) + product_data_dic = data_dic.get(self.productform, {}) if product_data_dic is None: print("Error: product_data_dic is None.") diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index f0c2426..07f5921 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -108,27 +108,17 @@ class TestCaseManager(object): continue if suffix_name == ".dex": - if suite_file_dictionary.get("DEX", []) and isinstance( - suite_file_dictionary.get("DEX", []), list): - suite_file_dictionary.get("DEX").append(suite_file) + suite_file_dictionary.get("DEX").append(suite_file) elif suffix_name == ".hap": - if suite_file_dictionary.get("JST", []) and isinstance( - suite_file_dictionary.get("JST", []), list): - suite_file_dictionary.get("JST").append(suite_file) + suite_file_dictionary.get("JST").append(suite_file) elif suffix_name == ".py": if not self.check_python_test_file(suite_file): continue - if suite_file_dictionary.get("PYT", []) and isinstance( - suite_file_dictionary.get("PYT", []), list): - suite_file_dictionary.get("PYT").append(suite_file) + suite_file_dictionary.get("PYT").append(suite_file) elif suffix_name == "": - if suite_file_dictionary.get("CXX", []) and isinstance( - suite_file_dictionary.get("CXX", []), list): - suite_file_dictionary.get("CXX").append(suite_file) + suite_file_dictionary.get("CXX").append(suite_file) elif suffix_name == ".bin": - if suite_file_dictionary.get("BIN", []) and isinstance( - suite_file_dictionary.get("BIN", []), list): - suite_file_dictionary.get("BIN").append(suite_file) + suite_file_dictionary.get("BIN").append(suite_file) return suite_file_dictionary -- Gitee From 65363afc9ab354d714b44a6ab3e366c93b5fc8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B1=B3=E9=B9=8F=E4=BC=9F?= Date: Wed, 25 May 2022 06:54:34 +0000 Subject: [PATCH 5/5] Signed-off-by:mipengwei --- libs/benchmark/report/generate_report.py | 7 +++---- libs/fuzzlib/fuzzer_helper.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/benchmark/report/generate_report.py b/libs/benchmark/report/generate_report.py index 67e7332..4d482b6 100644 --- a/libs/benchmark/report/generate_report.py +++ b/libs/benchmark/report/generate_report.py @@ -163,7 +163,7 @@ class BenchmarkReport(object): if sbs_name in system_summary_dic.keys() and testsuit_name in \ system_summary_dic.get(sbs_name, {}).keys(): subsystem_summary_dic = \ - system_summary_dic.get(sbs_name).get(testsuit_name, {}) + system_summary_dic.get(sbs_name).get(testsuit_name) subsystem_summary_dic["children"] += \ self._remove_iterations(mdl_summary_list) else: @@ -187,9 +187,8 @@ class BenchmarkReport(object): self._remove_iterations(mdl_summary_list) self.sbs_mdl_summary_list.append(subsystem_summary_dic) system_summary_dic[sbs_name] = {} - if isinstance(system_summary_dic.get(sbs_name), dict): - system_summary_dic.get(sbs_name)[testsuit_name] = \ - subsystem_summary_dic + 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 53bd9a8..3be2cd3 100644 --- a/libs/fuzzlib/fuzzer_helper.py +++ b/libs/fuzzlib/fuzzer_helper.py @@ -93,7 +93,7 @@ def _get_fuzzer_yaml_config(fuzzer_name): fuzzer_name, "project.yaml") yaml_config = {} - if not os.path.exists(project_yaml_path): + if os.path.exists(project_yaml_path): # log run stdout to fuzzlog dir with open(project_yaml_path) as filehandle: yaml_config = yaml.safe_load(filehandle) -- Gitee