oh-capi-xts-gen

Generate OpenHarmony CAPI XTS mode-2 tests from C header declarations.

31|6|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-capi-xts-gen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: oh-capi-xts-gen
Source: https://github.com/openharmonyinsight/openharmony-skills/tree/main/skills/oh-capi-xts-gen
Command: npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill oh-capi-xts-gen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill removes the repetitive work of writing OpenHarmony CAPI XTS tests by generating N-API (mode 2) wrapper tests and matching ETS/ArkTS test cases directly from C header (.h) definitions, including validation and optional coverage-report-driven incremental generation.

Core Features & Use Cases

  • .h 头文件解析:从 C API 声明中提取函数签名、参数与返回信息,形成可用于生成的结构化上下文。
  • N-API 封装与 ETS 测试生成(方式2):自动生成 C++ N-API 封装代码和 ETS/ArkTS 测试代码,遵循 hypium/XTS 命名与断言规范。
  • 覆盖率驱动的补充测试:当用户提供覆盖率报告或缺失测试项时,按缺失 API/参数组合/测试场景生成补测用例,避免无谓的全量分析。
  • 强制 N-API 三重校验 + 可选编译验证:在生成后完成注册一致性、index.d.ts 一致性、ETS 调用一致性校验,并可进一步执行编译验证(Linux/Windows 工作流)。

Quick Start

Use the oh-capi-xts-gen skill to generate CAPI N-API XTS tests for subsystem Hilog and API HiLogPrint by providing the API name and your OpenHarmony root path configured in the skill config.

Frequently Asked Questions about oh-capi-xts-gen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate OpenHarmony CAPI XTS tests from C header files?

Generating OpenHarmony CAPI XTS tests from C header files involves parsing .h API declarations to extract function signatures, then producing C++ N-API wrapper code and matching ETS/ArkTS test cases following hypium naming conventions.

What is N-API mode-2 testing in OpenHarmony and when is it needed?

N-API mode-2 testing in OpenHarmony wraps C APIs into C++ N-API modules for ETS/ArkTS invocation. It is needed when validating CAPI subsystems via XTS test suites, requiring strict triple verification across C++ registration, index.d.ts declarations, and ETS testNapi calls.

Can I use coverage reports to generate incremental missing CAPI test cases?

Yes, you can use coverage reports to generate incremental missing CAPI test cases. By providing coverage reports or missing test items, the system generates supplementary tests for missing APIs, parameter combinations, or test scenarios without performing redundant full-suite analysis.

Does OpenHarmony CAPI XTS generation support compilation verification for N-API wrappers?

Yes, OpenHarmony CAPI XTS generation supports compilation verification for N-API wrappers. After enforcing N-API triple consistency checks, it can execute optional compilation verification workflows on Linux and Windows to validate the generated C++ and ETS/ArkTS test code.

What are the limitations of automated CAPI XTS test generation for ArkTS?

A key limitation of automated CAPI XTS test generation is its strict enforcement of mode-2 (N-API) only, meaning it does not support other testing modes. Additionally, it requires precise C header parsing and mandatory triple verification to prevent registration or declaration inconsistencies.