Testing & Benchmarking
Guide for running tests and benchmarks for the Metal shim implementation.
Prerequisites
- Xcode command line tools
- CMake 3.10+
- C++17 compatible compiler
- Metal-capable macOS device
Code Quality
Before running tests, ensure code quality standards are met:
pre-commit run --all-files
Quality Checks
| Check | GitHub Actions | CircleCI |
|---|---|---|
| Code Formatting | ✓ | ✓ |
| Linting | ✓ | ✓ |
| YAML Validation | ✓ | ✓ |
| Security Analysis | ✓ | ✓ |
| Container Scanning | ✓ | ✓ |
Running Tests
Unit Tests
mkdir -p build && cd build cmake .. -DBUILD_TESTS=ON make ctest --output-on-failure
Performance Benchmarks
cd build ./bin/benchmark_metal_shim --benchmark_min_time=1s
Test Coverage
mkdir -p build_coverage && cd build_coverage cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON make test_metal_shim lcov --capture --directory . --output-file coverage.info genhtml coverage.info --output-directory coverage
Writing Tests
Unit Tests: Place in tests/unit/, use Google Test framework, name files test_*.cpp
Benchmark Tests: Place in tests/performance/, use Google Benchmark framework, name files benchmark_*.cpp
Best Practices
- Write tests for all new features
- Keep tests independent and isolated
- Use meaningful test names
- Test edge cases and error conditions
- Document test assumptions and requirements