skills/openharmony-ut/SKILL.md
Automate OpenHarmony unit test and fuzz test workflows including test generation, compilation, deployment to devices, and execution. Use when writing, building, or running UT/FuzzTest for OpenHarmony projects.
npx skillsauth add openharmonyinsight/openharmony-skills openharmony-utInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
重要:在执行任何操作前,必须先收集用户配置信息。
首次使用此 skill 时,请按以下顺序询问用户配置:
请输入 OpenHarmony 项目根目录路径
默认:/root/OpenHarmony
请输入编译产物输出路径
默认:${项目根目录}/out/rk3568/tests
请输入编译命令
模板(使用 ${OH_ROOT} 和 ${TARGET} 变量)
默认:cd ${OH_ROOT} && ./build.sh --product-name=rk3568 --build-target ${TARGET}
请输入 Windows 机器的 IP 地址(用于 hdc 连接)
格式:x.x.x.x
端口固定使用 8710
自动获取选项:如果当前环境是 WSL,可以先尝试自动获取:
WIN_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
echo $WIN_IP
询问用户是否使用自动获取之后的 IP,或手动输入。
配置完 IP 后,必须依次执行以下验证步骤,确保设备可用:
ping -c 3 ${WINDOWS_IP}
判断标准:
失败处理:
❌ 无法 ping 通 ${WINDOWS_IP}
请检查:
1. Windows 机器是否开机
2. 网络连接是否正常
3. IP 地址是否正确
4. Windows 防火墙是否允许 ping(ICMP)
nc -zv -w 3 ${WINDOWS_IP} 8710
判断标准:
succeeded! 或 Connection to xxx 8710 port [tcp/*] succeeded!timed out 或 Connection refused失败处理:
❌ 无法连接到 ${WINDOWS_IP}:8710
请检查:
1. HDC 服务是否在 Windows 上启动
2. 端口 8710 是否被防火墙阻止
3. hdc_std.exe 是否在 Windows 上运行
启动 HDC 服务方法(Windows 管理员权限 PowerShell):
hdc_std start -l
hdc -s ${WINDOWS_IP}:8710 list targets
判断标准:
xxxxx[Empty] 或报错失败处理:
❌ 未检测到可用设备
请检查:
1. OpenHarmony 设备是否开机
2. 设备是否通过 USB 连接到 Windows 机器
3. hdc_std 是否正确识别设备
手动查看设备(Windows 上执行):
hdc_std list targets
hdc -s ${WINDOWS_IP}:8710 shell "echo 'connection OK'"
判断标准:
connection OK失败处理:
❌ Shell 连接失败
请检查 hdc 版本兼容性
收集到的配置将存储为以下变量,后续命令中使用:
OH_ROOT - 项目根目录OH_OUTPUT - 编译产物路径BUILD_CMD - 编译命令模板WINDOWS_IP - Windows IP,端口固定为 8710cd ${OH_ROOT}/ && ${BUILD_CMD} <TARGET_NAME>
hdc -s ${WINDOWS_IP}:8710 shell "mkdir -p /data/test/"
hdc -s ${WINDOWS_IP}:8710 file send <TARGET_PATH> /data/test
hdc shell -s ${WINDOWS_IP}:8710 "chmod +x /data/test/<TARGET_NAME> && /data/test/<TARGET_NAME>"
当用户请求"编写并运行"或类似明确包含编写意图时,按以下顺序执行:
/data/test/当用户仅说"运行用例"、"跑一下这个用例"等,没有明确提及编写或修改代码时:
先查找编译产物 - 检查是否已有编译好的文件:
cd ${OH_OUTPUT}/ && find . -name <TARGET_NAME>
如果找到 - 直接跳到部署步骤
如果找不到 - 再执行编译,然后继续部署运行
判断依据:用户请求是否包含"编写"、"写"、"生成"、"创建"等动词
LnnNetBuilderFuzzTest)testing
--- name: ohos-req-value-decision description: Use after review meeting to record decision and route to next step. Triggers: 评审决策纪要, 评审结论回流, value decision, 评审接纳, 评审不接纳, 评审退回, 下次重新上会. Do NOT use for feature baseline (ohos-req-feature-baseline), review gate checks (ohos-req-review-gate), or IR generation (ohos-req-feature-to-ir). metadata: author: openharmony scope: common stage: requirements capability: value-decision version: 0.3.0 status: draft tags: - sdd - requirements
development
Use when converting an OpenHarmony requirement document, spec, or design proposal into an OpenHarmony review slide deck (需求评审 / 需求变更评审 / 设计评审 PPTX) — produces the fixed OpenHarmony-branded review-deck structure (OH logo on every page) with architecture/flow diagrams and field tables. Triggers on "需求评审PPT", "需求变更评审", "把需求文档转成评审PPT", "spec转评审PPT", "requirement/spec to review deck". NOT for arbitrary or generic slide decks unrelated to OpenHarmony requirement/design review.
testing
Use when performing the Phase 0 Step 0.5 Review Ready Gate on a 04-feature.md, especially when the user says "evaluate gate", "review readiness", "feature ready?", "should we generate IR", or when the ohos-req-intake-orchestration main session needs a structured Ready / Conditional Ready / Not Ready judgment instead of doing the check inline. Reads 01-04, runs seven fixed checks plus a conditional-items check, and returns a machine-readable JSON summary plus a human-readable table that the main session can route on. Do NOT use for feature baseline generation (ohos-req-feature-baseline), value decision recording (ohos-req-value-decision), or IR generation (ohos-req-feature-to-ir).
testing
--- name: ohos-req-requirement-intake description: Use when importing an OHOS requirement into Phase 0.1, especially for 01-requirement.md, requirement intake, background, user value, scenarios, scope, FR/NFR, affected modules, or priority. Triggers: 需求导入, 01-requirement, 需求基线, RR单号. Do NOT use for feasibility analysis (ohos-req-feasibility-analysis), architecture decision (ohos-req-arch-decision), or feature baseline (ohos-req-feature-baseline). metadata: author: openharmony scope: common