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
Merged fromchengding888/pypto9.2.0intocann/pypto9.2.0
Pull Request has been successfully merged by CANN-robot.
(Thank you for chengding888's contribution.)Sep 15 Created pull request, commit be6e58be
atomgit-bot
Sep 15 Comments:
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 阶段失败改为硬性退出失败。


Incorrect?
atomgit-bot
Sep 15 Comments:
Sep 15 Comments:
Sep 15 Added label: cann-cla/yes
CANN-robot
Sep 15 Comments:
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
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)


CANN-robot
Sep 15 Comments:
Sep 15 Comments:
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
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
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
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
Sep 15 Modify description of pull request
Sep 15 Associated issue: [Bug-Report|缺陷反馈]: c++ 覆盖率统计无法覆盖使用Python写的UT
chengding888
Sep 15 Comments:
Sep 15 Comments:
compile


Sep 15 Pre merge succeeded (commit_id: ff8babd10fbcd5c0434a5a9020fb5561669b7554)
CANN-robot
Sep 15 Comments:
Sep 15 Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


Sep 15 Added label: ci-pipeline-running
Sep 15 Removed label: ci-pipeline-running
Sep 15 Added label: ci-pipeline-passed
Jie Yin
Sep 15 Comments:
Sep 15 Comments:
/approve


Sep 15 Added label: approved
lidongsheng
Sep 15 Comments:
Sep 15 Comments:
/lgtm


Sep 15 Added label: lgtm
Sep 15 Merged pull request
cherry-pick https://gitcode.com/cann/pypto/pull/6148