已合并
【PR】: [fix] device_validation UT 补充缺失的 algorithm 头文件包含 #1983
【PR】: [fix] device_validation UT 补充缺失的 algorithm 头文件包含 #1983
已合并
Leechi666创建于 10 天前
Leechi666
Leechi666成员
10 天前

Pull Request

描述

autofuse/tests/ut/device_validation/test_device_resources.cpp:378 使用 std::find 但文件未包含 <algorithm>,其可见性完全依赖头文件传递包含:

  • GCC 9 的 libstdc++ 中 <unordered_map>(项目头引入)传递包含 bits/stl_algo.h,编译碰巧通过;
  • GCC 14 环境下 libstdc++/gtest(v1.14+)均已精简传递包含,std::find 声明不可见,模板推导失败,UT 编译报错,导致文档声明 GCC >= 7.3.0 可用但实际 ST/UT 验证流程无法走通。

修复:显式包含 <algorithm>(1 行),消除对第三方/标准库头文件内部实现细节的依赖。

变更类型

关联的Issue

如何测试

  1. cmake --build build --target device_validation_ut -j 8 完整编译链接通过(无错误、无新增告警);
  2. 运行 ./build/autofuse/tests/ut/device_validation/device_validation_ut,136 个用例全部 PASSED,其中含出问题的 KernelModuleTest.V2RequestDoesNotProbeLegacySymbol
  3. 反向验证:去掉该行后编译成败取决于传递包含链(GCC 9 碰巧通过、精简头文件的环境复现 no matching function for call to 'find(...)'),显式包含后确定性成立;
  4. pre-commit 全部钩子通过(clang-format v18.1.8、OAT 开源合规检查)。

核对清单

其他信息

分支基于 origin/develop(3ab20804),仅含 1 个提交(7824a372),无多余 commit。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Leechi666 的贡献)
Leechi666Leechi666成员
10 天前 创建了 pull request,commit df0b4113
atomgit-bot
atomgit-bot
10 天前 评论:

变更摘要

该 PR 修复 autofuse/tests/ut/device_validation/test_device_resources.cpp 的编译缺陷:该文件在 KernelModuleTest.V2RequestDoesNotProbeLegacySymbol 等用例中调用 std::find,但此前未显式包含 <algorithm>,其可见性依赖标准库头文件的传递包含(GCC 9 的 libstdc++ 恰好通过,GCC 14 精简传递包含后模板推导失败,导致 UT 编译报错)。修复方式是在该测试文件中显式补上 #include <algorithm>(1 行),消除对第三方/标准库头文件内部实现细节的依赖,使 UT 在文档声明的 GCC >= 7.3.0 环境中可确定性地编译通过。

主要改动

  • 显式包含 <algorithm> 头文件: 在 autofuse/tests/ut/device_validation/test_device_resources.cpp#include <gtest/gtest.h> 之后新增 #include <algorithm>,为文件中使用的 std::find 提供确定性声明来源。
  • 消除传递包含依赖: 不再依赖 <unordered_map> 等头文件内部对 bits/stl_algo.h 的传递包含行为,使 UT 编译结果在不同 GCC/libstdc++ 与 gtest 版本下保持稳定,修复 GCC 14 环境下的 no matching function for call to 'find(...)' 报错。
likedislike
不准确?
atomgit-bot
atomgit-bot
10 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
10 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
10 天前 评论:

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
repo-cann/graph-autofusion yangyongqiang0606, zhang_shengjie, liyuewei (3/2) yangyongqiang0606 (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-robot成员
10 天前 评论:

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
10 天前 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,zhang_shengjie,depeng1994,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为评审人
CANN-robotCANN-robot成员
10 天前 将niuyuhu,yangyongqiang0606,liyuewei,xchu42,zhang_shengjie,depeng1994,wqtshg_wt,peiyang,shengnan666,XuebinYang,sjtulxh,zhanj,zhujingjing,xuyafei,wangxiaotian995设为审查人
Leechi666
Leechi666成员
10 天前 评论:

compile

likedislike
Leechi666Leechi666成员
10 天前 预合并成功(commit_id: 29c674ab3e3f7925da469661b2360caa8e5c6d09)
CANN-robot
CANN-robot成员
10 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
10 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
10 天前 添加了label:ci-pipeline-passed
zhang_shengjie成员
10 天前 评论:

/lgtm

likedislike
liyuewei
liyuewei成员
10 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:lgtm
yangyongqiang
yangyongqiang成员
10 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
10 天前 添加了label:approved
CANN-robot
CANN-robot成员
10 天前 评论:

Something went wrong during merge: git update-ref: exit status 128, stderr: "fatal: commit: cannot lock ref 'refs/heads/develop': is at 22122bec4e1489a00db52d1652dae9bc7e074b69 but expected 1e8bf172af55ffbbc46b45a1162ac9bffb64042b\n"

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
yangyongqiang
yangyongqiang成员
10 天前 评论:

/approve cancel

likedislike
CANN-robotCANN-robot成员
10 天前 删除了label:approved
CANN-robot
CANN-robot成员
10 天前 评论:

Review Code Feedback

approved was removed in this pull request by: yangyongqiang0606. 😳

likedislike
Leechi666
Leechi666成员
9 天前 评论:

/check-pr

likedislike
CANN-robot
CANN-robot成员
9 天前 评论:

The following label is not ready.

approved: Please wait for committers to review the code.

likedislike
Leechi666
Leechi666成员
9 天前 评论:

@yangyongqiang0606 麻烦重新审批一下:上次 /approve 后的合并因 develop 分支被并发推进(git update-ref 竞态)而失败,approve 随之失效。当前 PR 已具备 ci-pipeline-passed 与两枚 lgtm,代码自上次审批以来无任何变更,重新 /approve 后即可正常合入。谢谢!

likedislike
yangyongqiang
yangyongqiang成员
9 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
9 天前 添加了label:approved
CANN-robotCANN-robot成员
9 天前 合入了pull request
邢智雄邢智雄成员
7 天前 关联了issue:[Bug-Report|缺陷反馈]: ST 测试代码存在编译缺陷