SyzScope icon indicating copy to clipboard operation
SyzScope copied to clipboard

feat: Set up comprehensive Python testing infrastructure

Open llbbl opened this issue 3 months ago • 0 comments

Set Up Python Testing Infrastructure

Summary

This PR establishes a comprehensive testing infrastructure for the SyzScope project, providing a ready-to-use environment for writing and running tests.

Changes Made

  • Package Management: Migrated from requirements.txt to Poetry with complete pyproject.toml configuration
  • Testing Framework: Added pytest with pytest-cov and pytest-mock as development dependencies
  • Test Organization: Created structured testing directories:
    • tests/ - Main testing package
    • tests/unit/ - Unit tests directory
    • tests/integration/ - Integration tests directory
  • Configuration: Comprehensive pytest configuration in pyproject.toml with:
    • 80% test coverage threshold
    • HTML and XML coverage reports
    • Custom test markers: unit, integration, slow
    • Proper test discovery patterns
  • Shared Fixtures: Extensive conftest.py with reusable fixtures for:
    • Temporary directories and files
    • Mock VM instances and kernel objects
    • Mock crash cases and analysis components
    • Environment variable mocking
    • Sample binary and C files for testing
  • Validation: Infrastructure validation tests to ensure setup works correctly
  • Development Tools: Updated .gitignore with appropriate testing exclusions

Running Tests

To run tests after setting up the environment:

# Install dependencies
poetry install

# Run all tests
poetry run test
# or
poetry run tests

# Run with coverage
poetry run pytest --cov=syzscope

# Run specific test types
poetry run pytest -m unit        # Unit tests only
poetry run pytest -m integration # Integration tests only
poetry run pytest -m slow        # Slow tests only

Coverage Reporting

Coverage reports are generated in multiple formats:

  • Terminal output with missing lines
  • HTML report in htmlcov/ directory
  • XML report as coverage.xml

Dependencies

The infrastructure includes testing-specific dependencies:

  • pytest ^7.0 - Main testing framework
  • pytest-cov ^4.0 - Coverage reporting
  • pytest-mock ^3.10 - Mocking utilities

Notes

  • All production dependencies from requirements.txt have been migrated to Poetry format
  • The Poetry configuration allows for both exact version pinning and flexible constraints where appropriate
  • The testing infrastructure is framework-agnostic and can be extended for any testing needs
  • Infrastructure validation tests ensure the setup works correctly across different environments

🤖 Generated with Claude Code

llbbl avatar Sep 04 '25 18:09 llbbl