Skip to content

Add: unit tests for C++ runtime modules and Python utilities#427

Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:add-unit-tests-cpp-and-python
Open

Add: unit tests for C++ runtime modules and Python utilities#427
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:add-unit-tests-cpp-and-python

Conversation

@chenshengxin2026
Copy link
Copy Markdown
Contributor

Summary

  • Add tests/ut/cpp/ with GoogleTest-based unit tests for the a2a3 tensormap_and_ringbuffer runtime: ring buffer, scheduler, tensormap, shared memory, ready queue, and type-level tests (core, submit, tensor, dispatch payload, pto types)
  • Add tests/ut/test_elf_parser.py: 12 tests covering ELF64 and Mach-O .text section extraction
  • Add tests/ut/test_env_manager.py: 7 tests covering environment variable caching and error handling
  • Add ut-cpp CI job to .github/workflows/ci.yml to build and run C++ tests on ubuntu-latest (no hardware required)

Two tests in test_ring_buffer intentionally 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

  • All 19 new Python unit tests pass (test_elf_parser.py, test_env_manager.py)
  • C++ tests build and run: 9/10 test binaries pass, test_ring_buffer has 2 intentional bug-candidate failures
  • Simulation tests pass (not required for UT-only changes)
  • Hardware tests pass (not required for UT-only changes)

- 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.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant