Add: unit tests for C++ runtime modules and Python utilities#427
Add: unit tests for C++ runtime modules and Python utilities#427chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
Conversation
- Add tests/ut/cpp/ with GoogleTest-based UTs for the a2a3 tensormap_and_ringbuffer runtime: ring buffer, scheduler, tensormap, shared memory, ready queue, core/submit/tensor/dispatch types - Add tests/ut/test_elf_parser.py: ELF64 and Mach-O .text extraction - Add tests/ut/test_env_manager.py: environment variable cache - Add ut-cpp CI job to run C++ tests on ubuntu-latest (no hardware) Two tests in test_ring_buffer expose known bugs in the ring buffer heap wrap-around and dep-pool entry-0 conflict logic; they are intentionally failing until the underlying bugs are fixed.
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive suite of unit tests for the runtime system, covering core types, scheduling logic, memory management, and tensor operations. It includes a CMake configuration for building these tests with GoogleTest, along with platform stubs for x86 compatibility. Feedback was provided to improve the robustness of a CMake helper function by ensuring it verifies the existence of all source files, including extra sources, to prevent potential build failures.
| function(add_gtest_target name) | ||
| cmake_parse_arguments(ARG "" "" "SOURCES;EXTRA_SOURCES" ${ARGN}) | ||
| # Check all source files exist | ||
| foreach(src ${ARG_SOURCES}) |
There was a problem hiding this comment.
The foreach loop for checking source file existence only iterates over ARG_SOURCES. It should also check files in ARG_EXTRA_SOURCES to prevent build failures when an extra source file is missing or misspelled. This will make the helper function more robust.
foreach(src ${ARG_SOURCES} ${ARG_EXTRA_SOURCES})
Summary
tests/ut/cpp/with GoogleTest-based unit tests for thea2a3tensormap_and_ringbufferruntime: ring buffer, scheduler, tensormap, shared memory, ready queue, and type-level tests (core, submit, tensor, dispatch payload, pto types)tests/ut/test_elf_parser.py: 12 tests covering ELF64 and Mach-O.textsection extractiontests/ut/test_env_manager.py: 7 tests covering environment variable caching and error handlingut-cppCI job to.github/workflows/ci.ymlto build and run C++ tests onubuntu-latest(no hardware required)Two tests in
test_ring_bufferintentionally fail to expose known bugs in heap wrap-around and dep-pool entry-0 conflict logic; they will pass once the underlying bugs are fixed.Testing
test_elf_parser.py,test_env_manager.py)test_ring_bufferhas 2 intentional bug-candidate failures