From 8763d60538ca5561cdded3065c49f9c8df85697b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Wed, 31 Jul 2024 01:30:58 +0000 Subject: [PATCH 1/3] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- libs/fuzzlib/tools/run_result.py | 2 +- src/core/command/console.py | 45 +++---- src/core/command/run.py | 210 +++++++++++++++---------------- 3 files changed, 119 insertions(+), 138 deletions(-) diff --git a/libs/fuzzlib/tools/run_result.py b/libs/fuzzlib/tools/run_result.py index 662d6ab..729cb4e 100644 --- a/libs/fuzzlib/tools/run_result.py +++ b/libs/fuzzlib/tools/run_result.py @@ -42,7 +42,7 @@ class RunResult(): self.data = data self.payload = {} - self.crash_info = { + self.crash_info = { "run_times": 0, "log": "", "project": "", diff --git a/src/core/command/console.py b/src/core/command/console.py index 924abbd..3d7f0f7 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -66,6 +66,21 @@ class Console(object): def __init__(self): pass + @staticmethod + def _parse_combination_param(combination_value): + # sample: size:xxx1;exclude-annotation:xxx + parse_result = {} + key_value_pairs = str(combination_value).split(";") + for key_value_pair in key_value_pairs: + key, value = key_value_pair.split(":", 1) + if not value: + raise ParamError("'%s' no value" % key) + value_list = str(value).split(",") + exist_list = parse_result.get(key, []) + exist_list.extend(value_list) + parse_result[key] = exist_list + return parse_result + # 参数解析方法 @classmethod def argument_parser(cls, para_list): @@ -259,21 +274,6 @@ class Console(object): LOG.warning("Parameter parsing systemexit exception.") return options, unparsed, valid_param - - @staticmethod - def _parse_combination_param(combination_value): - # sample: size:xxx1;exclude-annotation:xxx - parse_result = {} - key_value_pairs = str(combination_value).split(";") - for key_value_pair in key_value_pairs: - key, value = key_value_pair.split(":", 1) - if not value: - raise ParamError("'%s' no value" % key) - value_list = str(value).split(",") - exist_list = parse_result.get(key, []) - exist_list.extend(value_list) - parse_result[key] = exist_list - return parse_result @classmethod def _params_post_processing(self, options): @@ -296,21 +296,6 @@ class Console(object): elif param == "-->": para_list[index] = "!%s" % param - @staticmethod - def _parse_combination_param(combination_value): - # sample: size:xxx1;exclude-annotation:xxx - parse_result = {} - key_value_pairs = str(combination_value).split(";") - for key_value_pair in key_value_pairs: - key, value = key_value_pair.split(":", 1) - if not value: - raise ParamError("'%s' no value" % key) - value_list = str(value).split(",") - exist_list = parse_result.get(key, []) - exist_list.extend(value_list) - parse_result[key] = exist_list - return parse_result - @classmethod def _process_command_version(cls, para_list): display_version_info(para_list) diff --git a/src/core/command/run.py b/src/core/command/run.py index b600a30..c2b0c2d 100644 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -47,8 +47,109 @@ LOG = platform_logger("Run") class Run(object): - history_cmd_list = [] - + history_cmd_list = [] + @classmethod + def get_history(self): + return self.history_cmd_list + + @classmethod + def get_target_out_path(cls, product_form): + target_out_path = UserConfigManager().get_test_cases_dir() + if target_out_path == "": + target_out_path = os.path.join( + get_build_output_path(product_form), + "packages", + product_form) + target_out_path = os.path.abspath(target_out_path) + return target_out_path + + @classmethod + def get_tests_out_path(cls, product_form): + testcase_path = UserConfigManager().get_test_cases_dir() + if testcase_path == "": + all_product_list = scan_support_product() + if product_form in all_product_list: + if is_open_source_product(product_form): + testcase_path = os.path.abspath(os.path.join( + get_build_output_path(product_form), + "tests")) + else: + testcase_path = os.path.abspath(os.path.join( + get_build_output_path(product_form), + "tests")) + else: + testcase_path = os.path.join( + get_build_output_path(product_form), "tests") + LOG.info("testcase_path=%s" % testcase_path) + return testcase_path + + @classmethod + def get_xts_tests_out_path(cls, product_form, testtype): + xts_testcase_path = UserConfigManager().get_test_cases_dir() + if xts_testcase_path == "": + xts_testcase_path = os.path.abspath(os.path.join( + get_build_output_path(product_form), + "suites", + testtype[0], + "testcases")) + LOG.info("xts_testcase_path=%s" % xts_testcase_path) + return xts_testcase_path + + @classmethod + def get_external_deps_out_path(cls, product_form): + external_deps_path = os.path.abspath(os.path.join( + get_build_output_path(product_form), + "part_deps_info", + "part_deps_info.json")) + LOG.info("external_deps_path=%s" % external_deps_path) + return external_deps_path + + @classmethod + def get_coverage_outpath(cls, options): + coverage_out_path = "" + if options.coverage: + coverage_out_path = get_build_output_path(options.productform) + if coverage_out_path == "": + coverage_out_path = UserConfigManager().get_user_config( + "coverage").get("outpath", "") + if coverage_out_path == "": + LOG.error("Coverage test: coverage_outpath is empty.") + return coverage_out_path + + @classmethod + def get_part_deps_list(cls, productform, testpart): + #获取预处理部件间依赖的编译结果路径 + external_deps_path = cls.get_external_deps_out_path(productform) + external_deps_path_list = TestCaseManager().get_part_deps_files(external_deps_path, testpart) + return external_deps_path_list + + @classmethod + def _build_test_cases(cls, options): + if options.coverage: + LOG.info("Coverage testing, no need to compile testcases") + return True + + is_build_testcase = UserConfigManager().get_user_config_flag( + "build", "testcase") + project_root_path = sys.source_code_root_path + if is_build_testcase and project_root_path != "": + from core.build.build_manager import BuildManager + build_manager = BuildManager() + return build_manager.build_testcases(project_root_path, options) + else: + return True + + @classmethod + def _check_test_dictionary(cls, test_dictionary): + is_valid_status = False + key_list = sorted(test_dictionary.keys()) + for key in key_list: + file_list = test_dictionary[key] + if len(file_list) > 0: + is_valid_status = True + break + return is_valid_status + def process_command_run(self, command, options): current_raw_cmd = ",".join(list(map(str, options.current_raw_cmd.split(" ")))) if options.coverage and platform.system() != "Windows": @@ -310,111 +411,6 @@ class Run(object): else: print(f"{cov_main_file_path} not exists.") return - - ############################################################## - ############################################################## - - @classmethod - def get_history(self): - return self.history_cmd_list - - @classmethod - def get_target_out_path(cls, product_form): - target_out_path = UserConfigManager().get_test_cases_dir() - if target_out_path == "": - target_out_path = os.path.join( - get_build_output_path(product_form), - "packages", - product_form) - target_out_path = os.path.abspath(target_out_path) - return target_out_path - - @classmethod - def get_tests_out_path(cls, product_form): - testcase_path = UserConfigManager().get_test_cases_dir() - if testcase_path == "": - all_product_list = scan_support_product() - if product_form in all_product_list: - if is_open_source_product(product_form): - testcase_path = os.path.abspath(os.path.join( - get_build_output_path(product_form), - "tests")) - else: - testcase_path = os.path.abspath(os.path.join( - get_build_output_path(product_form), - "tests")) - else: - testcase_path = os.path.join( - get_build_output_path(product_form), "tests") - LOG.info("testcase_path=%s" % testcase_path) - return testcase_path - - @classmethod - def get_xts_tests_out_path(cls, product_form, testtype): - xts_testcase_path = UserConfigManager().get_test_cases_dir() - if xts_testcase_path == "": - xts_testcase_path = os.path.abspath(os.path.join( - get_build_output_path(product_form), - "suites", - testtype[0], - "testcases")) - LOG.info("xts_testcase_path=%s" % xts_testcase_path) - return xts_testcase_path - - @classmethod - def get_external_deps_out_path(cls, product_form): - external_deps_path = os.path.abspath(os.path.join( - get_build_output_path(product_form), - "part_deps_info", - "part_deps_info.json")) - LOG.info("external_deps_path=%s" % external_deps_path) - return external_deps_path - - @classmethod - def get_coverage_outpath(cls, options): - coverage_out_path = "" - if options.coverage: - coverage_out_path = get_build_output_path(options.productform) - if coverage_out_path == "": - coverage_out_path = UserConfigManager().get_user_config( - "coverage").get("outpath", "") - if coverage_out_path == "": - LOG.error("Coverage test: coverage_outpath is empty.") - return coverage_out_path - - @classmethod - def get_part_deps_list(cls, productform, testpart): - #获取预处理部件间依赖的编译结果路径 - external_deps_path = cls.get_external_deps_out_path(productform) - external_deps_path_list = TestCaseManager().get_part_deps_files(external_deps_path, testpart) - return external_deps_path_list - - @classmethod - def _build_test_cases(cls, options): - if options.coverage: - LOG.info("Coverage testing, no need to compile testcases") - return True - - is_build_testcase = UserConfigManager().get_user_config_flag( - "build", "testcase") - project_root_path = sys.source_code_root_path - if is_build_testcase and project_root_path != "": - from core.build.build_manager import BuildManager - build_manager = BuildManager() - return build_manager.build_testcases(project_root_path, options) - else: - return True - - @classmethod - def _check_test_dictionary(cls, test_dictionary): - is_valid_status = False - key_list = sorted(test_dictionary.keys()) - for key in key_list: - file_list = test_dictionary[key] - if len(file_list) > 0: - is_valid_status = True - break - return is_valid_status def get_xts_test_dict(self, options): # 获取XTS测试用例编译结果路径 -- Gitee From 706ad3f8b3cde782e46035da727d9dd1282518b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Wed, 31 Jul 2024 01:36:31 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/command/console.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/command/console.py b/src/core/command/console.py index 3d7f0f7..fc0fea6 100755 --- a/src/core/command/console.py +++ b/src/core/command/console.py @@ -382,21 +382,6 @@ class Console(object): def handler_ctrl_z(self, signalnum, frame): pass - def console(self, args): - """ - Main xDevice console providing user with the interface to interact - """ - EnvironmentManager() - if args is None or len(args) < 2: - self.wizard_dic = show_wizard_mode() - print(self.wizard_dic) - if self._build_version(self.wizard_dic["productform"]): - self._console() - else: - LOG.error("Build version failed, exit test framework.") - else: - self.command_parser(" ".join(args[1:])) - def command_parser(self, args): try: # 将用户输入的指令按空格拆分成字符串数组 @@ -440,6 +425,21 @@ class Console(object): RuntimeError, SystemError, TypeError, ValueError) as exception: LOG.exception(exception, exc_info=False) + def console(self, args): + """ + Main xDevice console providing user with the interface to interact + """ + EnvironmentManager() + if args is None or len(args) < 2: + self.wizard_dic = show_wizard_mode() + print(self.wizard_dic) + if self._build_version(self.wizard_dic["productform"]): + self._console() + else: + LOG.error("Build version failed, exit test framework.") + else: + self.command_parser(" ".join(args[1:])) + # 命令执行总入口 def _console(self): if platform.system() != 'Windows': -- Gitee From 344badc26da06920a116da4ff1b4e5e520b2f00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9B=BD=E8=BE=89?= Date: Wed, 31 Jul 2024 02:19:36 +0000 Subject: [PATCH 3/3] =?UTF-8?q?Signed-off-by:=20=E9=BB=84=E5=9B=BD?= =?UTF-8?q?=E8=BE=89=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 黄国辉 --- src/core/command/run.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/command/run.py b/src/core/command/run.py index c2b0c2d..0c1e8ba 100644 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -48,6 +48,7 @@ LOG = platform_logger("Run") class Run(object): history_cmd_list = [] + @classmethod def get_history(self): return self.history_cmd_list -- Gitee