How avuvos/cp-stress-tester works
Project type and purpose
• This is a command-line stress-testing tool for competitive programming solutions.
• Purpose: generate random testcases, run both a brute-force (guaranteed correct but slow) solution and an “optimal” solution under test, and highlight mismatches.
File structure
• Top-level files:
• brute_sol.cpp – the brute-force C++ solution source
• optimal_sol.cpp – the “optimal” (possibly incorrect) C++ solution source
• testcase_generator.py – Python script with a function to produce one test case
• mapper.sh – shell script that orchestrates generation, compilation, execution, and comparison over N testcases
• README.md, .gitignore
• No separate frontend/backend folders—this is a single-purpose CLI pipeline.
• Key patterns: generator → compiler → runner → comparator.
README for additional insights
• README clarifies the workflow:
a. You fill in the generator to define how testcases are built.
b. You compile and plug in two solutions.
c. You invoke mapper.sh with a parameter (e.g., 20) to run that many tests in sequence.
• No other external services or databases.
Main components
a. Testcase Generator (Python)
b. Brute-Force Solution (compiled binary from brute_sol.cpp)
c. Optimal Solution (compiled binary from optimal_sol.cpp)
d. Mapper/Orchestration Script (mapper.sh)
e. Comparator & Logger (internal to mapper.sh or a helper function)
f. CLI/User Interface
Relationships and data flow
• CLI invokes mapper.sh with parameter N.
• mapper.sh loops from 1 to N:
1. Calls testcase_generator.py → STDOUT sends one test input
2. Pipes the input to both compiled binaries in parallel or sequentially → captures two outputs
3. Passes the two outputs to a compare routine
4. If they differ, logs the test input, both outputs, and stops or continues
5. Reports summary at the end
Architectural patterns and design principles
• Pipeline pattern: a linear sequence of processing stages
• Separation of concerns:
• Generation (Python)
• Execution (binaries)
• Comparison & reporting (shell logic)
Relevant technologies
• Python 3 for testcase_generator.py
• Bash for mapper.sh
• C++14 (or C++17) for brute_sol.cpp and optimal_sol.cpp
• Standard I/O and exit codes for communication