From b941689b179ace74980a054fb5e7761a9289d7b9 Mon Sep 17 00:00:00 2001 From: caojiale1 Date: Thu, 18 May 2023 14:54:15 +0800 Subject: [PATCH 1/4] Signed-off-by caojiale1 caojiale1@huawei.com Signed-off-by: caojiale1 --- .../push_coverage_so/push_coverage.py | 45 ++++- localCoverage/resident_service/init_gcov.py | 183 ++++++++++++++---- .../resident_service/pull_service_gcda.py | 26 ++- localCoverage/utils.py | 59 +++++- src/core/driver/drivers.py | 41 +++- 5 files changed, 289 insertions(+), 65 deletions(-) diff --git a/localCoverage/push_coverage_so/push_coverage.py b/localCoverage/push_coverage_so/push_coverage.py index 39d4c56..e224591 100644 --- a/localCoverage/push_coverage_so/push_coverage.py +++ b/localCoverage/push_coverage_so/push_coverage.py @@ -25,6 +25,23 @@ def _init_sys_config(): sys.path.insert(0, sys.localcoverage_path) +def get_subsystem_name(partname: str) -> str: + """ + 获取部件所属的子系统名 + :param partname: + :return: 子系统名 + """ + parts_info_json = os.path.join(out_path, "build_configs", "parts_info", "part_subsystem.json") + if not os.path.exists(parts_info_json): + logger("{} not exists.".format(parts_info_json), "ERROR") + return "" + json_obj = json_parse(parts_info_json) + if json_obj: + if partname not in json_obj: + logger("{} part not exist in {}".format(partname, parts_info_json), "ERROR") + return "" + return json_obj[partname] + return "" def find_part_so_dest_path(test_part: str) -> str: """ 获取指定部件的obj目录 @@ -74,7 +91,7 @@ def find_subsystem_so_dest_path(sub_system: str) -> list: return [] -def find_so_source_dest(path: str) -> dict: +def find_so_source_dest(path: str, subsystem_name: str) -> dict: """ 获取so和设备里所在目录的对应关系 :param path: 子系统obj目录 @@ -89,12 +106,19 @@ def find_so_source_dest(path: str) -> dict: for j in json_list: json_obj = json_parse(j) + if "subsystem_name" not in json_obj: + logger("subsystem_name not in {}".format(j), "INFO") + continue + if json_obj["subsystem_name"] != subsystem_name: + logger("{} != {}. No need to deal.".format(json_obj["subsystem_name"], subsystem_name), "INFO") + continue if "source" not in json_obj or "dest" not in json_obj: logger("{} json file error.".format(j), "ERROR") return {} - if json_obj["source"].endswith(".so"): - so_dict[json_obj["source"]] = json_obj["dest"] + source_path = os.path.join(out_path, json_obj["source"]) + if is_elffile(source_path): + so_dict[source_path] = json_obj["dest"] return so_dict @@ -112,13 +136,12 @@ def push_coverage_so(so_dict: dict): cmd = "shell mount -o rw,remount /" hdc_command(device_ip, device_port, device, cmd) for source_path, dest_paths in so_dict.items(): - full_source = os.path.join(out_path, source_path) - if not os.path.exists(full_source): - logger("{} not exist.".format(full_source), "ERROR") + if not os.path.exists(source_path): + logger("{} not exist.".format(source_path), "ERROR") continue for dest_path in dest_paths: full_dest = os.path.join("/", dest_path) - command = "file send {} {}".format(full_source, full_dest) + command = "file send {} {}".format(source_path, full_dest) hdc_command(device_ip, device_port, device, command) @@ -127,7 +150,8 @@ if __name__ == "__main__": _init_sys_config() from localCoverage.resident_service.public_method import get_config_ip, get_sn_list - from localCoverage.utils import get_product_name, hdc_command, tree_find_file_endswith, json_parse, logger + from localCoverage.utils import get_product_name, hdc_command, tree_find_file_endswith,\ + json_parse, logger, is_elffile root_path = current_path.split("/test/testfwk/developer_test")[0] out_path = os.path.join(root_path, "out", get_product_name(root_path)) @@ -152,7 +176,8 @@ if __name__ == "__main__": testpart_list.append(param.strip("[").strip("]").strip(",")) for testpart in testpart_list: json_path_list = find_part_so_dest_path(testpart) - source_dest_dict = find_so_source_dest(json_path_list) + subsystem = get_subsystem_name(testpart) + source_dest_dict = find_so_source_dest(json_path_list, subsystem) push_coverage_so(source_dest_dict) else: for param in param_list: @@ -162,5 +187,5 @@ if __name__ == "__main__": subsystem = subsystem_list[0] json_path_list = find_subsystem_so_dest_path(subsystem) for json_path in json_path_list: - source_dest_dict = find_so_source_dest(json_path) + source_dest_dict = find_so_source_dest(json_path, subsystem) push_coverage_so(source_dest_dict) diff --git a/localCoverage/resident_service/init_gcov.py b/localCoverage/resident_service/init_gcov.py index 10c0c8a..3a25e87 100644 --- a/localCoverage/resident_service/init_gcov.py +++ b/localCoverage/resident_service/init_gcov.py @@ -21,7 +21,7 @@ import subprocess import json import sys import time - +import xml.etree.ElementTree as ET from public_method import get_server_dict, get_config_ip, get_sn_list @@ -106,46 +106,148 @@ def modify_faultloggerd_file(developer_path, hdc_str): return -def split_foundation_services(developer_path, system_info_dict, home_path, hdc_str): +def modify_foundation_xml(serv, config_path, origin_xml) -> str: + """ + 修改foundation.xml文件,删去拆分的进程相关 + :param serv: 拆分进程 + :param config_path: 配置文件路径 + :param origin_xml: 原foundation.xml + :return: 修改后foundation.xml路径 + """ + lib_list = FoundationServer.lib_dict + + tree = ET.parse(origin_xml) + root = tree.getroot() + loadlibs = root.find("loadlibs") + + for lib in lib_list: + for sa in root.findall('systemability'): + if lib in sa.find('libpath').text: + root.remove(sa) + for ll in loadlibs.findall('libpath'): + if lib in ll.text: + loadlibs.remove(ll) + + tree.write(os.path.join(config_path, 'foundation.xml'), encoding='utf-8', xml_declaration=True) + return os.path.join(config_path, 'foundation.xml') + + +def create_service_xml(serv, config_path, origin_xml) -> str: + """ + 创建进程xml + :param serv: 进程名 + :param config_path:配置文件所在目录 + :param origin_xml: 原foundation.xml + :return: xml文件路径 + """ + lib_list = FoundationServer.lib_dict + + tree = ET.parse(origin_xml) + root = tree.getroot() + loadlibs = root.find("loadlibs") + + for lib in lib_list: + for sa in root.findall('systemability'): + if lib not in sa.find('libpath').text: + root.remove(sa) + for lp in loadlibs.findall('libpath'): + if lib not in lp.text: + loadlibs.remove(lp) + + tree.write(os.path.join(config_path, '{}.xml'.format(serv)), encoding='utf-8', xml_declaration=True) + return os.path.join(config_path, '{}.xml'.format(serv)) + + +def create_service_cfg(serv, config_path, origin_cfg) -> str: + """ + 创建进程cfg文件 + :param serv: 进程名 + :param config_path:配置文件所在目录 + :param origin_cfg: 原foundation.cfg + :return: cfg文件路径 + """ + with open(origin_cfg, "r") as jf: + json_obj = json.load(jf) + json_obj["jobs"][0]["name"] = "services:{}".format("wms") + + json_obj["services"][0]["name"] = "services:{}".format("wms") + + path_list = json_obj["services"][0]["path"] + path_list.remove("/system/profile/foundation.xml") + path_list.append("/system/profile/{}.xml".format(serv)) + json_obj["services"][0]["path"] = path_list + + json_obj["services"][0]["jobs"]["on-start"] = "services:{}".format("wms") + + cfg_path = os.path.join(config_path, "{}.cfg".format(serv)) + with open(cfg_path, 'w') as r: + json.dump(json_obj, r, indent=4) + return cfg_path + + +def remove_configs(config_path): + """ + 清理配置文件目录下的xml和cfg文件 + :param config_path: 配置文件目录 + :return: + """ + logger("Clear xml and cfg...", "INFO") + + file_list = os.listdir(config_path) + for file in file_list: + if file.endswith(".xml"): + os.remove(os.path.join(config_path, file)) + logger("remove {}".format(os.path.join(config_path, file)), "INFO") + if file.endswith(".cfg"): + os.remove(os.path.join(config_path, file)) + logger("remove {}".format(os.path.join(config_path, file)), "INFO") + + +def split_foundation_services(developer_path, system_info_dict, home_path, hdc_dict): """ foundation.xml、XXX.xml文件推送到 /system/profile XXX.cfg文件推送到/etc/init/ reboot设备,可以将服务从foundation中拆分出来,成为一个独立服务进程 """ - resident_service_path = os.path.join( - developer_path, "localCoverage/resident_service") - config_path = os.path.join(resident_service_path, "config") - restores_path = os.path.join( - resident_service_path, "resources", "restores_environment") - xml_restores_path = os.path.join(restores_path, "foundation.xml") - - if not os.path.exists(xml_restores_path): - print("%s file recv /system/profile/foundation.xml %s" % (hdc_str, restores_path)) - coverage_command("%s file recv /system/profile/foundation.xml %s" % (hdc_str, restores_path)) - - # 推送xml数据 - for key, value_list in system_info_dict.items(): + config_path = os.path.join(developer_path, "localCoverage", "resident_service") + remove_configs(config_path) + + device_ip = hdc_dict["device_ip"] + hdc_port = hdc_dict["device_port"] + device_sn = hdc_dict["device_sn_str"] + + hdc_command(device_ip, hdc_port, device_sn, "file recv /system/profile/foundation.xml {}".format(config_path)) + hdc_command(device_ip, hdc_port, device_sn, "file recv /etc/init/foundation.cfg {}".format(config_path)) + + if os.path.exists(os.path.join(config_path, "foundation.xml")): + origin_xml = os.path.join(config_path, "foundation_origin.xml") + os.rename(os.path.join(config_path, "foundation.xml"), origin_xml) + else: + logger("{} not exist, Cannot modify.".format(os.path.join(config_path, "foundation.xml")), "ERROR") + return + + if os.path.exists(os.path.join(config_path, "foundation.cfg")): + origin_cfg = os.path.join(config_path, "foundation_origin.cfg") + os.rename(os.path.join(config_path, "foundation.cfg"), origin_cfg) + else: + logger("{} not exist, Cannot modify.".format(os.path.join(config_path, "foundation.cfg")), "ERROR") + return + + foundation_process_list = FoundationServer.lib_dict.keys() + + # 推送配置文件 + for _, value_list in system_info_dict.items(): for process_str in value_list: - foundation_xml_path = os.path.join(config_path, process_str, "foundation.xml") - print("%s shell mount -o rw,remount /" % hdc_str) - coverage_command("%s shell mount -o rw,remount /" % hdc_str) - if os.path.exists(foundation_xml_path): - coverage_command("%s shell rm -rf /lost+found" % hdc_str) - coverage_command("%s shell rm -rf /log" % hdc_str) - coverage_command("%s shell rm -rf %s" % (hdc_str, home_path)) - print("%s file send %s %s" % (hdc_str, foundation_xml_path, "/system/profile/")) - coverage_command("%s file send %s %s" % ( - hdc_str, foundation_xml_path, "/system/profile/")) - - process_xml_path = os.path.join(config_path, process_str, f"{process_str}.xml") - print("%s file send %s %s" % (hdc_str, process_xml_path, "/system/profile/")) - coverage_command("%s file send %s %s" % ( - hdc_str, process_xml_path, "/system/profile/")) - - process_cfg_path = os.path.join(config_path, process_str, f"{process_str}.cfg") - print("%s file send %s %s" % (hdc_str, process_cfg_path, "/etc/init/")) - coverage_command("%s file send %s %s" % ( - hdc_str, process_cfg_path, "/etc/init/")) + if process_str in foundation_process_list: + foundation_xml = modify_foundation_xml(process_str, config_path, origin_xml) + service_xml = create_service_xml(process_str, config_path, origin_xml) + service_cfg = create_service_cfg(process_str, config_path, origin_cfg) + + hdc_command(device_ip, hdc_port, device_sn, "shell rm -rf {}".format(home_path)) + hdc_command(device_ip, hdc_port, device_sn, "file send {} /system/profile/".format(foundation_xml)) + hdc_command(device_ip, hdc_port, device_sn, "file send {} /system/profile/".format(service_xml)) + hdc_command(device_ip, hdc_port, device_sn, "file send {} /etc/init/".format(service_cfg)) + return @@ -154,13 +256,13 @@ def modify_cfg_xml_file(developer_path, device_ip, device_sn_list, if device_ip and len(device_sn_list) >= 1: for device_sn_str in device_sn_list: hdc_str = "hdc -s %s:%s -t %s" % (device_ip, device_port, device_sn_str) + hdc_dict = {"device_ip": device_ip, "device_port": device_port, "device_sn_str": device_sn_str} modify_init_file(developer_path, hdc_str) modify_faultloggerd_file( developer_path, hdc_str) # 推送服务对应的xml文件 - split_foundation_services( - developer_path, system_info_dict, home_path, hdc_str) - print("%s shell reboot" % hdc_str) + split_foundation_services(developer_path, system_info_dict, home_path, hdc_dict) + logger("{} shell reboot".format(hdc_str), "INFO") coverage_command("%s shell reboot > /dev/null 2>&1" % hdc_str) while True: after_sn_list = get_sn_list("hdc -s %s:%s list targets" % (device_ip, device_port)) @@ -169,7 +271,7 @@ def modify_cfg_xml_file(developer_path, device_ip, device_sn_list, break coverage_command("%s shell getenforce" % hdc_str) else: - print("user_config.xml device ip not config") + logger("user_config.xml device ip not config", "ERROR") if __name__ == '__main__': @@ -177,7 +279,8 @@ if __name__ == '__main__': command_str = command_args.split("command_str=")[1].replace(",", " ") current_path = os.getcwd() _init_sys_config() - from localCoverage.utils import coverage_command + from localCoverage.utils import coverage_command, \ + logger, hdc_command, FoundationServer root_path = current_path.split("/test/testfwk/developer_test")[0] developer_test_path = os.path.join(root_path, "test/testfwk/developer_test") diff --git a/localCoverage/resident_service/pull_service_gcda.py b/localCoverage/resident_service/pull_service_gcda.py index ca40131..69c4360 100644 --- a/localCoverage/resident_service/pull_service_gcda.py +++ b/localCoverage/resident_service/pull_service_gcda.py @@ -27,6 +27,29 @@ def _init_sys_config(): sys.path.insert(0, sys.localcoverage_path) +def restore_config(device_ip, device_port, device_sn, serv_path): + """ + 恢复设备内配置文件 + :param device_ip: + :param device_sn: + :param serv_path: + :param services_str: + :param device_port: + :return: + """ + remount_cmd = "shell mount -o rw,remount /" + hdc_command(device_ip, device_port, device_sn, remount_cmd) + origin_foundation = os.path.join(serv_path, "foundation_origin.xml") + restore_foundation_cmd = "file send {} /system/profile/foundation.xml".format(origin_foundation) + hdc_command(device_ip, device_port, device_sn, restore_foundation_cmd) + serv_list = FoundationServer.lib_dict + for serv in serv_list: + rm_xml_cmd = "shell rm /system/profile/{}.xml".format(serv) + hdc_command(device_ip, device_port, device_sn, rm_xml_cmd) + rm_cfg_cmd = "shell rm /etc/init/{}.cfg".format(serv) + hdc_command(device_ip, device_port, device_sn, rm_cfg_cmd) + + def attach_pid(device_ip, device_sn, process_str, component_gcda_dict, developer_path, resident_service_path, services_str, root_path, device_port): """ @@ -111,7 +134,7 @@ if __name__ == '__main__': command_str = command_args.split("command_str=")[1].replace(",", " ") current_path = os.getcwd() _init_sys_config() - from localCoverage.utils import get_product_name, coverage_command + from localCoverage.utils import get_product_name, coverage_command, hdc_command, FoundationServer root_path = current_path.split("/test/testfwk/developer_test")[0] developer_test_path = os.path.join(root_path, "test/testfwk/developer_test") @@ -136,3 +159,4 @@ if __name__ == '__main__': for sn_str in device_sn_list: get_service_list(ip, sn_str, system_dict, services_dict, component_dict, developer_test_path, service_path, root_path, port) + restore_config(ip, port, sn_str, service_path) diff --git a/localCoverage/utils.py b/localCoverage/utils.py index 74d75ab..32f675b 100644 --- a/localCoverage/utils.py +++ b/localCoverage/utils.py @@ -18,9 +18,10 @@ import os import json +import stat import subprocess import time -from subprocess import Popen, PIPE, STDOUT +from subprocess import Popen, PIPE, STDOUT, TimeoutExpired def logger(content, level): @@ -87,11 +88,14 @@ def shell_command(command_list: list): :return: """ process = Popen(command_list, stdout=PIPE, stderr=STDOUT) - with process.stdout: - for line in iter(process.stdout.readline, b""): - logger(line.decode().strip(), "INFO") - exitcode = process.wait() - return process, exitcode + try: + outs, errs = process.communicate(timeout=900) + except TimeoutExpired: + process.kill() + outs, errs = process.communicate() + logger(outs.decode("utf-8").strip(), "INFO") + + return errs, process.returncode def hdc_command(device_ip, device_port, device_sn, command): @@ -140,3 +144,46 @@ def tree_find_file_endswith(path, suffix, file_list=None): if os.path.isdir(full_path): tree_find_file_endswith(full_path, suffix, file_list) return file_list + + +class FoundationServer: + """ + foundation拆分的进程和其对应的so之间的对应关系 + """ + lib_dict = { + "ams": ["libabilityms.z.so", "libdataobsms.z.so", "libupms.z.so", "libappms.z.so"], + "bms": ["libbms.z.so"], + "call": ["libtel_call_manager.z.so"], + "dms": ["libdistributed_ability_manager_svr.z.so"], + "fms": ["libfms.z.so"], + "notification": ["libcesfwk_services.z.so", "libans.z.so"], + "power": ["libbatteryservice.z.so", "libdisplaymgrservice.z.so", "libpowermgrservice.z.so", + "libthermalservice.z.so", "libbatterystats_service.z.so"], + "state": ["libtel_state_registry.z.so"], + "wms": ["libwms.z.so"] + } + + +def is_elffile(filepath: str) -> bool: + """ + 判断文件是否二进制文件 + :param filepath: + :return: bool + """ + if not os.path.exists(filepath): + logger("{} not exists.".format(filepath), "ERROR") + return False + + try: + file_states = os.stat(filepath) + file_mode = file_states[stat.ST_MODE] + if not stat.S_ISREG(file_mode): + return False + with open(filepath, "rb") as f: + header = (bytearray(f.read(4)[1:4])).decode(encoding="utf-8") + if header in ["ELF"]: + return True + except UnicodeDecodeError as e: + logger(e, "ERROR") + + return False diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 578b762..29aa4dc 100644 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -64,6 +64,19 @@ CYCLE_TIMES = 30 ############################################################################## ############################################################################## +class CollectingOutputReceiver: + def __init__(self): + self.output = "" + + def __read__(self, output): + self.output = "%s%s" % (self.output, output) + + def __error__(self, message): + pass + + def __done__(self, result_code="", message=""): + pass + class DisplayOutputReceiver: def __init__(self): @@ -355,17 +368,23 @@ class ResultManager(object): result_josn_file_path = os.path.join(result_save_path, "%s.json" % self.testsuite_name) + result_log_file_path = os.path.join(result_save_path, + "%s.log" % self.testsuite_name) if self.testsuite_path.endswith('.hap'): remote_result_file = os.path.join(self.device_testpath, "testcase_result.xml") remote_json_result_file = os.path.join(self.device_testpath, "%s.json" % self.testsuite_name) + remote_log_result_file = os.path.join(self.device_testpath, + "%s.log" % self.testsuite_name) else: remote_result_file = os.path.join(self.device_testpath, "%s.xml" % self.testsuite_name) remote_json_result_file = os.path.join(self.device_testpath, "%s.json" % self.testsuite_name) + remote_log_result_file = os.path.join(self.device_testpath, + "%s.log" % self.testsuite_name) if self.config.testtype[0] != "fuzztest": if self.device.is_file_exist(remote_result_file): @@ -377,6 +396,8 @@ class ResultManager(object): else: LOG.info("%s not exist", remote_result_file) + self.device.pull_file(remote_log_result_file, result_log_file_path) + return result_file_path def make_empty_result_file(self, error_message=""): @@ -532,18 +553,21 @@ class CppTestDriver(IDriver): if not self.config.coverage: if self.config.random == "random": seed = random.randint(1, 100) - command = "cd %s; rm -rf %s.xml; chmod +x *; ./%s %s --gtest_shuffle --gtest_random_seed=%d" % ( + command = "cd %s; rm -rf %s.xml; chmod +x *; ./%s %s --gtest_shuffle --gtest_random_seed=%d\ + > %s.log 2>&1" % ( self.config.target_test_path, filename, filename, test_para, - seed) + seed, + filename) else: - command = "cd %s; rm -rf %s.xml; chmod +x *; ./%s %s" % ( + command = "cd %s; rm -rf %s.xml; chmod +x *; ./%s %s > %s.log 2>&1" % ( self.config.target_test_path, filename, filename, - test_para) + test_para, + filename) else: coverage_outpath = self.config.coverage_outpath if coverage_outpath: @@ -558,22 +582,23 @@ class CppTestDriver(IDriver): self._push_corpus_cov_if_exist(suite_file) command = f"cd {self.config.target_test_path}; tar zxf {filename}_corpus.tar.gz; \ rm -rf {filename}.xml; chmod +x *; GCOV_PREFIX=.; \ - GCOV_PREFIX_STRIP={strip_num} ./{filename} {test_para}" + GCOV_PREFIX_STRIP={strip_num} ./{filename} {test_para} > {filename}.log 2>&1" else: command = "cd %s; rm -rf %s.xml; chmod +x *; GCOV_PREFIX=. " \ - "GCOV_PREFIX_STRIP=%s ./%s %s" % \ + "GCOV_PREFIX_STRIP=%s ./%s %s > %s.log 2>&1" % \ (self.config.target_test_path, filename, str(strip_num), filename, - test_para) + test_para, + filename) result = ResultManager(suite_file, self.config) result.set_is_coverage(is_coverage_test) try: # get result - display_receiver = DisplayOutputReceiver() + display_receiver = CollectingOutputReceiver() self.config.device.execute_shell_command( command, receiver=display_receiver, -- Gitee From 24bcd56e85c7f85525ea168cfc02e210d8726c8b Mon Sep 17 00:00:00 2001 From: caojiale1 Date: Fri, 19 May 2023 11:50:45 +0800 Subject: [PATCH 2/4] Signed-off-by caojiale1 caojiale1@huawei.com Signed-off-by: caojiale1 --- localCoverage/resident_service/init_gcov.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localCoverage/resident_service/init_gcov.py b/localCoverage/resident_service/init_gcov.py index 3a25e87..b04bdda 100644 --- a/localCoverage/resident_service/init_gcov.py +++ b/localCoverage/resident_service/init_gcov.py @@ -114,7 +114,7 @@ def modify_foundation_xml(serv, config_path, origin_xml) -> str: :param origin_xml: 原foundation.xml :return: 修改后foundation.xml路径 """ - lib_list = FoundationServer.lib_dict + lib_list = FoundationServer.lib_dict.get(serv) tree = ET.parse(origin_xml) root = tree.getroot() @@ -140,7 +140,7 @@ def create_service_xml(serv, config_path, origin_xml) -> str: :param origin_xml: 原foundation.xml :return: xml文件路径 """ - lib_list = FoundationServer.lib_dict + lib_list = FoundationServer.lib_dict.get(serv) tree = ET.parse(origin_xml) root = tree.getroot() -- Gitee From d003dfe2ea0c0970f3e40207c9ac9998f22b0b4e Mon Sep 17 00:00:00 2001 From: caojiale1 Date: Fri, 19 May 2023 11:50:45 +0800 Subject: [PATCH 3/4] Signed-off-by caojiale1 caojiale1@huawei.com Signed-off-by: caojiale1 --- localCoverage/resident_service/init_gcov.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/localCoverage/resident_service/init_gcov.py b/localCoverage/resident_service/init_gcov.py index 3a25e87..b04bdda 100644 --- a/localCoverage/resident_service/init_gcov.py +++ b/localCoverage/resident_service/init_gcov.py @@ -114,7 +114,7 @@ def modify_foundation_xml(serv, config_path, origin_xml) -> str: :param origin_xml: 原foundation.xml :return: 修改后foundation.xml路径 """ - lib_list = FoundationServer.lib_dict + lib_list = FoundationServer.lib_dict.get(serv) tree = ET.parse(origin_xml) root = tree.getroot() @@ -140,7 +140,7 @@ def create_service_xml(serv, config_path, origin_xml) -> str: :param origin_xml: 原foundation.xml :return: xml文件路径 """ - lib_list = FoundationServer.lib_dict + lib_list = FoundationServer.lib_dict.get(serv) tree = ET.parse(origin_xml) root = tree.getroot() -- Gitee From ac70e631808659204d2869aae2d2898c7ad9a350 Mon Sep 17 00:00:00 2001 From: caojiale1 Date: Fri, 19 May 2023 15:51:10 +0800 Subject: [PATCH 4/4] Signed-off-by caojiale1 caojiale1@huawei.com Signed-off-by: caojiale1 --- localCoverage/push_coverage_so/push_coverage.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/localCoverage/push_coverage_so/push_coverage.py b/localCoverage/push_coverage_so/push_coverage.py index e224591..cd4079d 100644 --- a/localCoverage/push_coverage_so/push_coverage.py +++ b/localCoverage/push_coverage_so/push_coverage.py @@ -107,17 +107,15 @@ def find_so_source_dest(path: str, subsystem_name: str) -> dict: for j in json_list: json_obj = json_parse(j) if "subsystem_name" not in json_obj: - logger("subsystem_name not in {}".format(j), "INFO") continue if json_obj["subsystem_name"] != subsystem_name: - logger("{} != {}. No need to deal.".format(json_obj["subsystem_name"], subsystem_name), "INFO") continue if "source" not in json_obj or "dest" not in json_obj: logger("{} json file error.".format(j), "ERROR") return {} source_path = os.path.join(out_path, json_obj["source"]) - if is_elffile(source_path): + if source_path.endswith(".so"): so_dict[source_path] = json_obj["dest"] return so_dict -- Gitee