Skip to content

test: add peek-fd testing and builtin coverage for peek-fd tool#107

Open
yuKing123-king wants to merge 1 commit into
DKapture:mainfrom
yuKing123-king:test/peek-fd
Open

test: add peek-fd testing and builtin coverage for peek-fd tool#107
yuKing123-king wants to merge 1 commit into
DKapture:mainfrom
yuKing123-king:test/peek-fd

Conversation

@yuKing123-king

Copy link
Copy Markdown
Contributor

本次修改集中在 test 目录,修改内容如下

  1. 添加了 peek-fd 的 BUILTIN 单测。测试内容围绕工具实际功能补充了较完整的回归验证,覆盖了以下几类行为:
    • 帮助信息输出:验证 -h/--help 能正常打印 usage,并包含 pid、fd、read、write、outfile、sock 等选项说明。
    • 非法参数处理:验证传入非法选项时会返回错误,并输出 usage,保证参数校验路径正确。
    • 必选参数校验:验证缺少 pid / fd 时会报错,缺少 read / write 模式时也会报错,确保工具使用约束正确。
    • 默认输出行为:验证未指定 --outfile 时,匹配到的 FD 数据会写到当前标准输出。
    • 输出重定向行为:验证指定 --outfile 后,匹配数据会写入目标文件,不会误写回默认输出文件。
    • read 过滤语义:验证只开启 --read 时,仅匹配读事件,写事件、错误 pid、错误 fd 事件都会被过滤。
    • write 过滤语义:验证只开启 --write 时,仅匹配写事件,读事件和错误 fd 事件都会被过滤。
    • read + write 联合语义:验证同时开启 --read --write 时,读写两类事件都能正常输出。
    • sock 过滤语义:验证只有显式开启 --sock 时,socket 类型 FD 事件才会输出;未开启时,普通 FD 事件仍可输出,但 socket 事件会被过滤。
    • 多条件组合过滤:验证 pid、fd、read/write、sock 多个条件组合后,只有真正满足全部条件的事件会输出。
    • 日志输出行为:验证匹配规则的 FD 数据会真正写入输出,不匹配事件不会误输出,确保过滤结果和最终日志一致。
  2. 在test/Makefile 中补齐测试目标的链接依赖;
  3. 在test/mock.cpp 中修正 skeleton 对象在全局容器中的分配、指针回填和销毁逻辑,避免因扩容和错索引导致的崩溃;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant