Merged
fix(build): Enable C++ coverage collection from Python UT #6296
chengding888Add on Sep 15
fix(build): Enable C++ coverage collection from Python UT #6296
Merged
chengding888Add on Sep 15
chengding888
chengding888Collaborators
Sep 15
Pull Request has been successfully merged by CANN-robot.
(Thank you for chengding888's contribution.)
chengding888chengding888Collaborators
Sep 15 Created pull request, commit be6e58be
atomgit-bot
atomgit-bot
Sep 15 Comments:

变更摘要

本 PR 旨在打通从 Python UT 侧采集 C++ 覆盖率数据的链路:通过构建与链接选项导出 __gcov_dump 符号,并在 Python 侧新增 conftest.py 在用例 teardown 时手动 flush gcov 覆盖率数据;同时将本地预检脚本中的覆盖率统计与门禁移除,统一交由 CI 兜底。

主要改动

  • 构建环境注入 PYPTO_GCOV_FLUSH(build_ci.py):当启用 gcov 构建(self.build.gcov)时,在 Python 测试环境变量中写入 PYPTO_GCOV_FLUSH=1,作为 Python 侧触发 gcov flush 的开关。
  • 链接选项导出 __gcov_dump 符号(cmake/intf.cmake):在 ENABLE_GCOV 且编译器为 GNU 时,为 tile_fwk_intf_pub_base 增加 -Wl,--export-dynamic,--whole-archive,-lgcov,--no-whole-archive 链接选项,供 pytest-forked 子进程退出前手动调用 __gcov_dump 写入覆盖率数据。
  • 新增 Python UT 公共 conftest.py:针对 --forked 模式下 pytest-forked 通过 os._exit() 退出子进程跳过 atexit、导致 .gcda 不落盘的问题,在 pytest_runtest_teardown 中通过 ctypes 解析并调用 __gcov_dump();仅在 PYPTO_GCOV_FLUSH 环境变量存在时生效,并附带 duration_estimate 用例耗时标注装饰器。
  • 预检脚本移除本地覆盖率门禁(tools/scripts/pre_commit_check.sh):删除 lcov/gen_coverage.py --increment 本地覆盖率采集与 80% 阈值检查,说明增量覆盖率计算与 CI 的 get_ai_inc_cov.py(addlcov) 为两套实现、无法保证一致,覆盖率门禁由 CI 兜底;同时修复 run_clang 中 GTEST_FILTER 环境变量在运行后未恢复的问题,并将 clang/ASan 阶段失败改为硬性退出失败。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 15 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 15 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 15 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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
build_ci.py ✅ 尹杰, tsungl4 (2/2) ✅ 尹杰 (1/1)
cmake ✅ 尹杰, tsungl4 (2/2) ✅ 尹杰 (1/1)
repo-cann/pypto ✅ tsungl4, 尹杰 (2/2) ✅ 尹杰 (1/1)
tools/scripts ✅ 尹杰, tsungl4 (2/2) ✅ 尹杰 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)
likedislike
CANN-robot
CANN-robotCollaborators
Sep 15 Comments:

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 15 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 15 Set xinweiliu,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
chengding888chengding888Collaborators
Sep 15 Modify description of pull request
chengding888chengding888Collaborators
Sep 15 Associated issue: [Bug-Report|缺陷反馈]: c++ 覆盖率统计无法覆盖使用Python写的UT
chengding888
chengding888Collaborators
Sep 15 Comments:

compile

likedislike
chengding888chengding888Collaborators
Sep 15 Pre merge succeeded (commit_id: ff8babd10fbcd5c0434a5a9020fb5561669b7554)
CANN-robot
CANN-robotCollaborators
Sep 15 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 15 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 15 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 15 Added label: ci-pipeline-passed
Jie Yin
Jie YinCollaborators
Sep 15 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 15 Added label: approved
lidongsheng
lidongshengCollaborators
Sep 15 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 15 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 15 Merged pull request