utest: fix hooklist testcase reinit#11521
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: kernelReviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-06-26 15:59 CST)
📝 Review Instructions
|
|
|
||
| rt_thread_detach(&thr_tobe_inited); | ||
| rt_thread_mdelay(1); /* wait recycling done */ | ||
| cleanup_thr_tobe_inited(); |
There was a problem hiding this comment.
线程有 cleanup 回调,可以设置下,在回调里面处理
down
0993903 to
428d18f
Compare


为什么提交这份 PR (why to submit this PR)
修复 core.hooklist 用例在重复运行时偶现 rt_object_init 中 obj != object 断言失败的问题。
根因是测试中复用了静态线程对象 thr_tobe_inited。原实现通过 rt_thread_detach() 后延时 1 tick 等待回收,但 detach 的实际 object detach 依赖 defunct 回收时机,重复执行时可能在对象还留在线程对象链表中时再次调用 rt_thread_init(),从而触发重复对象断言。
你的解决方案是什么 (what is your solution)
为测试线程增加同步清理逻辑:测试线程从未启动,因此在清理时先关闭线程内部 timer,再同步从 object 容器中 detach,避免依赖异步 defunct 回收。
同时在 testcase init/cleanup 和 hook 注册前清理残留 hook 节点,保证重复运行 core.hooklist 时测试状态干净,不影响原本验证 rt_thread_inited_sethook() / rt_thread_inited_rmhook() 的目的。
请提供验证的 bsp 和 config (provide the config and bsp)
BSP: bsp/qemu-vexpress-a9
.config:
action: 本地验证
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I have considered the following: