diff --git a/libs/fuzzlib/tools/run_result.py b/libs/fuzzlib/tools/run_result.py index 662d6ab4e218d36e613be129a21e4d4e09468fcb..729cb4e25dccf4f92722fc9a94a9a1e4969787af 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 924abbd1d9a11a3faa27098680e31868fe047e6f..fc0fea6994f668cb981ededc7ab29fb809af5e46 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) @@ -397,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: # 将用户输入的指令按空格拆分成字符串数组 @@ -455,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': diff --git a/src/core/command/run.py b/src/core/command/run.py index b600a304fc082c94893108b1d9ea49e4f311e99e..0c1e8bac378935318a2391629298824b07f44ce9 100644 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -47,8 +47,110 @@ 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 +412,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测试用例编译结果路径