当前位置: 首页 > news >正文

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),仅供参考

http://www.cnnetsun.cn/news/3392487.html

相关文章:

  • CANN/asc-devkit SIMD向量减法API文档
  • 计算机网络物理层核心概念与典型习题精讲(附详细解析)
  • ngx-ui主题与样式定制:快速创建品牌化UI界面的终极指南
  • 从理论到实践:基于LabVIEW与USRP的无线通信系统核心模块构建指南
  • Agent 每次调用工具都要问用户吗?Janus 揭示权限管理的三难困境
  • 提升用户体验:UITextField-Shake在表单验证中的最佳实践 [特殊字符]
  • Python ctypes调用C DLL实战:从基础到高级应用
  • OpenVINO版本升级指南:从旧版本迁移到2024.3.0在openEuler上的注意事项
  • 【限时解密】ChatGPT竞品技术底牌:MoE架构差异、上下文窗口压缩算法、推理加速芯片兼容性——一线厂商CTO亲授3个未公开参数
  • 终极Blender 3MF插件指南:如何完美解决3D打印格式兼容性问题
  • MMPlayerView:打造如YouTube般流畅的自定义AVPlayerLayer视频播放体验
  • DLPA100电源管理与电机驱动芯片在4K UHD显示系统中的应用与设计
  • PythonOcc进阶——基于零件形心的智能爆炸图生成与交互式UI设计
  • Unity游戏多语言实时翻译解决方案:XUnity.AutoTranslator深度解析
  • AI视频分析技术深度解析足球明星互动情感细节
  • 2026年Spine安装与配置全攻略:从下载到上手指南
  • S25FL256S Quad SPI Flash在FPGA中的高效驱动与实战优化
  • 从训练到部署:YOLOv5自定义模型在RK3588上的端到端实时摄像头应用
  • 如何扩展kaniko:自定义构建上下文和存储后端的实现方法
  • 基于MATLAB/Simulink的无刷直流电机双闭环调速系统建模与仿真实践
  • 从零构建Android远程控制工具:MediaProjection与WebSocket实战
  • 【环境管理实战】从零开始:用Miniconda搭建你的第一个Python隔离开发环境
  • 66AK2G12时钟与接口时序设计:从PLL配置到GPMC同步模式实战
  • Claude Code国产化适配指南:CC Switch+settings.json本地部署实战
  • Jekyll Compose社区生态:10个提升写作效率的相关工具和资源推荐
  • PyTumblr高级内容管理:队列、草稿、提交和标签搜索的Python自动化实现
  • 显卡性能调校的终极进化:NVIDIA Profile Inspector的深度哲学
  • ABAP 对接钉钉待办:从证书配置到任务创建实战
  • 嵌入式引脚复用配置实战:从TDA3手册到工程代码的完整指南
  • VASSAL引擎:3步解决远程桌面游戏痛点,开启你的虚拟桌游革命