HCCL_VM UT Test Execution Script【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcommOverviewrun_ut.shis the unit test execution script for the HCCL_VM project, used to automate the compilation and execution of test cases.Three-Step ProcessThe script automatically completes the following steps during execution:StepDescriptionLog OutputStep 1CMake configuration make compilationbuild.logStep 2Generate executable filesLists all binaries with size/timeStep 3Execute test cases and display resultsrun.logsummary.logStep 4Generate gcov/lcov coverage HTML report (requires--cov)coverage.logUsagecd {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 informationCommand Details1. Full Execution./run_ut.shExecutes 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 --covFull 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 storeRecursively 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_checkerCompiles 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.ccAutomatically 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.CheckBasicExecutes 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 --listLists 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 -lLog DirectoryEach 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 DescriptionFileContentbuild.logCMake configuration output, make compilation output, list of generated executablesrun.logFull output of each test (including gtest details)summary.logExecution status, pass/fail count, and time summary for each testExecution ResultsAfter the script finishes, summary information is displayed: Directory Test Result Summary: plugin/checker Executed: 16 PASSED: 185 FAILED: 8 CRASHED: 0 TIMEOUT: 0Status DescriptionStatusDescriptionPASSTest passedFAILTest failed (assertion failure)CRASHTest crashed (core dump)TIMEOUTTest timed out (default 60 seconds)Directory Structuretest/ ├── 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 testsEnvironment RequirementsBefore 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 pathExample: 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.shThe script will automatically load these environment variables. Failure to modify them will result in compilation errors.Configuration ParametersThe script has the following built-in configuration (can be modified at the beginning of the script):ParameterDefault ValueDescriptionCMAKE_BUILD_TYPEDebugCMake build typeMAKE_JOBS8Number of parallel make jobsLOG_DIR$CODE_DIR/ut_logsLog output directoryNotesFirst execution: The first execution will perform a complete CMake configuration, which takes a longer time.Compilation failure: If compilation fails, checkbuild.logfor detailed error information.Test failure: If tests fail, checkrun.logfor the specific failing test cases.Log cleanup: Log directories are named by timestamp. Clean up old logs periodically to save space.Frequently Asked QuestionsQ: 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_checkerQ: 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 ReportsAfter generating the HTML coverage report on Linux, start an HTTP server to view it:cd coverage_report/html directory python3 -m http.server 8080Access via local browser:http://localhost:8080.For remote servers, use SSH port forwarding to access locally:ssh -L 8080:localhost:8080 userserver_ip # Then open http://localhost:8080 in your local browserPress^Cto stop the server.Version Historyv1.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.【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考