Skip to content

Establish Test Infrastructure with Multi-Format Binary Fixtures #34

Closed
1 of 1 issue completed
Closed

Description

@unclesp1d3r

Summary

Create a comprehensive test infrastructure with sample binary files covering all supported formats (ELF, PE, Mach-O) to enable integration testing of the binary analyzer.

Context

StringyMcStringFace currently has strong foundational parsers for ELF, PE, and Mach-O formats via goblin, but lacks integration tests with real binary fixtures. As the string extraction, semantic classification, and ranking systems are being developed, we need a robust test framework to validate:

  • Section classification accuracy across formats
  • String extraction from different sections (.rodata, .rdata, __cstring, etc.)
  • UTF-8 and UTF-16 handling in PE binaries
  • Import/export symbol extraction
  • Cross-platform compatibility

Without proper test fixtures, we cannot validate the analyzer's behavior against real-world binaries or catch regressions as new features are added.

Proposed Solution

1. Directory Structure

tests/
├── fixtures/
│   ├── elf/
│   │   ├── simple_hello_x64
│   │   ├── simple_hello_arm64
│   │   └── with_rodata_strings
│   ├── pe/
│   │   ├── simple_hello_x64.exe
│   │   ├── with_utf16_strings.exe
│   │   └── with_resources.exe
│   ├── macho/
│   │   ├── simple_hello_x64
│   │   ├── simple_hello_arm64
│   │   └── with_cstring_section
│   └── README.md  # Documentation of each fixture
├── integration/
│   ├── test_format_detection.rs
│   ├── test_section_classification.rs
│   └── test_string_extraction.rs
└── common/
    └── mod.rs  # Shared test utilities

2. Binary Fixtures Requirements

Each test binary should be minimal but contain known string patterns:

ELF Binaries:

  • Simple hello world with strings in .rodata
  • Known function names for import testing
  • Various string encodings

PE Binaries:

  • UTF-16LE strings in .rdata section
  • Version info resources
  • Import table with known DLLs
  • Optional: manifest resources

Mach-O Binaries:

  • Strings in __cstring section
  • Both x86_64 and arm64 architectures
  • Known dylib imports

3. Test Binary Creation

Use simple C/Rust programs compiled with known strings:

// example_fixture.c
const char* url = "https://api.example.com/v1/";
const char* path = "/usr/local/bin/stringy";
const char* guid = "{12345678-1234-1234-1234-123456789abc}";

int main() {
    printf("Test binary for StringyMcStringFace\n");
    return 0;
}

Compile for each platform:

  • Linux: gcc -o tests/fixtures/elf/with_rodata_strings example_fixture.c
  • Windows: Cross-compile or build on Windows target
  • macOS: clang -o tests/fixtures/macho/with_cstring_section example_fixture.c

4. Integration Test Framework

Create tests that:

  • Load each fixture
  • Verify format detection
  • Validate section classification
  • Extract strings and compare against known values
  • Test that offsets and RVAs are calculated correctly

5. Documentation

Create tests/fixtures/README.md documenting:

  • What each binary contains
  • Expected strings and their locations
  • How to regenerate binaries if needed
  • Checksums for integrity verification

Acceptance Criteria

  • tests/fixtures/ directory structure created with subdirectories for each format
  • At least one test binary for each format (ELF, PE, Mach-O)
  • Each fixture contains documented known strings at known offsets
  • Integration tests can load and parse each fixture successfully
  • Tests verify format detection works correctly
  • Tests verify section classification for each format
  • README.md documents all fixtures with expected contents
  • Tests pass in CI/CD pipeline
  • Fixtures are committed to git (or documented build process for local generation)

Related Components

  • Binary format detection (goblin integration)
  • Section classification system
  • String extraction engines (to be tested once implemented)
  • Container parsers for ELF, PE, Mach-O

Task-ID

stringy-analyzer/basic-test-infrastructure

Activity

  1. added this to the v0.1 milestone on Sep 30, 2025
  2. self-assigned this
    on Sep 30, 2025
  3. unclesp1d3r commented on Sep 30, 2025

    @unclesp1d3r
    MemberAuthor

    @coderabbitai Enhance this issue body with additional context and a proposed solution. Improve the issue title and assign the proper labels and other metadata.

  4. changed the title [-]Basic Test Infrastructure[/-] [+]Establish Test Infrastructure with Multi-Format Binary Fixtures[/+] on Sep 30, 2025
  5. coderabbitai commented on Sep 30, 2025

    @coderabbitai
    Contributor

    Tip

    For best results, initiate chat on the files or code changes.

    🧩 Analysis chain

    🏁 Script executed:

    #!/bin/bash
    
    # Fetch details of issue #34
    gh issue view 34 --json title,body,labels,assignees,state,author,createdAt,updatedAt
    
    # Also get the repository context to better understand the project
    cat README.md 2>/dev/null || echo "No README found"
    

    Length of output: 7239


    @unclesp1d3r, I'll enhance this issue with additional context and a proposed solution. Let me update it now.


    🏁 Script executed:

    #!/bin/bash
    
    # Update issue #34 with enhanced content
    gh issue edit 34 \
      --title "Establish Test Infrastructure with Multi-Format Binary Fixtures" \
      --body "## Summary
    
    Create a comprehensive test infrastructure with sample binary files covering all supported formats (ELF, PE, Mach-O) to enable integration testing of the binary analyzer.
    
    ## Context
    
    StringyMcStringFace currently has strong foundational parsers for ELF, PE, and Mach-O formats via goblin, but lacks integration tests with real binary fixtures. As the string extraction, semantic classification, and ranking systems are being developed, we need a robust test framework to validate:
    
    - Section classification accuracy across formats
    - String extraction from different sections (.rodata, .rdata, __cstring, etc.)
    - UTF-8 and UTF-16 handling in PE binaries
    - Import/export symbol extraction
    - Cross-platform compatibility
    
    Without proper test fixtures, we cannot validate the analyzer's behavior against real-world binaries or catch regressions as new features are added.
    
    ## Proposed Solution
    
    ### 1. Directory Structure
    \`\`\`
    tests/
    ├── fixtures/
    │   ├── elf/
    │   │   ├── simple_hello_x64
    │   │   ├── simple_hello_arm64
    │   │   └── with_rodata_strings
    │   ├── pe/
    │   │   ├── simple_hello_x64.exe
    │   │   ├── with_utf16_strings.exe
    │   │   └── with_resources.exe
    │   ├── macho/
    │   │   ├── simple_hello_x64
    │   │   ├── simple_hello_arm64
    │   │   └── with_cstring_section
    │   └── README.md  # Documentation of each fixture
    ├── integration/
    │   ├── test_format_detection.rs
    │   ├── test_section_classification.rs
    │   └── test_string_extraction.rs
    └── common/
        └── mod.rs  # Shared test utilities
    \`\`\`
    
    ### 2. Binary Fixtures Requirements
    
    Each test binary should be minimal but contain known string patterns:
    
    **ELF Binaries:**
    - Simple hello world with strings in .rodata
    - Known function names for import testing
    - Various string encodings
    
    **PE Binaries:**
    - UTF-16LE strings in .rdata section
    - Version info resources
    - Import table with known DLLs
    - Optional: manifest resources
    
    **Mach-O Binaries:**
    - Strings in __cstring section
    - Both x86_64 and arm64 architectures
    - Known dylib imports
    
    ### 3. Test Binary Creation
    
    Use simple C/Rust programs compiled with known strings:
    
    \`\`\`c
    // example_fixture.c
    const char* url = \"https://api.example.com/v1/\";
    const char* path = \"/usr/local/bin/stringy\";
    const char* guid = \"{12345678-1234-1234-1234-123456789abc}\";
    
    int main() {
        printf(\"Test binary for StringyMcStringFace\\n\");
        return 0;
    }
    \`\`\`
    
    Compile for each platform:
    - Linux: \`gcc -o tests/fixtures/elf/with_rodata_strings example_fixture.c\`
    - Windows: Cross-compile or build on Windows target
    - macOS: \`clang -o tests/fixtures/macho/with_cstring_section example_fixture.c\`
    
    ### 4. Integration Test Framework
    
    Create tests that:
    - Load each fixture
    - Verify format detection
    - Validate section classification
    - Extract strings and compare against known values
    - Test that offsets and RVAs are calculated correctly
    
    ### 5. Documentation
    
    Create \`tests/fixtures/README.md\` documenting:
    - What each binary contains
    - Expected strings and their locations
    - How to regenerate binaries if needed
    - Checksums for integrity verification
    
    ## Acceptance Criteria
    
    - [ ] \`tests/fixtures/\` directory structure created with subdirectories for each format
    - [ ] At least one test binary for each format (ELF, PE, Mach-O)
    - [ ] Each fixture contains documented known strings at known offsets
    - [ ] Integration tests can load and parse each fixture successfully
    - [ ] Tests verify format detection works correctly
    - [ ] Tests verify section classification for each format
    - [ ] README.md documents all fixtures with expected contents
    - [ ] Tests pass in CI/CD pipeline
    - [ ] Fixtures are committed to git (or documented build process for local generation)
    
    ## Related Components
    
    - Binary format detection (goblin integration)
    - Section classification system
    - String extraction engines (to be tested once implemented)
    - Container parsers for ELF, PE, Mach-O
    
    ## Task-ID
    stringy-analyzer/basic-test-infrastructure"
    
    # Add priority label since this is foundational for development
    gh issue edit 34 --add-label "priority:medium"
    
    echo "Issue #34 has been enhanced successfully!"
    

    Length of output: 237


    @unclesp1d3r, I've successfully enhanced issue #34! Here's what was updated:

    Changes Made

    ✅ Title Updated:

    • Old: "Basic Test Infrastructure"
    • New: "Establish Test Infrastructure with Multi-Format Binary Fixtures"

    ✅ Body Enhanced with:

    • Context section: Explains why test infrastructure is needed for the binary analyzer, referencing the current development status and the need to validate string extraction across ELF, PE, and Mach-O formats
    • Detailed proposed solution covering:
      • Complete directory structure for test fixtures
      • Requirements for each binary format (ELF, PE, Mach-O)
      • Sample C code for creating test binaries with known strings
      • Integration test framework structure
      • Documentation requirements
    • Clear acceptance criteria: 9 checkboxes covering fixture creation, testing, and documentation
    • Related components: Links to the systems that will be tested

    ⚠️ Label Note:
    I attempted to add a priority:medium label, but it doesn't exist in your repository. The existing labels are already well-suited for this issue:

    • ✅ area:analyzer - Correct component
    • ✅ type:enhancement - Correct type
    • ✅ status:backlog - Current status
    • ✅ lang:rust - Implementation language
    • ✅ needs:tests - Ironically appropriate since this issue is about creating tests!

    You can view the enhanced issue here: #34

    If you'd like to add priority labels to your repository, you can create them through the GitHub UI under Issues → Labels, or let me know if you'd like me to create a priority label system for you.

    🐰

       ^   ^
      (•.•)
      /> 📋 Enhanced and organized!
    
  6. unclesp1d3r commented on Jul 4, 2026

    @unclesp1d3r
    MemberAuthor

    Implemented: multi-format fixtures (ELF/PE/Mach-O) under tests/fixtures/ generated by 'just gen-fixtures'. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions