news 2026/7/15 8:06:10

HCCL_VM单元测试脚本

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
HCCL_VM单元测试脚本

HCCL_VM UT Test Execution Script

【免费下载链接】hcommHCOMM(Huawei Communication)是HCCL的通信基础库,提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm

Overview

run_ut.shis the unit test execution script for the HCCL_VM project, used to automate the compilation and execution of test cases.

Three-Step Process

The script automatically completes the following steps during execution:

StepDescriptionLog Output
Step 1CMake configuration + make compilationbuild.log
Step 2Generate executable filesLists all binaries with size/time
Step 3Execute test cases and display resultsrun.log+summary.log
Step 4Generate gcov/lcov coverage HTML report (requires--cov)coverage.log

Usage

cd {HCCL_VM_PATH}/test # Basic usage ./run_ut.sh # Full compilation + execute all tests ./run_ut.sh --cov # Full compilation + execution + generate gcov/lcov coverage HTML report ./run_ut.sh <directory> # Compile + execute all tests in specified directory (recursive) ./run_ut.sh <binary_name> # Compile + execute specified test binary ./run_ut.sh <test_file_name> # Compile + execute the binary corresponding to the specified test file ./run_ut.sh <file> <test_case_name> # Compile + execute a single test case in the specified file # Other commands ./run_ut.sh -l, --list # List all available tests ./run_ut.sh -h, --help # Display help information

Command Details

1. Full Execution

./run_ut.sh
  • Executes all tests in thetestdirectory.
  • Complete three-step process: compilation → generate executables → run all tests.
  • Suitable for full regression testing.

2. Coverage Report

./run_ut.sh --cov
  • Full compilation + execute all tests + generate gcov/lcov coverage HTML report.
  • Automatically enables the--coveragecompilation flag, generating.gcno/.gcdafiles.
  • Four-step process: compilation (with coverage instrumentation) → execution → collect coverage data → generate HTML report.
  • Report output path:$CODE_DIR/coverage_report/html/index.html.
  • Automatically filters system headers, third-party libraries, stub files, and other non-business code.

3. Directory Execution

./run_ut.sh plugin/checker ./run_ut.sh plugin/ccu_executor ./run_ut.sh store
  • Recursively finds all*_test.ccfiles in the specified directory.
  • Compiles and executes all tests in that directory.
  • Suitable for module-level testing.

4. Binary Execution

./run_ut.sh test_checker ./run_ut.sh test_allgather_semantics_checker
  • Compiles and executes the specified test binary.
  • Binary names start withtest_.

5. File Execution

./run_ut.sh checker_test.cc ./run_ut.sh allgather_semantics_checker_test.cc
  • Automatically matches the corresponding binary based on the test file name.
  • Compiles and executes.

6. Single Test Case Execution

./run_ut.sh checker_test.cc CheckerTest.GenAndCheckGraph_EmptyQueues ./run_ut.sh allgather_semantics_checker_test.cc AllgatherSemanticsCheckerTest.CheckBasic
  • Executes a single test case in the specified test file.
  • Test case name format:TestSuiteName.TestCaseName.

7. List Tests

./run_ut.sh -l ./run_ut.sh --list
  • Lists all available test files and their status.
  • Displays the number of test cases and corresponding binary names.

Examples

# Example 1: Full test ./run_ut.sh # Example 2: Full test + coverage report ./run_ut.sh --cov # Example 3: Execute all tests in the plugin/checker directory ./run_ut.sh plugin/checker # Example 4: Compile and execute test_checker ./run_ut.sh test_checker # Example 5: Compile and execute the binary corresponding to checker_test.cc ./run_ut.sh checker_test.cc # Example 6: Execute a single test case ./run_ut.sh checker_test.cc CheckerTest.GenAndCheckGraph_EmptyQueues # Example 7: List all tests ./run_ut.sh -l

Log Directory

Each execution generates log files underut_logs/<timestamp>/:

{HCCL_VM_PATH}/ut_logs/20260425_142048/ ├── build.log # Detailed compilation log (cmake + make output) ├── run.log # Detailed execution log (full output of each test) └── summary.log # Summary log (execution result of each test)

Log File Description

FileContent
build.logCMake configuration output, make compilation output, list of generated executables
run.logFull output of each test (including gtest details)
summary.logExecution status, pass/fail count, and time summary for each test

Execution Results

After the script finishes, summary information is displayed:

======================================== Directory Test Result Summary: plugin/checker ======================================== Executed: 16 PASSED: 185 FAILED: 8 CRASHED: 0 TIMEOUT: 0

Status Description

StatusDescription
PASSTest passed
FAILTest failed (assertion failure)
CRASHTest crashed (core dump)
TIMEOUTTest timed out (default 60 seconds)

Directory Structure

test/ ├── run_ut.sh # This script ├── cmd/ # Command-related tests │ ├── base/ │ ├── subcmds/ │ └── utils/ ├── device_arm/ # Device-related tests ├── device_vir/ ├── ipc/ # IPC-related tests │ └── shm/ ├── log/ # Log-related tests ├── plugin/ # Plugin-related tests │ ├── ccu_executor/ │ │ ├── control_type/ │ │ ├── load_type/ │ │ ├── reduce_type/ │ │ └── trans_type/ │ └── checker/ │ └── framework/ │ ├── mem_conflict_check/ │ ├── semantics_check/ │ └── singletask_check/ ├── proxy/ # Proxy-related tests │ ├── level1/ │ └── level2/ ├── runnerdb/ # Database-related tests ├── store/ # Storage-related tests │ └── hccl_shm/ └── src_root/ # Source root directory tests

Environment Requirements

Before executing the script, you must modify the following environment variables inrun_ut.shto use the actual paths:

# The following are example paths. Modify them according to your actual environment. export HCOMM_CODE_HOME=/home/q30033976/checker/hcomm # hcomm source code path export HCCL_CODE_HOME=/home/q30033976/checker/hccl # hccl source code path (required for AIV/AICPU mode) source /home/q30033976/checker/Ascend/cann/set_env.sh # CANN environment script path

Example: If your working directory is/home/workspace, modify the settings to:

export HCOMM_CODE_HOME=/home/workspace/hcomm export HCCL_CODE_HOME=/home/workspace/hccl source /home/workspace/Ascend/cann/set_env.sh

The script will automatically load these environment variables. Failure to modify them will result in compilation errors.

Configuration Parameters

The script has the following built-in configuration (can be modified at the beginning of the script):

ParameterDefault ValueDescription
CMAKE_BUILD_TYPEDebugCMake build type
MAKE_JOBS8Number of parallel make jobs
LOG_DIR$CODE_DIR/ut_logsLog output directory

Notes

  1. First execution: The first execution will perform a complete CMake configuration, which takes a longer time.
  2. Compilation failure: If compilation fails, checkbuild.logfor detailed error information.
  3. Test failure: If tests fail, checkrun.logfor the specific failing test cases.
  4. Log cleanup: Log directories are named by timestamp. Clean up old logs periodically to save space.

Frequently Asked Questions

Q: How to compile without executing?

A: The current script integrates compilation and execution. To compile only, use cmake and make directly:

cd {HCCL_VM_PATH}/build cmake .. && make -j8 test_checker

Q: How to view detailed output of a specific test?

A: Check therun.logfile, which contains the complete gtest output for each test.

Q: What to do if a test times out?

A: The default timeout is 60 seconds. You can modify thetimeout_secparameter in the script.

Q: How to add new tests?

A: Create a*_test.ccfile in the corresponding directory and add the build target to the correspondingCMakeLists.txt.

Viewing Coverage Reports

After generating the HTML coverage report on Linux, start an HTTP server to view it:

cd <coverage_report/html directory> python3 -m http.server 8080
  • Access via local browser:http://localhost:8080.
  • For remote servers, use SSH port forwarding to access locally:
ssh -L 8080:localhost:8080 <user>@<server_ip> # Then open http://localhost:8080 in your local browser

Press^Cto stop the server.

Version History

  • v1.0 - Initial version, supports full/directory/file/test-case-level test execution.
  • v2.0 - Optimized command-line parameters, supports automatic path derivation, three-step process logging.
  • v2.1 - Added--covparameter, supports gcov/lcov coverage HTML report generation.

【免费下载链接】hcommHCOMM(Huawei Communication)是HCCL的通信基础库,提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/15 8:06:08

CANN/asc-devkit SIMD向量减法API文档

asc_sub 【免费下载链接】asc-devkit 本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言&#xff0c;原生支持C和C标准规范&#xff0c;主要由类库和语言扩展层构成&#xff0c;提供多层级API&#xff0c;满足多维场景算子开发诉求。 项目地址: https://gitcode.com/ca…

作者头像 李华
网站建设 2026/7/15 8:03:53

计算机网络物理层核心概念与典型习题精讲(附详细解析)

1. 物理层在计算机网络体系中的定位物理层是OSI七层模型和TCP/IP四层模型中最底层的基础设施&#xff0c;相当于网络通信的"高速公路路基"。它不关心数据的具体含义&#xff0c;只负责将比特流从一个节点搬运到另一个节点。就像快递员不需要知道包裹里装的是什么&…

作者头像 李华
网站建设 2026/7/15 8:03:50

ngx-ui主题与样式定制:快速创建品牌化UI界面的终极指南

ngx-ui主题与样式定制&#xff1a;快速创建品牌化UI界面的终极指南 【免费下载链接】ngx-ui &#x1f680; Style and Component Library for Angular 项目地址: https://gitcode.com/gh_mirrors/ng/ngx-ui ngx-ui是一个强大的Angular组件和样式库&#xff0c;由Swimlan…

作者头像 李华
网站建设 2026/7/15 8:03:06

从理论到实践:基于LabVIEW与USRP的无线通信系统核心模块构建指南

1. 初识LabVIEW与USRP的无线通信系统第一次接触LabVIEW和USRP时&#xff0c;我完全被这种图形化编程与软件无线电的结合方式震撼到了。作为一个通信工程专业的学生&#xff0c;以前只能在课本上看到的调制解调、信道编码等概念&#xff0c;现在居然可以通过拖拽图标就能实现&am…

作者头像 李华
网站建设 2026/7/15 8:02:59

Agent 每次调用工具都要问用户吗?Janus 揭示权限管理的三难困境

未来的 Agent 安全&#xff0c;不只是要检测提示注入&#xff0c;也不只是要给工具加权限开关。更重要的是建立一套能够理解上下文、约束工具行为、管理用户授权、记录执行链路的权限决策层。Agent 的安全问题&#xff0c;正在从“模型说了什么”转向“模型做了什么”。当 Agen…

作者头像 李华