From c4a4cf245eb9db8fc6ae46fe74cd8f77febf1fa2 Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Mon, 5 Sep 2022 02:44:38 +0000 Subject: [PATCH 1/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- libs/fuzzlib/tools/colored.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/fuzzlib/tools/colored.py b/libs/fuzzlib/tools/colored.py index fae3edf..63a4887 100644 --- a/libs/fuzzlib/tools/colored.py +++ b/libs/fuzzlib/tools/colored.py @@ -83,7 +83,7 @@ class Colored(object): "run.log" ) with open(run_log, 'ab') as f: - f.write(msg+"\n") + f.write(msg + "\n") def color_str(self, color, s, tag=None): -- Gitee From c200a23a4fa0cd0b769b586be83034ecf97c415e Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Mon, 5 Sep 2022 02:59:00 +0000 Subject: [PATCH 2/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- aw/python/distributed/common/common.py | 2 +- libs/fuzzlib/fuzzer_helper.py | 10 +++++----- src/core/config/config_manager.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aw/python/distributed/common/common.py b/aw/python/distributed/common/common.py index 45d7ea2..e0c087b 100755 --- a/aw/python/distributed/common/common.py +++ b/aw/python/distributed/common/common.py @@ -61,7 +61,7 @@ def get_resource_dir(phone_res_dir, device_type_name): pos = phone_res_dir.find(os.sep + "tests" + os.sep) if pos != -1: prefix_path = phone_res_dir[:pos] - suffix_path = phone_res_dir[pos+1:] + suffix_path = phone_res_dir[pos + 1:] prefix_path = os.path.abspath(os.path.dirname(prefix_path)) current_dir = os.path.join(prefix_path, product_form_name, suffix_path) diff --git a/libs/fuzzlib/fuzzer_helper.py b/libs/fuzzlib/fuzzer_helper.py index b8c6217..aba2656 100644 --- a/libs/fuzzlib/fuzzer_helper.py +++ b/libs/fuzzlib/fuzzer_helper.py @@ -27,6 +27,8 @@ import pipes import traceback import time import copy +import shutil +from pprint import pprint from tools.colored import Colored from tools.templates import GN_ENTRY_TEMPLATE @@ -34,8 +36,6 @@ from tools.templates import PROJECT_GN_TEMPLATE from tools.templates import PROJECT_DEMO_TEMPLATE from tools.templates import PROJECT_HEADER_TEMPLATE from tools.templates import PROJECT_XML_TEMPLATE -import shutil -from pprint import pprint from tools.run_result import RunResult CURRENT_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -93,7 +93,7 @@ def _get_fuzzer_yaml_config(fuzzer_name): fuzzer_name, "project.yaml") if not os.path.exists(project_yaml_path): - return None + return #log run stdout to fuzzlog dir with open(project_yaml_path) as filehandle: yaml_config = yaml.safe_load(filehandle) @@ -198,8 +198,8 @@ def make(args, stdout=None): ret = subprocess.check_call(build_script, cwd=SOURCE_ROOT_DIR) return ret except subprocess.CalledProcessError: - print("*"*50) - print("*"*50) + print("*" * 50) + print("*" * 50) print( 'fuzzers {} build failed.'.format(args.project_name), file=sys.stdout diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index 5b45acb..7f05543 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -239,12 +239,12 @@ class UserConfigManager(object): node = root.find(target_name) if not node: - return None + return if sub_target != "": node = node.find(sub_target) if not node: - return None + return for sub in node: if sub.text is None: -- Gitee From 39952c6ed8984440009f79880f35a98e8e53e4a2 Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Mon, 5 Sep 2022 02:59:21 +0000 Subject: [PATCH 3/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- src/core/command/run.py | 11 ++++++----- src/core/config/parse_parts_config.py | 3 ++- src/core/driver/lite_driver.py | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/core/command/run.py b/src/core/command/run.py index 2aafa04..392281e 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -108,7 +108,8 @@ class Run(object): print("The latest command history is: %d" % len(self.history_cmd_list)) for index in range(0, len(self.history_cmd_list)): cmd_record = self.history_cmd_list[index] - print("%d. [%s]-[%s]::[%s]" % (index+1, cmd_record["time"], cmd_record["raw_cmd"], cmd_record["result"])) + print("%d. [%s]-[%s]::[%s]" % (index+1, cmd_record["time"], + cmd_record["raw_cmd"], cmd_record["result"])) return #重新运行历史里的一条命令 if options.runhistory > 0: @@ -116,7 +117,7 @@ class Run(object): if options.runhistory > 10 or options.runhistory > len(self.history_cmd_list): print("input history command[%d] out of range:", options.runhistory) return - cmd_record = self.history_cmd_list[options.runhistory-1] + cmd_record = self.history_cmd_list[options.runhistory - 1] print("run history command:", cmd_record["raw_cmd"]) need_record_history = False command = cmd_record["command"] @@ -252,9 +253,9 @@ class Run(object): with open(latest_report_path) as report_file: for report_line in report_file: if "testsuites name=\"summary_report\"" in report_line: - result = report_line.replace("\n","") - result = result.replace("","") + result = report_line.replace("\n", "") + result = result.replace("", "") cmd_record["result"] = result break if len(self.history_cmd_list) >= 10: diff --git a/src/core/config/parse_parts_config.py b/src/core/config/parse_parts_config.py index 107932b..f366491 100755 --- a/src/core/config/parse_parts_config.py +++ b/src/core/config/parse_parts_config.py @@ -38,7 +38,8 @@ class ParsePartsConfig(object): # 获取user_config.xml文件中的配置的(编译好的测试用例地址) testcase_dir = manager.get_test_cases_dir() - # 如果没有在developtertest/config/user_config里配置test_cases路径,就到OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里查找 + # 如果没有在developtertest/config/user_config里配置test_cases路径, + # 就到OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里查找 if testcase_dir == "": if sys.source_code_root_path != "": config_filepath = os.path.join( diff --git a/src/core/driver/lite_driver.py b/src/core/driver/lite_driver.py index b2764fa..603f2e2 100755 --- a/src/core/driver/lite_driver.py +++ b/src/core/driver/lite_driver.py @@ -81,7 +81,7 @@ class LiteUnitTest(IDriver): def __check_failed__(self, msg): self.log.error("check failed {}".format(msg)) - return None + return def __check_environment__(self, device_options): pass @@ -278,7 +278,7 @@ class LiteUnitTest(IDriver): "ls /%s" % \ UserConfigManager().get_user_config("NFS").get("board_dir") start_time = time.time() - while time.time()-start_time < timeout: + while time.time() - start_time < timeout: result, _, _ = self.lite_device.execute_command_with_timeout( command=ls_command, case_type=DeviceTestType.cpp_test_lite, timeout=5, receiver=None) @@ -292,14 +292,14 @@ class LiteUnitTest(IDriver): show help info. """ self.log.info("this is test driver for cpp test") - return None + return def show_driver_info(self): """ show driver info. """ self.log.info("this is test driver for cpp test") - return None + return def __result__(self): pass -- Gitee From 861338fc875d92800e2513255311a11ee51a1aa5 Mon Sep 17 00:00:00 2001 From: yuyan0428 Date: Mon, 5 Sep 2022 02:59:29 +0000 Subject: [PATCH 4/4] Signed-off-by: yuyan0428 Signed-off-by: yuyan0428 --- src/core/build/select_targets.py | 3 ++- src/core/testcase/testcase_manager.py | 16 ++++++++-------- src/core/utils.py | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/core/build/select_targets.py b/src/core/build/select_targets.py index f6563fa..a411232 100755 --- a/src/core/build/select_targets.py +++ b/src/core/build/select_targets.py @@ -108,7 +108,8 @@ class SelectTargets(object): def _get_target_list_by_type(self, productform, typelist): target_list = [] # 获取所有部件编译输出信息列表:[{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1]}] - # 或者{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1,~/OpenHarmony/out/rk3568/编译目录build_out_dir/module_list_files/部件名1]} + # 或者{“部件名1”:[~/OpenHarmony/out/rk3568/module_list_files/部件名1, + # ~/OpenHarmony/out/rk3568/编译目录build_out_dir/module_list_files/部件名1]} part_path_dic = self._get_part_path_data(productform) for item in part_path_dic: part_path_list = part_path_dic.get(item) diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index e41ef83..a95b73a 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -66,7 +66,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, @@ -118,17 +118,17 @@ class TestCaseManager(object): continue if suffix_name == ".dex": - suite_file_dictionary["DEX"].append(suite_file) + suite_file_dictionary.get("DEX").append(suite_file) elif suffix_name == ".hap": - suite_file_dictionary["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 - suite_file_dictionary["PYT"].append(suite_file) + suite_file_dictionary.get("PYT").append(suite_file) elif suffix_name == "": - suite_file_dictionary["CXX"].append(suite_file) + suite_file_dictionary.get("CXX").append(suite_file) elif suffix_name == ".bin": - suite_file_dictionary["BIN"].append(suite_file) + suite_file_dictionary.get("BIN").append(suite_file) return suite_file_dictionary @@ -159,9 +159,9 @@ class TestCaseManager(object): if not self.check_hap_test_file(acts_suite_file): continue if self.get_hap_test_driver(acts_suite_file) == "OHJSUnitTest": - acts_suit_file_dic["OHJST"].append(acts_suite_file) + acts_suit_file_dic.get("OHJST").append(acts_suite_file) if self.get_hap_test_driver(acts_suite_file) == "JSUnitTest": - acts_suit_file_dic["JST"].append(acts_suite_file) + acts_suit_file_dic.get("JST").append(acts_suite_file) else: LOG.error("acts %s is not exist." % acts_test_case_path) return acts_suit_file_dic diff --git a/src/core/utils.py b/src/core/utils.py index 9adb069..33d84b7 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -131,12 +131,12 @@ def parse_device_name(product_form): "productdefine", "common", "products", "{}.json".format(product_form)) if not os.path.exists(device_json_file): - return None + return with open(device_json_file, 'r') as json_file: json_info = json.load(json_file) if not json_info: - return None + return device_name = json_info.get('product_device') return device_name @@ -197,7 +197,8 @@ def is_lite_product(product_form, code_root_path): return True if len(product_form.split("_")) >= 3 else False else: product_list = FrameworkConfigManager().get_framework_config("productform") - if (product_form in scan_support_product() or product_form in product_list) and product_form.find("wifiiot") == -1: + if (product_form in scan_support_product() or product_form in product_list) + and product_form.find("wifiiot") == -1: return False else: return True -- Gitee