diff --git a/src/core/build/build_manager.py b/src/core/build/build_manager.py index dc0c6b4815135fc98da4a34925a0600e540c8b8a..b0cf72d8e8fbeafcfa863859eee13c2c1c009300 100755 --- a/src/core/build/build_manager.py +++ b/src/core/build/build_manager.py @@ -170,6 +170,7 @@ class BuildManager(object): LOG.info("partname_list = %s" % str(param.partname_list)) LOG.info("testmodule = %s" % param.testmodule) LOG.info("testsuit = %s" % param.testsuit) + LOG.info("testcase = %s" % param.testcase) LOG.info("--------------------------------------------------") LOG.info("") diff --git a/src/core/build/build_testcases.py b/src/core/build/build_testcases.py index d3e8730d678dd213223e087128b4e2078e841bf0..95351c0061b4cacc29bed9027b9d36c293fceb4e 100755 --- a/src/core/build/build_testcases.py +++ b/src/core/build/build_testcases.py @@ -203,14 +203,17 @@ class BuildTestcases(object): build_result = False acts_build_command = [] current_path = os.getcwd() - # acts_rootpath = ~/OpenHarmony/test/xts/acts + # 路径 acts_rootpath = ~/OpenHarmony/test/xts/acts os.chdir(self.xts_project_rootpath) acts_build_command.append(BUILD_PRODUCT_NAME % para.productform) acts_build_command.append("system_size=standard") if len(para.subsystem) > 0: acts_build_command.append(BUILD_TARGET_SUBSYSTEM % para.subsystem[0]) - if para.testsuit != "": + if para.testsuit != "" and len(para.subsystem) > 0: acts_build_command.append(BUILD_TARGET_SUITE % para.testsuit) + elif para.testsuit != "" and len(para.subsystem) == 0: + LOG.error("Please specify subsystem.") + return if os.path.exists(BUILD_FILEPATH): build_command = [BUILD_FILEPATH] build_command.extend(acts_build_command) diff --git a/src/core/command/display.py b/src/core/command/display.py index e867c0afe1550c31414b2cffdd05db51bb71cb51..15d0269b392598b5bddce7dbf3ab0ae48916e376 100755 --- a/src/core/command/display.py +++ b/src/core/command/display.py @@ -45,15 +45,16 @@ CMD_KEY_PRODUCTLIST = "productlist" # 测试用例类型 # 1. UT -# 2. MST -# 3. ST -# 4. PERF -# 5. SEC -# 6. FUZZ -# 7. RELI -# 8. DST -# 9. BENCHMARK -# 10. ALL +# 2. ACTS +# 3. MST +# 4. ST +# 5. PERF +# 6. SEC +# 7. FUZZ +# 8. RELI +# 9. DST +# 10. BENCHMARK +# 11. ALL CMD_KEY_TYPELIST = "typelist" # 子系统名称列表 @@ -62,6 +63,9 @@ CMD_KEY_SUBSYSTEMLIST = "subsystemlist" # 子系统下的部件名 CMD_KEY_PARTLIST = "partlist" +# acts子系统名称列表 +CMD_KEY_SUBSYSTEMLIST_ACTS = "actssubsystemlist" + TOOL_VERSION_INFO = """Welcome to DeveloperTest V1.0.0. """ @@ -179,19 +183,20 @@ def select_user_input(data_list): sys.exit(0) return select_item_value, select_item_index + # 选择productform def select_productform(): select_value = "phone" - # scan_support_product() = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568] + # 列表注释 scan_support_product() = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568] scan_product_list = scan_support_product() # 从framework_config.xml里取productform节点的value:ipcamera_hispark_aries、ipcamera_hispark_taurus、wifiiot_hispark_pegasus config_product_list = \ FrameworkConfigManager().get_framework_config("productform") - # productform_list = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568, - # ipcamera_hispark_aries、ipcamera_hispark_taurus、wifiiot_hispark_pegasus] + # 列表注释 productform_list = [DAYU,Hi3516,ohos_arm64,ohos_sdk,rk3568, + # 列表注释 ipcamera_hispark_aries、ipcamera_hispark_taurus、wifiiot_hispark_pegasus] productform_list = scan_product_list + config_product_list if len(productform_list) != 0: @@ -275,6 +280,7 @@ def show_testtype_list(): else: print("No category specified.") + # 从OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里的subsystem_infos中subsystem_infos下获取subsystemlist def show_subsystem_list(product_form): print("List of currently supported subsystem names:") @@ -287,11 +293,25 @@ def show_subsystem_list(product_form): for index, element in enumerate(subsystem_name_list): print(" %d. %s" % (index + 1, element)) + +def show_acts_subsystem_list(): + print("List of currently supported acts subsystem names:") + sub_list = ['global', 'security', 'useriam', 'multimedia', 'appexecfwk', 'account', 'communication', 'notification', + 'ability', 'miscservices', 'powermgr', 'startup', 'sensor', 'distributeddatamgr', 'update', 'graphic','arkui', + 'storage', 'compileruntime', 'usb', 'multimodalinput', 'resourceschedule', + 'telephony', 'hiviewdfx', 'location', 'barrierfree', 'customization'] + sub_list.sort() + for index, element in enumerate(sub_list): + print(" %d. %s" % (index + 1, element.strip())) + print("end") + + # 从OpenHarmony/out/rk3568/build_configs/infos_for_testfwk.json里的subsystem_infos中subsystem_infos下获取partlist def show_partname_list(product_form): print("List of currently supported part names:") parser = ParsePartsConfig(product_form) subsystem_name_list = parser.get_subsystem_name_list() + if len(subsystem_name_list) == 0: return @@ -304,6 +324,7 @@ def show_partname_list(product_form): for index, element in enumerate(part_name_list): print(" %d. %s" % (index + 1, element)) + def display_help_command_info(command): if command == ToolCommandType.TOOLCMD_KEY_SHOW: print(SUPPORT_COMMAND_SHOW) @@ -326,6 +347,8 @@ def display_show_command_info(command, product_form="phone"): show_subsystem_list(product_form) elif command == CMD_KEY_PARTLIST: show_partname_list(product_form) + elif command == CMD_KEY_SUBSYSTEMLIST_ACTS: + show_acts_subsystem_list() else: print("This command is not support.") diff --git a/src/core/command/run.py b/src/core/command/run.py index f662c012f3ed67a8a6de0cc5a249b443beeb671b..4ed923e6f41960c71506710c6d153beb5d30f3eb 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -141,8 +141,6 @@ class Run(object): options.testcases_path = options.target_outpath options.resource_path = os.path.abspath(os.path.join( sys.framework_root_dir, "..", "resource")) - print(options.testcases_path) - print(options.resource_path) if options.productform.find("wifiiot") != -1: scheduler.update_test_type_in_source(".bin", DeviceTestType.ctest_lite) diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index 748ad61632b04c0b5643757c0b623b37c517aff8..448d85dd63613d2cf5c907906b9f114312e4763e 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -29,8 +29,10 @@ LOG = platform_logger("config_manager") # 变量注释 CONFIG_PATH = OpenHarmony/test/developertest/config CONFIG_PATH = os.path.join(sys.framework_res_dir, "config") + # framework_config.xml class FrameworkConfigManager(object): + def __init__(self, filepath=""): if filepath == "": @@ -40,9 +42,10 @@ class FrameworkConfigManager(object): else: self.filepath = filepath - # 获取framework_config.xml中所有name的value,返回列表 def get_framework_config(self, target_name): + # 获取framework_config.xml中所有name的value,返回列表 data_list = [] + try: if os.path.exists(self.filepath): @@ -125,6 +128,7 @@ class FilterConfigManager(object): def get_filter_config_path(self): return self.filepath + # 这里的filepath不存在 class ResourceConfigManager(object): def __init__(self, filepath=""): @@ -307,6 +311,7 @@ class BuildConfigManager(object): def get_build_path(self): return self.filepath + class FuzzerConfigManager(object): def __init__(self, config_path=""): if config_path == "": diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 791b97f826813777224a788493263110e38f20a6..0c7959589742eb6cec19ee72bfa25df2686ec70d 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -99,6 +99,8 @@ class DisplayOutputReceiver: class GTestConst(object): exec_para_filter = "--gtest_filter" exec_para_level = "--gtest_testsize" + exec_acts_para_filter = "--jstest_filter" + exec_acts_para_level = "--jstest_testsize" def get_device_log_file(report_path, serial=None, log_name="device_log"): @@ -671,12 +673,9 @@ class JSUnitTestDriver(IDriver): timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) else: timeout = ResourceManager.get_nodeattrib_data(resource_data_dic) - resource_manager.process_preparer_data(resource_data_dic, resource_dir, - self.config.device) - + resource_manager.process_preparer_data(resource_data_dic, resource_dir,self.config.device) main_result = self._install_hap(suite_file) result = ResultManager(suite_file, self.config) - if main_result: self._execute_hapfile_jsunittest() try: @@ -686,8 +685,7 @@ class JSUnitTestDriver(IDriver): if timeout: actiontime = timeout times = 1 - device_log_file_open = os.open(device_log_file, os.O_RDONLY, - stat.S_IWUSR | stat.S_IRUSR) + device_log_file_open = os.open(device_log_file, os.O_RDONLY,stat.S_IWUSR | stat.S_IRUSR) with os.fdopen(device_log_file_open, "r", encoding='utf-8') \ as file_read_pipe: for i in range(0, times): @@ -704,7 +702,6 @@ class JSUnitTestDriver(IDriver): break if int(time.time()) - start_time > 5: break - finally: _lock_screen(self.config.device) self._uninstall_hap(self.package_name) @@ -712,8 +709,7 @@ class JSUnitTestDriver(IDriver): self.result = result.get_test_results("Error: install hap failed") LOG.error("Error: install hap failed") - resource_manager.process_cleaner_data(resource_data_dic, resource_dir, - self.config.device) + resource_manager.process_cleaner_data(resource_data_dic, resource_dir,self.config.device) def generate_console_output(self, device_log_file, request): result_message = self.read_device_log(device_log_file) @@ -808,6 +804,28 @@ class JSUnitTestDriver(IDriver): _sleep_according_to_result(return_message) return return_message + @staticmethod + def _get_acts_test_para(testcase, + testlevel, + testtype, + target_test_path, + suite_file, + filename): + if "actstest" == testtype[0]: + test_para = (" --actstest_out_format=json" + " --actstest_out=%s%s.json") % ( + target_test_path, filename) + return test_para + + if "" != testcase and "" == testlevel: + test_para = "%s=%s" % (GTestConst.exec_acts_para_filter, testcase) + elif "" == testcase and "" != testlevel: + level_para = get_level_para_string(testlevel) + test_para = "%s=%s" % (GTestConst.exec_acts_para_level, level_para) + else: + test_para = "" + return test_para + @classmethod def _get_json_shell_timeout(cls, json_filepath): test_timeout = 300 @@ -824,12 +842,14 @@ class JSUnitTestDriver(IDriver): return test_timeout except JSONDecodeError: return test_timeout + finally: + print(" get json shell timeout finally") + @staticmethod def _get_package_and_ability_name(hap_filepath): package_name = "" ability_name = "" - if os.path.exists(hap_filepath): filename = os.path.basename(hap_filepath) @@ -863,7 +883,6 @@ class JSUnitTestDriver(IDriver): package_name = profile.get("package") if not package_name: continue - abilities = profile.get("abilities") for abilitie in abilities: abilities_name = abilitie.get("name") @@ -880,5 +899,4 @@ class JSUnitTestDriver(IDriver): shutil.rmtree(hap_bak_path) else: print("file %s not exist" % hap_filepath) - return package_name, ability_name diff --git a/src/core/testcase/testcase_manager.py b/src/core/testcase/testcase_manager.py index 9e6406dfaeeaaa206e76066db962d58072dffa31..1bec1ddca810730086c133cdb22f9f408764682d 100755 --- a/src/core/testcase/testcase_manager.py +++ b/src/core/testcase/testcase_manager.py @@ -189,6 +189,7 @@ class TestCaseManager(object): break return is_valid_status + @classmethod def check_python_test_file(cls, suite_file): if suite_file.endswith(".py"): @@ -197,6 +198,7 @@ class TestCaseManager(object): return True return False + @classmethod def check_hap_test_file(cls, hap_file_path): try: @@ -221,3 +223,5 @@ class TestCaseManager(object): return False except JSONDecodeError: return False + finally: + print(" check hap test file finally") diff --git a/src/core/utils.py b/src/core/utils.py index 21ad7d2d16cce07ebfc24ab340ec429fb891ddba..49a98154e5c390387442cca3a5a35e13c94bcd17 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -49,6 +49,7 @@ def get_file_list(find_path, postfix=""): file_list.append(file_name) return file_list + # 获取目录下每一个文件,并放到一个列表里 def get_file_list_by_postfix(path, postfix=""): file_list = [] @@ -102,7 +103,7 @@ def get_build_output_path(product_form): def scan_support_product(): # scan standard and large system info - # product_form_dir = OpenHarmony/productdefine/common/products/ + # 路径注释 product_form_dir = OpenHarmony/productdefine/common/products/ product_form_dir = os.path.join(sys.source_code_root_path, "productdefine", "common",