# vidyutchakrabarti/testx architecture

> Architecture diagram of the GitHub repository vidyutchakrabarti/testx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vidyutchakrabarti/testx
- Repository: https://github.com/vidyutchakrabarti/testx

## Overview

##### Project type and purpose
- This is an open-source test-generation framework (“TestX”) that uses gcov to auto-generate and validate test inputs for user-provided functions operating on common data structures (linked list, graph, trie).

##### File structure
- Top-level:
- LICENSE, README.md – project metadata
- data-structures/ – three subfolders (LL, Graph, trie), each containing:
– Makefile, source files for DS implementation, “instrumented” versions, user_function.cpp/h, test/ (auto-generated testcases + harness Makefile & runner).
- prototype/ – sample code.cpp + input/output files + run_tests.sh as a quick demo.
- testgenerators/ – core engine:
– Makefile that builds libtg.a
– coveragelogger, testgenerator, valuegenerators, etc., which together generate test inputs based on coverage feedback.
- Patterns:
- Plugin-style modules: each data structure subfolder links against libtg.a.
- Two-phase workflow: generation (using instrumented code + gcov) → execution (running generated JSON against user_function + gcov report).

##### README for additional insights
- It describes exactly the two-stage process:
1) Build libtg.a in testgenerators
2) In each DS folder, drop your code in user_function.cpp, run make → generate JSON testcases until ≥80% coverage
3) In DS/test folder, run make → executes tests and emits gcov reports
- Mentions storage of testcases in JSON under testcases/

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Engine
    subgraph "Core Engine (testgenerators)"
        direction TB
        TGMakefile["Makefile"]:::cli
        TGCoreCpp["testgenerator.cpp"]:::core
        TGCoreHdr["testgenerator.h"]:::core
        CovLogCpp["coveragelogger.cpp"]:::core
        CovLogHdr["coveragelogger.h"]:::core
        ValGenCpp["valuegenerators.cpp"]:::core
        ValGenHdr["valuegenerators.h"]:::core
        TGTest["test_valuegenerators.cpp"]:::core
        LibTG["libtg.a"]:::storage
    end

    %% LinkedList Module
    subgraph "LinkedList Module (data-structures/LL)"
        direction TB
        LLMakefile["Makefile"]:::cli
        LLImplCpp["linkedlist.cpp"]:::plugin
        LLImplHdr["linkedlist.h"]:::plugin
        LLInstr["linkedlist_instrumented.cpp"]:::plugin
        LLAdapterCpp["lltg.cpp"]:::plugin
        LLAdapterHdr["lltg.h"]:::plugin
        LLMain["main.cpp"]:::cli
        LLUser["user_function.cpp"]:::plugin
        subgraph "LL Test Harness"
            direction TB
            LLTestMake["Makefile"]:::cli
            LLTestCpp["test.cpp"]:::plugin
        end
    end

    %% Graph Module
    subgraph "Graph Module (data-structures/Graph)"
        direction TB
        GrMakefile["Makefile"]:::cli
        GrImplCpp["graph.cpp"]:::plugin
        GrImplHdr["graph.h"]:::plugin
        GrInstr["graph_instrumented.cpp"]:::plugin
        GrAdapterCpp["graphtg.cpp"]:::plugin
        GrAdapterHdr["graphtg.h"]:::plugin
        GrMain["main.cpp"]:::cli
        GrUserCpp["user_function.cpp"]:::plugin
        GrUserHdr["user_function.h"]:::plugin
        subgraph "Graph Test Harness"
            direction TB
            GrTestMake["Makefile"]:::cli
            GrTestCpp["test.cpp"]:::plugin
            GrJSON["testcases/*.json"]:::storage
        end
    end

    %% Trie Module
    subgraph "Trie Module (data-structures/trie)"
        direction TB
        TrMakefile["Makefile"]:::cli
        TrImplCpp["trie.cpp"]:::plugin
        TrImplHdr["trie.h"]:::plugin
        TrInstr["trie_instrumented.cpp"]:::plugin
        TrAdapterHdr["trietg.h"]:::plugin
        TrMain["main.cpp"]:::cli
        TrUser["user_function.cpp"]:::plugin
        subgraph "Trie Test Harness"
            direction TB
            TrTestMake["Makefile"]:::cli
            TrTestCpp["test.cpp"]:::plugin
        end
    end

    %% Two-Phase Workflow
    subgraph "Generation Phase"
        direction TB
        LLBin["LL Instrumented Binary"]:::plugin
        GrBin["Graph Instrumented Binary"]:::plugin
        TrBin["Trie Instrumented Binary"]:::plugin
        CovLoop("CoverageLogger Loop"):::core
        JSON["Generated JSON Testcases"]:::storage
    end

    subgraph "Execution Phase"
        direction TB
        TestHarness("Test Runner"):::cli
        UserFunc("User Function Wrapper"):::plugin
        GcovReport[".gcov Reports"]:::storage
        extGcov("gcov"):::external
    end

    %% Build & Link
    TGMakefile -->|build libtg.a| LibTG
    LibTG -->|linked against| LLMakefile
    LibTG -->|linked against| GrMakefile
    LibTG -->|linked against| TrMakefile

    %% Instrumentation to Generation
    LLMakefile --> LLBin
    GrMakefile --> GrBin
    TrMakefile --> TrBin
    LLBin -->|collect data| CovLoop
    GrBin -->|collect data| CovLoop
    TrBin -->|collect data| CovLoop
    CovLoop -->|generate| JSON

    %% Execution Flow
    JSON --> TestHarness
    TestHarness -->|invoke| UserFunc
    UserFunc -->|exec & cover| extGcov
    extGcov -->|output| GcovReport
    GcovReport -->|feedback| CovLoop

    %% Click Events
    click TGMakefile "https://github.com/vidyutchakrabarti/testx/tree/main/testgenerators/Makefile"
    click TGCoreCpp "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/testgenerator.cpp"
    click TGCoreHdr "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/testgenerator.h"
    click CovLogCpp "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/coveragelogger.cpp"
    click CovLogHdr "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/coveragelogger.h"
    click ValGenCpp "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/valuegenerators.cpp"
    click ValGenHdr "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/valuegenerators.h"
    click TGTest "https://github.com/vidyutchakrabarti/testx/blob/main/testgenerators/test_valuegenerators.cpp"
    click LLMakefile "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/LL/Makefile"
    click LLImplCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/linkedlist.cpp"
    click LLImplHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/linkedlist.h"
    click LLInstr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/linkedlist_instrumented.cpp"
    click LLAdapterCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/lltg.cpp"
    click LLAdapterHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/lltg.h"
    click LLMain "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/main.cpp"
    click LLUser "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/user_function.cpp"
    click LLTestMake "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/LL/test/Makefile"
    click LLTestCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/LL/test/test.cpp"
    click GrMakefile "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/Graph/Makefile"
    click GrImplCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/graph.cpp"
    click GrImplHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/graph.h"
    click GrInstr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/graph_instrumented.cpp"
    click GrAdapterCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/graphtg.cpp"
    click GrAdapterHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/graphtg.h"
    click GrMain "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/main.cpp"
    click GrUserCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/user_function.cpp"
    click GrUserHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/user_function.h"
    click GrTestMake "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/Graph/test/Makefile"
    click GrTestCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/test/test.cpp"
    click GrJSON "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/test/testcases/*.json"
    click TrMakefile "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/trie/Makefile"
    click TrImplCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/trie.cpp"
    click TrImplHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/trie.h"
    click TrInstr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/trie_instrumented.cpp"
    click TrAdapterHdr "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/trietg.h"
    click TrMain "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/main.cpp"
    click TrUser "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/user_function.cpp"
    click TrTestMake "https://github.com/vidyutchakrabarti/testx/tree/main/data-structures/trie/test/Makefile"
    click TrTestCpp "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/trie/test/test.cpp"
    click JSON "https://github.com/vidyutchakrabarti/testx/blob/main/data-structures/Graph/test/testcases/*.json"
    click extGcov "https://github.com/vidyutchakrabarti/testx/tree/main/gcov"

    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:1px
    classDef plugin fill:#9ff,stroke:#333,stroke-width:1px
    classDef storage fill:#ff9,stroke:#333,stroke-width:1px
    classDef external fill:#fdd,stroke:#333,stroke-width:1px
    classDef cli fill:#dfd,stroke:#333,stroke-width:1px
```
