| 平台 | 目标 |
| windows | simulator |
| linux | — |
| lm620 | r4f4 |
覆盖 xt_event(事件管理) 事件发布订阅模块的核心功能,共 **7 组 33 项测试**。
测试分组
| 分组 | 测试项数 | 内容 |
| 1. 基本功能 | 11 | setup、subscribe、unsubscribe、publish、publish_sync、handler、get_current |
| 2. 去重与匹配 | 3 | 去重不增加计数、unsub 不影响其他、填满后 unsub+resub |
| 3. 重入 | 6 | 回调中 subscribe/unsubscribe、嵌套 publish、嵌套修改外层 |
| 4. dispatch 位图清除 | 3 | unsub+resub 防误通知、嵌套位图清除、无临界锁 |
| 5. 嵌套与隔离 | 3 | 三层嵌套、事件隔离、第 6 层拒绝 |
| 6. 补充场景 | 2 | handler 空队列、subscribe 后 publish_sync |
| 7. handler 重入 | 5 | handler 内 subscribe/unsubscribe/publish、多事件、事件顺序 |
预期行为
- **订阅去重**:相同 (event_id, callback) 不增加计数,不同事件的相同 callback 互不影响
- **同步分发**:publish_sync 立即回调所有订阅者,支持嵌套最多 5 层
- **异步分发**:publish 入队后由 handler 处理,handler 内 publish 不入本轮分发
- **重入安全**:回调中 unsubscribe 立即生效(位图清除),subscribe 下一轮生效
- **位图清除**:同时清除所有活跃 dispatch 帧的位图 bit
编译和运行
cd tests/xt_event
xt --target windows/simulator fullclean build
xt --target windows/simulator run
故障排除