Stub Generator
Generates VectorCAST stub scripts and gtest skeleton test files from C/C++ header files.
How It Works
- Parses C/C++ headers to extract function signatures and types
- Generates VectorCAST-compatible stub scripts (
.tstformat) - Generates gtest skeleton files with
TEST()macros for each function
Usage
Analyze a Header
curl -X POST http://localhost:9400/api/v1/stubgen/analyze \
-H "Content-Type: application/json" \
-d '{"file_path": "/path/to/module.h"}'
Generate Stubs and Tests
curl -X POST http://localhost:9400/api/v1/stubgen/generate \
-H "Content-Type: application/json" \
-d '{
"file_path": "/path/to/module.h",
"output_dir": "/path/to/output",
"recursive": false
}'
LLM test fill-in (BYOK)
The generated gtest skeletons are intentionally full of TODO markers — input
values, expected results, stub call-count checks. With suggest the engine
asks an LLM (your own key — bring-your-own-key) to replace those TODOs with
realistic automotive test logic, preserving the skeleton structure.
curl -X POST http://localhost:9400/api/v1/stubgen/generate \
-H "Content-Type: application/json" \
-d '{
"file_path": "/path/to/module.c",
"targets": ["gtest"],
"suggest": true,
"api_key": "sk-ant-…"
}'
suggest applies only to the gtest target. It requires api_key — the
request is rejected with 400 if it's missing (suggest is BYOK, never billed by
us). The response sets suggestions_applied: true when the skeleton was
rewritten. In the extension the API key configured in the popup is used
automatically.
CLI
# Analyze only
python -m engine.stubgen.cli analyze /path/to/module.h | jq .
# Generate all artifacts
python -m engine.stubgen.cli all /path/to/module.h -o /path/to/output
# gtest with LLM fill-in (key via flag or ANTHROPIC_API_KEY / OPENAI_API_KEY)
python -m engine.stubgen.cli gtest /path/to/module.c -o out --suggest --api-key sk-ant-…
Output Files
| File | Description |
|---|---|
module_stubs.c |
C stub implementations |
module_stubs.tst |
VectorCAST test script |
test_module.cpp |
gtest skeleton |
Example
Given sensor.h:
int read_temperature(uint8_t channel);
void reset_sensor(void);
Generated gtest skeleton:
#include <gtest/gtest.h>
extern "C" {
#include "sensor.h"
}
TEST(SensorTest, ReadTemperature) {
// TODO: implement
EXPECT_EQ(read_temperature(0), 0);
}
TEST(SensorTest, ResetSensor) {
// TODO: implement
reset_sensor();
}
Free vs Pro
| Feature | Free | Pro |
|---|---|---|
| Single file stub gen | Yes | Yes |
| gtest skeleton | Yes | Yes |
| Recursive (entire module) | No | Yes |
VectorCAST .tst export |
No | Yes |