Initial commit
This commit is contained in:
115
TestGenerator/README.md
Normal file
115
TestGenerator/README.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# Test Generator
|
||||
|
||||
A command-line tool that reads JSON configuration files and generates C++ test code.
|
||||
|
||||
## Features
|
||||
|
||||
- Parses JSON configuration files without external dependencies
|
||||
- Generates C++ test classes from templates
|
||||
- Supports multiple instrument configurations
|
||||
- Merges common and variant-specific setups
|
||||
- Variable substitution in configurations
|
||||
|
||||
## Building
|
||||
|
||||
### Requirements
|
||||
- GCC (g++) with C++11 support
|
||||
- Standard C++ library only (no external dependencies)
|
||||
|
||||
### On Windows
|
||||
```bash
|
||||
build.bat
|
||||
```
|
||||
|
||||
### On Linux/Mac
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
This will create the `testgen` (or `testgen.exe` on Windows) executable.
|
||||
|
||||
## Usage
|
||||
|
||||
### Generate Test Code
|
||||
```bash
|
||||
testgen -commonPath <common_path> -variantPath <variant_path>
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
testgen -commonPath ..\SMT_PlayGround\hw_ext_tests -variantPath ..\SMT_PlayGround\hw_ext_variants\Avi64\Driver\TestSetup
|
||||
```
|
||||
|
||||
### Validate JSON File
|
||||
```bash
|
||||
testgen -dry <json_file>
|
||||
```
|
||||
|
||||
Example:
|
||||
```bash
|
||||
testgen -dry test.json
|
||||
```
|
||||
|
||||
### Display Help
|
||||
```bash
|
||||
testgen -help
|
||||
```
|
||||
|
||||
## Generated Files
|
||||
|
||||
The tool generates C++ files in `<variantPath>/generatedTests/`:
|
||||
|
||||
- `Instruments.h` - Instrument definitions
|
||||
- `Measurement.h` - Measurement interface (stub)
|
||||
- `Test_*.cpp` - Generated test classes
|
||||
- `main.cpp` - Main entry point that runs all tests
|
||||
- `build.bat` - Windows build script for generated tests
|
||||
- `Makefile` - Linux/Mac build script for generated tests
|
||||
|
||||
## Building Generated Tests
|
||||
|
||||
After generation, build and run the tests:
|
||||
|
||||
**Windows:**
|
||||
```bash
|
||||
cd <variantPath>/generatedTests
|
||||
build.bat
|
||||
test_runner.exe
|
||||
```
|
||||
|
||||
**Linux/Mac:**
|
||||
```bash
|
||||
cd <variantPath>/generatedTests
|
||||
make
|
||||
./test_runner
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
TestGenerator/
|
||||
├── src/
|
||||
│ ├── main.cpp # Entry point and command-line parsing
|
||||
│ ├── json_parser.h/.cpp # JSON parser implementation
|
||||
│ ├── file_utils.h/.cpp # File I/O utilities
|
||||
│ ├── code_generator.h/.cpp # Code generation logic
|
||||
│ └── data_structures.h # Data structure definitions
|
||||
├── Makefile # Build script for Linux/Mac
|
||||
├── build.bat # Build script for Windows
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
1. **JSON Parser** - Simple recursive descent parser for JSON
|
||||
2. **Data Structures** - Type-safe structures for configuration data
|
||||
3. **File Utils** - Cross-platform file and directory operations
|
||||
4. **Code Generator** - Template-based C++ code generation
|
||||
5. **Main** - Command-line interface and orchestration
|
||||
|
||||
## Notes
|
||||
|
||||
- All code uses only the C++ standard library
|
||||
- No terminal/console APIs are used in the domain logic
|
||||
- Generated code requires linking with actual Measurement implementation
|
||||
- Variable substitution supports expressions like `0.03*gangCount`
|
||||
Reference in New Issue
Block a user