CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
StinkyTofu Tests
This directory contains all tests for the StinkyTofu library.
Directory Structure
tests/
+-- CMakeLists.txt # Test build configuration
+-- StinkyTofuTestMain.cpp # Main test entry point (GTest runner)
+-- unit/ # Unit tests
+-- WaitCntInsertionTest.cpp
+-- IntrusiveListTest.cpp
+-- PassManagerTest.cpp
+-- StinkyAsmEmitterTest.cpp
Building Tests
From the build directory:
# Build all test executables
make tests
# Or build specific test executable
make unit_tests
Running Tests
Run All Tests
# Run unit tests directly
./tests/unit_tests
# Run all tests using CTest
ctest
# Run only unit tests using CTest label
ctest -L unit_tests
Run Specific Test Suites
Using GTest filters directly:
# Run all AsmEmitter tests
./tests/unit_tests --gtest_filter="AsmEmitterTest.*"
# Run specific test
./tests/unit_tests --gtest_filter="AsmEmitterTest.EmitWithCycleInfo"
# Run multiple test suites
./tests/unit_tests --gtest_filter="AsmEmitterTest.*:PassManagerFlowTest.*"
Using CTest:
# Run all unit tests (by label)
ctest -L unit_tests
# Run tests matching pattern
ctest -R "AsmEmitter"
# Run tests NOT matching pattern
ctest -E "IntrusiveList"
# Combine label and pattern
ctest -L unit_tests -R "AsmEmitter"
Other CTest Options
# List all tests without running
ctest -N
# List tests with a specific label
ctest -L unit_tests -N
# Verbose output
ctest -V
# Show output only on failure
ctest --output-on-failure
Test Organization
Unit Tests (unit/)
Unit tests verify individual components in isolation:
- PassManagerTest: Tests for the pass manager infrastructure
- IntrusiveListTest: Tests for the intrusive list data structure
- WaitCntInsertionTest: Tests for the configurable wait count pass
- StinkyAsmEmitterTest: Tests for the assembly emitter
Adding New Tests
Adding a Unit Test
-
Create your test file in
tests/unit/:#include <gtest/gtest.h> #include "stinkytofu/core/stinkytofu.hpp" TEST(MyNewTest, BasicTest) { // Your test code EXPECT_EQ(1, 1); } -
Add the file to
tests/CMakeLists.txt:set(UNIT_TEST_FILES unit/PassManagerTest.cpp unit/IntrusiveListTest.cpp unit/WaitCntInsertionTest.cpp unit/asm/StinkyAsmEmitterTest.cpp unit/MyNewTest.cpp # Add your new test here ) -
Rebuild:
make unit_tests # or build all test executables make tests -
Run your new tests:
./tests/unit_tests --gtest_filter="MyNewTest.*" ctest -L unit_tests -R "MyNewTest"
Test Conventions
- Use descriptive test names:
TEST(Component, WhatItDoes) - One test file per component or module
- Use test fixtures for shared setup/teardown
- Keep tests focused and independent
- Use
EXPECT_*for non-fatal assertions - Use
ASSERT_*for fatal assertions (test stops on failure)
Test Categories
Current Test Types
- Unit Tests (
unit/) - Tests for individual components in isolation- Executable:
unit_tests - Label:
unit_tests - Command:
./tests/unit_testsorctest -L unit_tests
- Executable:
Adding New Test Types
To add a new test category (e.g., integration tests, benchmarks), follow this pattern in CMakeLists.txt:
# Integration Tests (example)
set(INTEGRATION_TEST_FILES
integration/YourIntegrationTest.cpp
)
list(TRANSFORM INTEGRATION_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
add_executable(integration_tests ${TEST_MAIN} ${INTEGRATION_TEST_FILES})
target_link_libraries(integration_tests PUBLIC ${TEST_LINK_LIBS})
target_include_directories(integration_tests PRIVATE ${TEST_INCLUDE_DIRS})
add_dependencies(integration_tests tablegen_generated)
gtest_discover_tests(integration_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
TIMEOUT 60
PROPERTIES LABELS "integration_tests"
)
# Add to the 'tests' target
add_dependencies(tests integration_tests)
This ensures:
- Each test type has its own executable
- Labels are correctly applied per test type
make testsbuilds all test executables- Tests can be filtered by type using labels
Python Tests
Python tests use pytest and are automatically integrated into CTest when STINKYTOFU_BUILD_PYTHON=ON.
Running Python Tests via CTest
# Build with Python support
cmake -DSTINKYTOFU_BUILD_PYTHON=ON ..
make
# Run all Python tests (fast: ~0.8s for 23 tests)
ctest -L python
# Run specific test file
ctest -R python.test_ir_basic
# Show output on failure
ctest -L python --output-on-failure
# Verbose mode (shows all output)
ctest -L python -V
Running Individual Tests Directly with Pytest
For debugging specific test cases, use pytest directly with proper PYTHONPATH:
# Set PYTHONPATH to find the built Python module
export PYTHONPATH=<build_dir>/lib
# Run one specific test
pytest python_module/tests/test_ir_basic.py::TestMemoryManagement::test_module_destruction -v
# Run all tests in a class
pytest python_module/tests/test_ir_basic.py::TestMemoryManagement -v
# Run tests matching a pattern
pytest python_module/tests/test_ir_basic.py -k "memory" -v
# Enable print statements and debugger
pytest python_module/tests/test_ir_basic.py::test_name -v -s --pdb
Python Test Organization
- Each
test_*.pyfile = one CTest entry - Tests are in
python_module/tests/ - CTest suppresses output by default (use
--output-on-failureor-Vto see details)