-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Repository Analysis
Purpose and Technology Stack
Z3 is Microsoft Research's theorem prover, written primarily in C++ with C++20 standard requirements. It provides various APIs (C++, C, Python, Java, .NET, OCaml, JavaScript/WASM) and uses CMake as its primary build system, with additional support for Visual Studio, Makefiles, vcpkg, and Bazel.
Current Test Coverage Infrastructure
**✅ (redacted)
- Comprehensive unit test suite (
src/test/) with 100+ test files covering core functionality - Robust CI infrastructure with multiple build configurations
- Existing coverage workflow (
.github/workflows/coverage.yml) that runs bi-weekly - Coverage collection infrastructure already configured (
.github/actions/daily-test-improver/coverage-steps/action.yml) - Rich regression test suite via external
z3testrepository
**
- Coverage report generation is failing due to gcovr merge conflicts with C++ template destructors
- The error indicates:
Got function (redacted)<(redacted)>::(redacted)) on multiple lines: 87, 116 - Despite test execution success, HTML coverage reports aren't being generated
Test Organization and Structure
Unit Tests (src/test/):
- Main test executable:
test-z3built via CMake - Tests cover: algebraic numbers, AST, bit vectors, arithmetic, SAT solving, SMT theories, parsers, utilities
- Test execution command:
./build/test-z3 -a
**External (redacted)
- Regression tests via
z3testrepository (SMT2 benchmarks) - Coverage-specific tests in
z3test/coverage/cpp - Example programs that also serve as integration tests
Build and Coverage Commands
**Build (redacted)
# Configure with coverage instrumentation
CXXFLAGS="--coverage" CFLAGS="--coverage" LDFLAGS="-lgcov" CC=clang CXX=clang++ \
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=./build/install -G "Ninja"
# Build core library and tests
ninja -C build install
ninja -C build test-z3**Test (redacted)
# Run unit tests
./build/test-z3 -a
# Run regression tests
python z3test/scripts/test_benchmarks.py build/z3 z3test/regressions/smt2
python z3test/scripts/test_coverage_tests.py ./build/install z3test/coverage/cppCoverage Report Generation (currently broken):
# This fails due to template merge conflicts
gcovr --html coverage.html --gcov-ignore-parse-errors --gcov-executable "llvm-cov gcov" .Test Coverage Improvement Strategy
Immediate Priorities
-
Fix Coverage Report Generation
- Resolve gcovr merge conflict by adding
--merge-mode-functions=separateflag - This will allow us to see actual coverage percentages and identify gaps
- Resolve gcovr merge conflict by adding
-
High-Impact Areas for New Tests (based on codebase analysis):
- Theory Solvers (
src/smt/theory_*.cpp): Core SMT theory implementations - AST Operations (
src/ast/): Expression manipulation and rewriting - SAT Solver Components (
src/sat/): Boolean satisfiability solving - API Layer (
src/api/): Public interface functions - Utility Libraries (
src/util/): Core data structures and algorithms
- Theory Solvers (
-
Coverage Expansion Strategies:
- Edge Case Testing: Focus on boundary conditions, error paths, and exception handling
- Integration Testing: Cross-theory interactions and complex formulas
- API Boundary Testing: Parameter validation and error conditions
- Performance Path Testing: Rarely-executed optimization paths
Test Organization Guidelines
**For New (redacted)
- Add to existing files in
src/test/when extending functionality of tested modules - Create new test files following naming pattern
<module_name>.cpp - Follow existing test patterns with simple functions and PASS/FAIL assertions
- Update
src/test/CMakeLists.txtwhen adding new test files
Fast Development Workflow
**Quick Test (redacted)
# Rebuild only tests after changes
ninja -C build test-z3
# Run specific test subset (when developing)
./build/test-z3 -a | grep -A5 -B5 "FAILED\|PASS.*<test-name>"
# Generate coverage after test runs
gcovr --merge-mode-functions=separate --gcov-ignore-parse-errors --gcov-executable "llvm-cov gcov" .Opportunities for Major Coverage Improvements
- Theory Combination Testing: Z3's strength is combining multiple theories - test complex multi-theory problems
- Error Path Coverage: Many error handling paths are likely untested
- API Robustness: Stress testing of public APIs with invalid inputs
- Memory Management: Test resource cleanup and edge cases in allocators
- Parser Edge Cases: Complex SMT-LIB2 parsing scenarios
Questions for Maintainers
- Are there specific modules or theories that are known to need more test coverage?
- What are the performance implications of enabling coverage instrumentation in CI?
- Should we prioritize functional correctness tests or performance regression prevention?
- Are there any testing patterns or utilities we should avoid or prefer?
> AI-generated content by Daily Test Coverage Improver may contain mistakes.
Generated by Agentic Workflow Run