From c9190b955fc730daefa842990a0d5b8fd3368887 Mon Sep 17 00:00:00 2001 From: steven_q Date: Mon, 13 May 2024 19:23:06 +0800 Subject: [PATCH] qqq Change-Id: I739ee7070ef522096f022d91b0e1188972ba42a5 --- config/user_config.xml | 4 ++-- .../codeCoverage/mutilProcess_CodeCoverage.py | 14 ++++++++------ .../restore_comment/build_before_generate.py | 4 ---- .../restore_comment/restore_source_code.py | 7 ------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/config/user_config.xml b/config/user_config.xml index 9dc4344..5482d81 100755 --- a/config/user_config.xml +++ b/config/user_config.xml @@ -29,8 +29,8 @@ - - + 172.25.64.1 + 2233 diff --git a/localCoverage/codeCoverage/mutilProcess_CodeCoverage.py b/localCoverage/codeCoverage/mutilProcess_CodeCoverage.py index 4fde91a..b12c046 100644 --- a/localCoverage/codeCoverage/mutilProcess_CodeCoverage.py +++ b/localCoverage/codeCoverage/mutilProcess_CodeCoverage.py @@ -191,7 +191,7 @@ def gen_subsystem_trace_info(subsystem, data_dir, test_dir, lcovrc_path): print(f"Sours path {src_dir} not exists!") return - cmd = "lcov -c -b {} -d {} --gcov-tool {} --config-file {} -o {} --ignore-errors source,gcov".format( + cmd = "lcov --rc lcov_branch_coverage=1 -c -b {} -d {} --gcov-tool {} --config-file {} -o {} --ignore-errors source,gcov".format( src_dir, data_dir, os.path.join(CODEPATH, LLVM_GCOV), lcovrc_path, output_name) print("single_test**##father_pid:%s##child_pid:%s cmd:%s config file:%s" % ( os.getpid(), os.getppid(), cmd, lcovrc_path @@ -209,13 +209,13 @@ def cut_info(subsystem, test_dir): test_dir, f"{subsystem}_strip.info" ) - remove = r"'*/third_party/*' '*/prebuilts/*' '*/unittest/*' " \ + remove = r"'*/third_party/*' '*/prebuilts/*' '*/unittest/*' '*/test/*' " \ r"'*/moduletest/*' '*/systemtest/*' '*.h*'" if not os.path.exists(trace_file): print(f"Error: trace file {trace_file} not exists!") return - cmd = "lcov --remove {} {} -o {}".format(trace_file, remove, output_name) + cmd = "lcov --rc lcov_branch_coverage=1 --remove {} {} -o {}".format(trace_file, remove, output_name) execute_command(cmd) @@ -278,6 +278,8 @@ def merge_subsystem_info_from_all_test(subsystem): subsystem_info_path_tmp = os.path.join( single_test_info_path, root, file ) + if os.path.getsize(subsystem_info_path_tmp) == 0: + continue print(f"##{subsystem_info_path_tmp}") subsystem_info_list.append(subsystem_info_path_tmp) @@ -287,7 +289,7 @@ def merge_subsystem_info_from_all_test(subsystem): info_output_name = os.path.join( CODEPATH, REPORT_PATH, subsystem_info_name ) - cmd = "lcov -a {} -o {}".format( + cmd = "lcov --rc lcov_branch_coverage=1 -a {} -o {}".format( " -a ".join(subsystem_info_list), info_output_name ) execute_command(cmd) @@ -322,7 +324,7 @@ def merge_info(report_dir): trace_file_name = os.path.join(report_dir, subsystem) trace_file_list.append(trace_file_name) - cmd = "lcov -a {} -o {}".format( + cmd = "lcov --rc lcov_branch_coverage=1 -a {} -o {}".format( " -a ".join(trace_file_list), os.path.join(report_dir, "ohos_codeCoverage.info") ) execute_command(cmd) @@ -339,7 +341,7 @@ def gen_html(cov_path): print(f"Error: the trace file {tracefile} not exists!") return - cmd = "genhtml --branch-coverage --demangle-cpp -o {} -p {} --ignore-errors source {}".format( + cmd = "genhtml --rc lcov_branch_coverage=1 --branch-coverage --demangle-cpp -o {} -p {} --ignore-errors source {}".format( os.path.join(CODEPATH, REPORT_PATH, "html"), CODEPATH, tracefile) execute_command(cmd) diff --git a/localCoverage/restore_comment/build_before_generate.py b/localCoverage/restore_comment/build_before_generate.py index 6a4cb34..44059cb 100644 --- a/localCoverage/restore_comment/build_before_generate.py +++ b/localCoverage/restore_comment/build_before_generate.py @@ -89,11 +89,7 @@ def add_lcov(subsystem_config_path): if "path" in value.keys(): for path_str in value["path"]: file_path = os.path.join(root_path, path_str) - primal_path = f"{file_path}_primal" if os.path.exists(file_path): - if not os.path.exists(primal_path): - subprocess.Popen("cp -r %s %s" % ( - file_path, primal_path), shell=True).communicate() source_file_path = get_source_file_list(file_path) rewrite_source_file(source_file_path) else: diff --git a/localCoverage/restore_comment/restore_source_code.py b/localCoverage/restore_comment/restore_source_code.py index d6b543c..372e678 100644 --- a/localCoverage/restore_comment/restore_source_code.py +++ b/localCoverage/restore_comment/restore_source_code.py @@ -35,12 +35,5 @@ if __name__ == '__main__': if "path" in value.keys(): for path_str in value["path"]: file_path = os.path.join(root_path, path_str) - if os.path.exists(file_path): - if os.path.exists(f"{file_path}_primal"): - subprocess.Popen("rm -rf %s" % file_path, shell=True).communicate() - subprocess.Popen("mv %s %s" % ( - f"{file_path}_primal", file_path), shell=True).communicate() - else: - print("The directory does not exist.", file_path) except(FileNotFoundError, AttributeError, ValueError, KeyError): print("restore source code Error") -- Gitee