Open
test(discovery): 同步端点参数并隔离发现测试状态 #9
test(discovery): 同步端点参数并隔离发现测试状态 #9
Open
liuxingsenAdd on 23 days ago
liuxingsenCollaborators
23 days ago

当前PR是否有AI参与:

[ ] 否

[x] 是
__1. AI Agent 平台: OpenAI Codex
__2. AI 模型: gpt-6-astra(实现与独立只读复核)
__3. Prompt上下文 : 分析平台代码仓开发者测试和行覆盖率,修复失败测试并提交任务类型 issue 与 PR。本 PR 同步 SMBus 发现测试接口,并防止测试桩在失败后污染后续用例。

PR功能描述 / 为什么需要这个合入:

smbus_set_eid_to_endpoint 已新增首参 ep_name,两个测试仍传旧六参,导致介质参数错位为物理地址 29,触发原断言。断言抛出使尾部 restore 未执行,共享 fixture 的 create_endpoint 桩继续影响 init 测试。本地复现 3 个失败,修复后 105 个 UT 全部通过。

修改方案:

两次调用补入端点名称;engine/discovery 移到每用例 setup 构造;setup 统一保存目标 EID,两个用例与 teardown 共用该值;teardown 统一恢复原 create_endpoint 并清除模块级失败记录,移除尾部重复恢复。class 范围的任务桩仍由 teardownClass 恢复。所有原介质、路径、请求报文、信号和重试次数断言保留,只修改 test/unit/test_discovery.lua。

验证方案:

Bingo 0.8.25、原 profile.dt.ini、gcov 开启,私有 PID/IPC/mount 与临时目录中复现基线。修复只涉及 Lua 测试,复用同一份新构建二进制,用 -wb 执行 UT+IT;各轮之间保存并清零本仓 gcda,清空本任务原 IT 生成的数据目录,保留 LuaCov/LCOV 和原始日志。

测试建议:

执行 bingo 的 UT+IT+覆盖率流程,关注 SMBus 成功/失败发现、失败轮询,以及测试失败后的清理和 init 用例隔离。

自验证报告:

  • 修复前:105 个 UT,102 通过、3 失败。
  • 检视整改后(9e99219054c8,测试内容哈希一致):105/105 UT 通过;IT 在 test_app.lua:492 到达最终 test complete,完整日志未见断言失败。IT 内部场景未提供独立总数,不把 105 当作 UT+IT 的合计用例数。
  • Bingo 正式源行覆盖 3129/3624(86.34%):Lua 2160/2495,C/C++ 969/1129。相同原始 gcda、同样排除规则补充分支 543/1078(50.37%),仅 C/C++ 编译范围;LuaCov 不提供 Lua 分支覆盖。
  • 上述为实际执行采集口径,没有将静态代码 LOC 或未编译代码作为覆盖率分母。原始计数及两轮日志均已保存。
  • git diff --check 通过;独立只读复核无阻塞。未修改生产、版权、年份或许可证,不升版本。
  • 重跑中一次复用了旧IT数据库,触发宿主缺少sqlite3的恢复路径而失败;已保存该轮日志/数据库,清空本任务生成的测试数据后重新完成上述验证。

该PR关联的issue

fixes #3

希望检视人员了解:

IT 日志有非被测组件 soctrl 不存在的查询提示,但本轮最终完成标记和断言审计已确认;没有为消除提示放宽断言。Conan 构建/依赖与远端 CI 环境仍可能不同,远端结果以当前 SHA 为准。

likedislike
Merge blocked
LliuxingsenCollaborators
23 days ago Created pull request, commit a2da7d37
LliuxingsenCollaborators
23 days ago Associated issue: [任务] 同步 SMBus 发现测试参数并隔离每用例状态
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: sig/sig-component-drivers
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

欢迎来到 openUBMC 社区

Hey @xiaoxinglxs , 感谢你对社区的贡献.

机器人使用手册

有关指令的使用,可以点击 说明文档 或 论坛 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。您可以自助配置此仓库的 PR 合并规则,更多详情,请参阅机器人自助配置使用手册。

联系指引

有疑问可以联系 SIG: sig-component-drivers ,
维护者是: @dongyushan, @net_swift_wangchen, @sam_h1973, @u012924942, @weixin_37569011, @xiaoxinglxs ,
优秀贡献者是: @hzy1010, @leessential .

likedislike
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: ai-co-authored
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: openUBMC-cla/yes
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: ai-includes-code
Oopenubmc-ci-botCollaborators
23 days ago Added label: ci-running
openubmc-ci-botCollaborators
23 days ago Comments:

CI已开始运行,查看流水线详情:流水线链接

likedislike
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

/ai review

likedislike
atomgit-bot
atomgit-botCollaborators
23 days ago Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: ai-compliance-successful
Oopenubmc-ci-botCollaborators
23 days ago Added label: limit_1k_suc
openubmc-ci-botCollaborators23 days agoStart code review2
test/unit/test_discovery.lua
Outdated
@@ -55,0 +57,4 @@
57+ 
58+function TestMctpDiscovery:teardown()
59+ self.mctp_engine.endpoints.create_endpoint = self._origin_create_endpoint
60+ self.mctp_discovery:smbus_set_eid_remove(9)
openubmc-ci-bot23 days agoComments:

💡 建议:teardown 中的清理 EID 使用硬编码魔法数

teardown() 里 smbus_set_eid_remove(9) 直接硬编码了 9,但各测试用例中使用的 EID 是局部变量 local target_eid = 9(如成功/失败用例中的 target_eid)。如果后续修改某个用例的 target_eid,这里会静默失效——不会报错,但失败列表清理不到,导致状态残留污染后续用例,与本 PR「隔离测试状态」的目的相悖。

修复建议:把 EID 提升为测试类成员,在 setup() 中统一赋值,teardown 引用该成员。例如在 setup() 增加 self.target_eid = 9,teardown 改为 self.mctp_discovery:smbus_set_eid_remove(self.target_eid),使清理与用例保持一致。

likedislike
System
System MessageSystem
23 days ago Comments:

changed this line on 9e992190 view diff detail

openubmc-ci-botCollaborators23 days agoStart code review1
test/unit/test_discovery.lua
@@ -55,0 +56,4 @@
56+end
57+ 
58+function TestMctpDiscovery:teardown()
59+ self.mctp_engine.endpoints.create_endpoint = self._origin_create_endpoint
openubmc-ci-bot23 days agoComments:

💡 建议:新增 teardown 后,用例中的手动 restore() 可简化

本次新增的 teardown()(本行)已经负责把 self.mctp_engine.endpoints.create_endpoint 恢复为 _origin_create_endpoint,且 setup()/teardown() 会为每个用例自动执行。因此 test_mctp_discovery_success 末尾的 restore()(stub_endpoints 返回的恢复函数)与 teardown 存在双重恢复。

虽然这不会造成功能问题(恢复是幂等的),但会引入冗余。修复建议:保留 teardown 的恢复作为「断言失败时也能保证清理」的兜底,同时可移除用例末尾的手动 restore() 调用,让清理逻辑集中到 fixture 中,代码更简洁。若希望在用例内保持防御性恢复,也建议加注释说明与 teardown 的职责分工。

likedislike
openubmc-ci-botCollaborators
23 days ago Comments:

人工检视报告

感谢 @xiaoxinglxs 的贡献!PR 同步 SMBus 发现测试接口(补入新增的 ep_name 首参),并将 engine/discovery 构造移到每用例的 setup()、新增 teardown() 恢复 create_endpoint 桩并清理失败列表,修复失败用例尾部 restore 未执行导致的测试状态污染问题。改动聚焦、目标明确,逻辑正确。

📋 检视概览

项目 详情
评级 良好
严重问题 0
警告 0
建议 2

已确认修复的问题 ✅

未发现需要确认修复的历史机器人问题(existing_review_comments 中仅有欢迎/CLA/CI/robot 触发等非检视意见,且机器人报告为「✅ 未发现问题」)。

需关注的问题(已关联代码行)

# 文件 行 级别 说明
1 test/unit/test_discovery.lua 60 💡 建议 teardown 中清理 EID 硬编码魔法数 9,与用例的 target_eid 易失同步,建议提升为测试类成员统一引用
2 test/unit/test_discovery.lua 59 💡 建议 新增 teardown 已负责恢复 create_endpoint,用例末尾手动 restore() 与其双重恢复,可考虑集中到 fixture

核实情况说明

  • smbus_set_eid_to_endpoint 新签名首参即 ep_name(src/lualib/mctp_discovery.lua:323),两处调用补入 'TestEndpoint' 与生产签名一致,正确。
  • discovery_smbus_eid_tb 为模块级共享表(src/lualib/mctp_discovery.lua:322),teardown 的 smbus_set_eid_remove(9) 能避免失败记录跨用例残留,符合隔离目的。

整体实现正确、意图清晰,上述两条仅为进一步提升健壮性与简洁性的可选优化。建议合入前可按需处理第 1 条,其余不阻塞合入。

likedislike
Oopenubmc-ci-botCollaborators
23 days ago Removed label: ci-running
openubmc-ci-botCollaborators
23 days ago Comments:
任务名称结果
pre-commit检查✅ SUCCESS
PR描述检查✅ SUCCESS
防投毒检查✅ SUCCESS
开源合规检查✅ SUCCESS
编译构建✅ SUCCESS
UT测试✅ SUCCESS
IT测试✅ SUCCESS
代码覆盖率✅ SUCCESS
修改行数检查✅ SUCCESS
头文件检查✅ SUCCESS
AI Review✅ SUCCESS
likedislike
Oopenubmc-ci-botCollaborators
23 days ago Added label: ci-successful
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: unresolved-reviews
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

注意

当前PR有 2 条评论意见. 其中 2 条未处理完毕. 全部处理完后, 请评论 /check-pr 进行检查. 😄

likedislike
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

注意

当前PR有 2 条评论意见. 其中 2 条未处理完毕. 全部处理完后, 请评论 /check-pr 进行检查. 😄

likedislike
LliuxingsenCollaborators
23 days ago Pre merge succeeded (commit_id: eaa692d3f90a919133664baa793a1363c68204ef)
LliuxingsenCollaborators
23 days ago Force-pushed 1 commits:9e992190-test(discovery): align endpoint arguments and isolate fixtures
LliuxingsenCollaborators
23 days ago Pre merge succeeded (commit_id: 29bfbe1eacf685e9cea089577b7f041568c66cc4)
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Removed label: openUBMC-cla/yes
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Removed label: limit_1k_suc
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

###注意:
当前PR代码已经发生变化(代码更新或者PR关闭),所以移除以下标签: limit_1k_suc.

likedislike
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Added label: openUBMC-cla/yes
openUBMC-robot
openUBMC-robotCollaborators
23 days ago Comments:

CLA 签署成功

xiaoxinglxs, 感谢您的代码贡献。 所有的代码贡献者都已完成了 CLA 签署。 👍

likedislike
openUBMC-robotopenUBMC-robotCollaborators
23 days ago Removed label: ci-successful
LliuxingsenCollaborators
23 days ago Modify description of pull request
Oopenubmc-ci-botCollaborators
23 days ago Added label: ci-running
openubmc-ci-botCollaborators
23 days ago Comments:

CI已开始运行,查看流水线详情:流水线链接

likedislike
LliuxingsenCollaborators
23 days ago Resolved final issue
Oopenubmc-ci-botCollaborators
23 days ago Added label: limit_1k_suc
openubmc-ci-botCollaborators
23 days ago Comments:

人工检视报告

感谢 @xiaoxinglxs 的贡献!本 PR 同步 SMBus 发现测试接口(为 smbus_set_eid_to_endpoint 补入新增的首参 ep_name),并将 engine/discovery 构造收敛到每用例的 setup()、新增 teardown() 统一恢复 create_endpoint 桩并清理失败 EID 列表,同时移除了用例尾部的手动 restore()。改动聚焦测试,逻辑正确,git diff --check 及 CI(编译/UT/IT/覆盖率/pre-commit)均通过。

📋 检视概览

项目 详情
评级 良好
严重问题 0
警告 0
建议 0

已确认修复的问题 ✅(对应上一轮 openubmc-ci-bot 的两条意见)

  1. teardown 清理 EID 硬编码魔法数 ✅ 已修复:EID 已提升为类成员 self.target_eid = 9(setup() 中统一赋值),teardown() 改为 smbus_set_eid_remove(self.target_eid),与用例保持一致,清理不再静默失效。
  2. 新增 teardown 后用例中的手动 restore() 可简化 ✅ 已修复:成功/失败两个用例末尾的手动 restore() 调用均已移除,stub_endpoints 亦不再返回恢复函数(返回体已删除),清理逻辑统一收敛到 fixture 的 teardown()。

需关注的问题(已关联代码行)

# 文件 行 级别 说明
- - - - 无新增问题

补充说明

  • teardown() 中无条件调用的 smbus_set_eid_remove(self.target_eid) 在 mctp_discovery.lua 内部有 if failed_tb then ... end 判空保护,即使目标 EID 从未加入失败列表(如 success/init/req_failed 用例)也安全,行为正确。
  • 该文件为纯测试变更,无生产代码/版权/年份/许可证改动,符合仓库规范。

结论:本轮变更无阻塞项,建议合入。

likedislike
Oopenubmc-ci-botCollaborators
23 days ago Removed label: ci-running
openubmc-ci-botCollaborators
23 days ago Comments:
任务名称结果
pre-commit检查✅ SUCCESS
PR描述检查✅ SUCCESS
防投毒检查✅ SUCCESS
开源合规检查✅ SUCCESS
编译构建✅ SUCCESS
UT测试✅ SUCCESS
IT测试✅ SUCCESS
代码覆盖率✅ SUCCESS
修改行数检查✅ SUCCESS
头文件检查✅ SUCCESS
AI Review✅ SUCCESS
likedislike
Oopenubmc-ci-botCollaborators
23 days ago Added label: ci-successful