Merged
fix: 统一 lcov 忽略错误参数以兼容 lcov>=2.0 覆盖率生成 #574
songkai111Add on Jun 29
fix: 统一 lcov 忽略错误参数以兼容 lcov>=2.0 覆盖率生成 #574
Merged
songkai111Add on Jun 29
songkai111
songkai111Collaborators
Jun 29

描述

本 PR 修复 scripts/util/generate_cpp_cov.sh 在 lcov >= 2.0 环境下覆盖率生成失败的问题。

lcov 2.0 及以上版本对多项条件(mismatch、inconsistent、empty、negative)实施了更严格的校验,而原脚本仅在个别命令上传入 --ignore-errors inconsistent,导致覆盖率采集(lcov -c)、过滤(lcov -r / lcov --remove)和 HTML 报告生成(genhtml)环节因严格校验报错而中断。

改动方法

  1. 新增统一的忽略错误参数变量 LCOV_IGNORE_ERRORS="--ignore-errors mismatch,inconsistent,empty,negative",集中管理所有需要忽略的错误类型。
  2. 将该变量应用到脚本中全部 4 处 lcov / genhtml 调用:
    • generate_coverage() 中的 lcov -c(采集)
    • generate_coverage() 中的 lcov -r(移除外部路径)
    • filter_coverage() 中的 lcov --remove(过滤无关目录)
    • generate_html() 中的 genhtml(生成 HTML 报告)
  3. 移除原先分散、仅覆盖 inconsistent 的局部 --ignore-errors inconsistent 写法。

关联的Issue

  • #238

测试

在 lcov >= 2.0 环境下运行 scripts/util/generate_cpp_cov.sh,覆盖率采集、过滤及 HTML 报告生成均正常完成,不再因严格校验中断。

文档更新

无。本次仅修改覆盖率生成脚本,不涉及文档。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for songkai111's contribution.)
CANN-robotCANN-robotCollaborators
Jun 29 Added label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Jun 29 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jun 29 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/opbase ✅ wangrui_, 王林木 (2/2) ✅ wangrui_ (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

songkai111, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
atomgit-bot
atomgit-bot
Jun 29 Comments:

变更摘要

此 PR 主要解决 lcov >= 2.0 版本引入了更严格的校验规则,导致 C++ 单元测试覆盖率生成脚本失败的问题。通过在覆盖率生成脚本中统一增加 --ignore-errors mismatch,inconsistent,empty,negative 参数,提升了对不同 lcov 版本的兼容性。此外,在升级脚本中补充了缺失的 pkg_version_dir 参数传递。

主要改动

  • 引入统一的 lcov 错误忽略变量: 在 scripts/util/generate_cpp_cov.sh 中新增 LCOV_IGNORE_ERRORS 变量,将 mismatch、inconsistent、empty、negative 四类错误统一忽略,替代原来零散的 --ignore-errors inconsistent 写法。
  • 更新 lcov -c 数据采集命令: 在 generate_coverage 函数中,为 lcov -c 添加 ${LCOV_IGNORE_ERRORS} 参数,使其在覆盖率数据采集阶段即可容忍版本差异导致的格式问题。
  • 更新 lcov -r 移除命令与 lcov --remove 过滤命令: 将两处硬编码的 --ignore-errors inconsistent 替换为 ${LCOV_IGNORE_ERRORS},扩展兼容的错误类型范围。
  • 更新 genhtml 报告生成命令: 在 generate_html 函数中为 genhtml 添加 ${LCOV_IGNORE_ERRORS} 参数,避免 HTML 报告生成阶段因严格校验而失败。
  • 修复升级脚本参数缺失: 在 scripts/package/opbase/scripts/opp_upgrade.sh 中为卸载脚本调用补充 "$pkg_version_dir" 参数,确保升级流程中版本信息正确传递。
likedislike
Incorrect?
songkai111songkai111Collaborators
Jun 29 Force-pushed 8 commits:eb994aa5-7 commits from branch master,43719a67-fix: 修复 lcov>=2.0 严格校验导致 ut 覆盖率生成失败
CANN-robotCANN-robotCollaborators
Jun 29 Removed label: stat/needs-squash
CANN-robotCANN-robotCollaborators
Jun 29 Added label: stat/needs-squash
CANN-robot
CANN-robotCollaborators
Jun 29 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): stat/needs-squash.

likedislike
songkai111
songkai111Collaborators
Jun 29 Comments:

compile

likedislike
atomgit-bot
atomgit-bot
Jun 29 Comments:

代码审查

边界值和共址缺陷检查均已完成。在上述同一位置未发现其他独立问题。


审查总结

文件 结果
scripts/package/opbase/scripts/opp_upgrade.sh 无问题——变更正确地补齐了 opp_uninstall.sh 所需的第 7 个参数 $pkg_version_dir(参照 install.sh 中已有的调用模式),属于 bug 修复。
scripts/util/generate_cpp_cov.sh 发现 1 个问题(P3)——共享的 LCOV_IGNORE_ERRORS 变量包含仅 lcov >= 2.0 支持的 negative 类别,当 genhtml 在 lcov 1.x 环境中运行时可能导致失败。

各优先级问题统计:

  • P0:0
  • P1:0
  • P2:0
  • P3:1

整体风险评估:低。opp_upgrade.sh 的变更是正确的 bug 修复。generate_cpp_cov.sh 的变更是针对 lcov >= 2.0 的必要适配方案;唯一的潜在问题是在 lcov 1.x 环境中 genhtml 的兼容性问题,但该 PR 明确针对 lcov >= 2.0,在此场景下不会出现回归。

⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jun 29 Added label: ci-pipeline-running
CANN-robot
CANN-robotCollaborators
Jun 29 Comments:

流水线任务触发成功
任务链接 [deacf1f122e140c8aa42656163550152][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
antipoison ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>> >>>>>
UT_Test ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
codecheck_style ✅ SUCCESS >>>>>
precommit ⚠️ WARNING >>>>> >>>>>
API_Check ✅ SUCCESS >>>>>

[2026-06-29 10:19:25]    CI执行结束

likedislike
CANN-robotCANN-robotCollaborators
Jun 29 Added label: api-check-pass
CANN-robotCANN-robotCollaborators
Jun 29 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Jun 29 Added label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
Jun 29 Comments:
流水线 PR-pipeline_cann_opbase#1334 [ commitID:43719a67 ] 已完成
likedislike
songkai111songkai111Collaborators
Jun 29 Change title to "fix: 统一 lcov 忽略错误参数以兼容 lcov>=2.0 覆盖率生成", originally titled "fix: 修复 lcov>=2.0 严格校验导致 ut 覆盖率生成失败".
songkai111songkai111Collaborators
Jun 29 Modify description of pull request
llimwang
llimwangCollaborators
Jun 29 Comments:

/lgtm

likedislike
RuiWang_
RuiWang_Collaborators
Jun 29 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Jun 29 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Jun 29 Closed associated issue
CANN-robotCANN-robotCollaborators
Jun 29 Merged pull request