This project includes comprehensive testing capabilities with multiple test runners for different purposes.
# Run all Catch2 unit tests with detailed output
./run_unit_tests.sh
# Quick run with minimal output
./run_unit_tests.sh --quick
# List available tests
./run_unit_tests.sh --list
# Run via CTest only
./run_unit_tests.sh --ctest
# Show help
./run_unit_tests.sh --help# Build with integrated static analysis and run all tests
./build-macos.sh
# Run comprehensive test suite (all tests)
./run_all_tests.sh
# Quick test run (faster)
./run_all_tests.sh --quick- Purpose: Fast unit testing with modern C++ testing framework
- Location:
build-macos/bin/glob_matcher_unit_test - What it tests: GlobMatcher functionality with comprehensive pattern matching
- Runtime: ~1-2 seconds
- Command:
./run_unit_tests.sh --quick
- Purpose: Test complete functionality of cache, async downloads, config parsing
- Location:
build-macos/bin/*_test - What it tests: Real-world scenarios, file operations, network simulation
- Runtime: ~10-30 seconds
- Command:
./run_all_tests.sh
- Purpose: Interactive demonstration of features
- Location:
build-macos/bin/cache_demo,build-macos/bin/cache_test - What it tests: User-facing functionality, manual validation
- Runtime: Variable
- Command: Individual execution
| Script | Purpose | Speed | Coverage | Best For |
|---|---|---|---|---|
run_unit_tests.sh |
Catch2 only | ⚡ Fastest | Unit tests | Development |
run_all_tests.sh |
All tests | 🐌 Slowest | Complete | CI/CD |
| Individual executables | Specific areas | ⚡ Fast | Targeted | Debugging |
# Fast feedback loop
./run_unit_tests.sh --quick# Comprehensive validation
./run_all_tests.sh# List what's available
./run_unit_tests.sh --list
# Run specific test types
ctest -R "GlobMatcher" --verbose
# Manual testing
./build-macos/bin/cache_test --test-cacheBuilt in build-macos/bin/:
glob_matcher_unit_test- Pattern matching tests
cache_test- Memory cache functionalityasync_test- Asynchronous download systemconfig_*_test- Configuration parsingdirectory_test- Directory tree managementmetrics_test- Prometheus metrics collectionedge_cases_test- Error handling and edge cases
cache_demo- Interactive cache demonstrationglob_test- Pattern matching examples
# Run specific test by name
./build-macos/bin/glob_matcher_unit_test "GlobMatcher basic wildcard patterns"
# Run tests with specific tags
./build-macos/bin/glob_matcher_unit_test [glob]
# Different output formats
./build-macos/bin/glob_matcher_unit_test --reporter=junit
./build-macos/bin/glob_matcher_unit_test --reporter=compact# Run all tests
ctest
# Run with parallel execution
ctest -j4
# Verbose output
ctest --verbose
# Run specific tests
ctest -R "GlobMatcher"
# Show test output on failure
ctest --output-on-failureThe project includes GitHub Actions workflows:
.github/workflows/test.yml- Runs all tests on Ubuntu with multiple compilers.github/workflows/code-quality.yml- Static analysis with cppcheck
Local equivalents:
# Simulate CI test run
./run_all_tests.sh
# Static analysis
cppcheck --enable=all --std=c++20 src/ include/- Add test cases to
src/test/glob_matcher_test.cppor create new Catch2 test file - Update
src/test/CMakeLists.txtto include new test executable - Use Catch2 syntax:
TEST_CASE("Your test name", "[tag]") { REQUIRE(your_function() == expected_value); }
- Create new test file in
src/test/ - Add to
TEST_PROGRAMSlist insrc/test/CMakeLists.txt - Define
<test_name>_SOURCESvariable
# Time the test runs
time ./run_unit_tests.sh --quick
time ./run_all_tests.sh --quick
# Profile memory usage (if needed)
valgrind ./build-macos/bin/glob_matcher_unit_test# Clean build
rm -rf build-macos
./run_unit_tests.sh # Will rebuild automatically# Verbose test output
./run_unit_tests.sh # Default mode shows details
ctest --verbose
# Run individual test for debugging
./build-macos/bin/glob_matcher_unit_test --successThe scripts automatically handle:
- CMake configuration
- Dependency fetching (Catch2, nlohmann_json, prometheus-cpp)
- Parallel building
The build system includes integrated static analysis for code quality and security:
# Build with clang-tidy analysis (requires: brew install llvm)
./build-macos.shStatic analysis checks:
- readability-*: Code readability and maintainability
- performance-*: Performance optimization opportunities
- modernize-*: Modern C++20 usage recommendations
- bugprone-*: Potential bugs and error-prone patterns
The project includes comprehensive memory safety documentation:
- USE_AFTER_FREE_ANALYSIS.md: Complete vulnerability analysis with fixes
- DYNAMIC_MEMORY_ANALYSIS.md: Memory allocation patterns and safety
- CACHE_EVICTION_PROTECTION.md: Thread-safe cache operations
Recent security improvements:
- ✅ Fixed critical use-after-free vulnerabilities in async callbacks
- ✅ Added atomic protection against cache eviction during downloads
- ✅ Eliminated use-after-move bugs with helper functions
- ✅ Added per-node mutex protection for concurrent directory operations
Concurrent operation tests:
- Multi-threaded cache access patterns
- Async download manager stress testing
- Directory tree concurrent modification protection
- Memory cache thread safety validation
- Use
run_unit_tests.sh --quickduring development for fast feedback - Run
./build-macos.shbefore commits for build + static analysis - Run
run_all_tests.shbefore commits for full validation - Use
--listto explore available tests when debugging - Individual executables for focused testing of specific components
- CTest integration for IDE support and automated discovery
- Review security analysis documents for understanding memory safety improvements