Summary
Tracking issue for unit test (UT) development across the simpler project. The goal is to build comprehensive offline-runnable unit tests for C++ runtime modules and Python utilities, enabling faster development iteration without requiring hardware.
Current Progress
Initial UT infrastructure and first batch of tests landed in PR #427 (add-unit-tests-cpp-and-python branch):
C++ Unit Tests (tests/ut/cpp/) — GoogleTest-based
Covering the a2a3/tensormap_and_ringbuffer runtime:
Test File
Module Under Test
Status
test_ring_buffer.cpp
pto_ring_buffer.h/cpp
2 intentional failures (expose known heap wrap-around & dep-pool entry-0 bugs)
test_scheduler_state.cpp
pto_scheduler.h/cpp
Pass
test_tensormap.cpp
pto_tensormap.h/cpp
Pass
test_shared_memory.cpp
pto_shared_memory.h/cpp
Pass
test_ready_queue.cpp
ready queue logic
Pass
test_core_types.cpp
core type definitions
Pass
test_submit_types.cpp
pto_submit_types.h
Pass
test_tensor.cpp
tensor.h
Pass
test_dispatch_payload.cpp
pto2_dispatch_payload.h
Pass
test_pto_types.cpp
pto_types.h
Pass
Python Unit Tests (tests/ut/) — pytest-based
Test File
Module Under Test
Status
test_elf_parser.py
python/elf_parser.py
12 tests, all pass
test_env_manager.py
python/env_manager.py
7 tests, all pass
test_task_interface.py
python/task_interface.py (nanobind bindings)
Pass
test_runtime_builder.py
python/runtime_compiler.py + examples/scripts/runtime_builder.py
Pass
test_chip_worker.py
src/common/worker/chip_worker.h/cpp
Pass
CI
ut-cpp job added to .github/workflows/ci.yml — builds and runs C++ tests on ubuntu-latest (no hardware required)
Remaining Coverage Gaps
C++ — High Priority
aicpu_build_graph runtime — pto_runtime2, pto_orchestrator, pto_scheduler, pto_shared_memory, pto_ring_buffer (shared source with tensormap_and_ringbuffer but different build config)
host_build_graph runtime — runtime.h/cpp, aicore/aicpu executors
Platform modules — memory_allocator, function_cache, host_regs, raii_scope_guard, runtime_compile_info (host-side, testable offline)
Common modules — task_interface/task_args.h, data_type.h, arg_direction.h type correctness tests
a5 architecture — verify tests also compile against a5 headers (shared runtime source)
Python — Medium Priority
Infrastructure
Motivation / Use Case
Unit tests that run offline (no Ascend hardware) enable:
Faster CI feedback — catch regressions in seconds, not minutes
Safer refactoring — runtime internals (ring buffer, scheduler, shared memory) are complex and subtle
Bug detection — the initial batch already found 2 bugs in ring buffer logic
Developer onboarding — tests serve as executable documentation of module contracts
Proposed Approach
C++ tests use GoogleTest with lightweight stubs for platform headers (no hardware dependency)
Python tests use pytest with mocking for external dependencies (compilers, file system)
Tests target module-level contracts, not integration behavior
Bug-exposing tests are kept with correct expected values; they fail until the bug is fixed
Additional Context
Summary
Tracking issue for unit test (UT) development across the simpler project. The goal is to build comprehensive offline-runnable unit tests for C++ runtime modules and Python utilities, enabling faster development iteration without requiring hardware.
Current Progress
Initial UT infrastructure and first batch of tests landed in PR #427 (
add-unit-tests-cpp-and-pythonbranch):C++ Unit Tests (
tests/ut/cpp/) — GoogleTest-basedCovering the
a2a3/tensormap_and_ringbufferruntime:test_ring_buffer.cpppto_ring_buffer.h/cpptest_scheduler_state.cpppto_scheduler.h/cpptest_tensormap.cpppto_tensormap.h/cpptest_shared_memory.cpppto_shared_memory.h/cpptest_ready_queue.cpptest_core_types.cpptest_submit_types.cpppto_submit_types.htest_tensor.cpptensor.htest_dispatch_payload.cpppto2_dispatch_payload.htest_pto_types.cpppto_types.hPython Unit Tests (
tests/ut/) — pytest-basedtest_elf_parser.pypython/elf_parser.pytest_env_manager.pypython/env_manager.pytest_task_interface.pypython/task_interface.py(nanobind bindings)test_runtime_builder.pypython/runtime_compiler.py+examples/scripts/runtime_builder.pytest_chip_worker.pysrc/common/worker/chip_worker.h/cppCI
ut-cppjob added to.github/workflows/ci.yml— builds and runs C++ tests onubuntu-latest(no hardware required)Remaining Coverage Gaps
C++ — High Priority
aicpu_build_graphruntime —pto_runtime2,pto_orchestrator,pto_scheduler,pto_shared_memory,pto_ring_buffer(shared source with tensormap_and_ringbuffer but different build config)host_build_graphruntime —runtime.h/cpp, aicore/aicpu executorsmemory_allocator,function_cache,host_regs,raii_scope_guard,runtime_compile_info(host-side, testable offline)task_interface/task_args.h,data_type.h,arg_direction.htype correctness testsa5architecture — verify tests also compile against a5 headers (shared runtime source)Python — Medium Priority
kernel_compiler.py—KernelCompilerclass, toolchain selection, flag generationtoolchain.py—GxxToolchain,Aarch64GxxToolchain,CCECToolchainflag/path logicexamples/scripts/platform_info.py— architecture detection, platform discoveryexamples/scripts/run_example.py— argument parsing, config loading (unit-testable parts)examples/scripts/code_runner.py— execution flow logicInfrastructure
ubuntu-latest)test_ring_buffer(tracked separately as bug fixes)Motivation / Use Case
Unit tests that run offline (no Ascend hardware) enable:
Proposed Approach
Additional Context
tests/ut/(Python) andtests/ut/cpp/(C++)tests/ut/cpp/stubs/to isolate platform dependencies