FIXUP! update documentation
This commit is contained in:
parent
030a813177
commit
93463789a5
@ -8,7 +8,7 @@ This comprehensive ECU Testing Framework provides a robust solution for testing
|
||||
|
||||
### ✅ **Complete Implementation Status**
|
||||
- **✅ pytest-based testing framework** with custom plugins
|
||||
- **✅ BabyLIN LIN communication integration** via ctypes bindings
|
||||
- **✅ BabyLIN LIN communication integration** via the official SDK Python wrapper (`BabyLIN_library.py`)
|
||||
- **✅ Mock interface for hardware-independent development**
|
||||
- **✅ Enhanced HTML/XML reporting with test metadata**
|
||||
- **✅ Detailed test documentation extraction**
|
||||
@ -87,9 +87,9 @@ ecu_tests/
|
||||
├── config/ # Configuration files
|
||||
│ ├── test_config.yaml # Main test configuration
|
||||
│ └── babylin.example.yaml # BabyLin configuration template
|
||||
├── vendor/babylin/ # BabyLin SDK integration
|
||||
│ ├── BabyLIN.dll # Hardware interface library
|
||||
│ └── include/BabyLIN.h # SDK header definitions
|
||||
├── vendor/ # BabyLIN SDK placement
|
||||
| ├── BabyLIN_library.py # Official SDK Python wrapper
|
||||
| └── platform libs # OS-specific native libs (DLL/.so/.dylib)
|
||||
├── reports/ # Generated test reports
|
||||
│ ├── report.html # Enhanced HTML report
|
||||
│ └── junit.xml # JUnit XML report
|
||||
@ -105,19 +105,55 @@ ecu_tests/
|
||||
|
||||
```powershell
|
||||
# Run all tests with verbose output
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -v
|
||||
python -m pytest -v
|
||||
|
||||
# Run specific test suite
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest tests/test_smoke_mock.py -v
|
||||
python -m pytest tests\test_smoke_mock.py -v
|
||||
|
||||
# Run tests with specific markers
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "smoke" -v
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "req_001" -v
|
||||
python -m pytest -m "smoke" -v
|
||||
python -m pytest -m "req_001" -v
|
||||
|
||||
# Run hardware tests (requires BabyLin hardware)
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "hardware" -v
|
||||
# Run hardware tests (requires BabyLIN hardware); join with adapter marker
|
||||
python -m pytest -m "hardware and babylin" -v
|
||||
```
|
||||
|
||||
### Unit Tests (fast, no hardware)
|
||||
|
||||
Run only unit tests using the dedicated marker or by path:
|
||||
|
||||
```powershell
|
||||
# By marker
|
||||
python -m pytest -m unit -q
|
||||
|
||||
# By path
|
||||
python -m pytest tests\unit -q
|
||||
|
||||
# Plugin self-tests (verifies reporting artifacts)
|
||||
python -m pytest tests\plugin -q
|
||||
```
|
||||
|
||||
Reports still go to `reports/` (HTML and JUnit per defaults). Open the HTML on Windows with:
|
||||
|
||||
```powershell
|
||||
start .\reports\report.html
|
||||
```
|
||||
|
||||
Coverage: enabled by default via pytest.ini. To disable locally:
|
||||
|
||||
```powershell
|
||||
python -m pytest -q -o addopts=""
|
||||
```
|
||||
|
||||
Optional HTML coverage:
|
||||
|
||||
```powershell
|
||||
python -m pytest --cov=ecu_framework --cov-report=html -q
|
||||
start .\htmlcov\index.html
|
||||
```
|
||||
|
||||
See also: `docs/13_unit_testing_guide.md` for more details and examples.
|
||||
|
||||
### Report Generation
|
||||
|
||||
Tests automatically generate enhanced reports:
|
||||
@ -130,40 +166,27 @@ Tests automatically generate enhanced reports:
|
||||
|
||||
```yaml
|
||||
interface:
|
||||
type: "mock" # or "babylin" for hardware
|
||||
type: mock # or babylin for hardware
|
||||
timeout: 1.0
|
||||
|
||||
babylin:
|
||||
dll_path: "./vendor/babylin/BabyLIN.dll"
|
||||
functions:
|
||||
open: "BL_open"
|
||||
close: "BL_close"
|
||||
send: "BL_mon_set_xmit"
|
||||
receive: "BL_getNextFrameTimeout"
|
||||
error: "BL_getLastError"
|
||||
|
||||
flash:
|
||||
hex_file_path: "firmware/ecu_firmware.hex"
|
||||
hex_file_path: firmware/ecu_firmware.hex
|
||||
flash_timeout: 30.0
|
||||
|
||||
ecu:
|
||||
name: "Test ECU"
|
||||
name: Test ECU
|
||||
lin_id_range: [0x01, 0x3F]
|
||||
```
|
||||
|
||||
### BabyLin Configuration (`config/babylin.example.yaml`)
|
||||
### BabyLIN Configuration (`config/babylin.example.yaml`)
|
||||
|
||||
```yaml
|
||||
babylin:
|
||||
dll_path: "C:/Path/To/BabyLIN.dll"
|
||||
interface_index: 0
|
||||
baudrate: 19200
|
||||
functions:
|
||||
open: "BL_open"
|
||||
close: "BL_close"
|
||||
send: "BL_mon_set_xmit"
|
||||
receive: "BL_getNextFrameTimeout"
|
||||
error: "BL_getLastError"
|
||||
interface:
|
||||
type: babylin
|
||||
channel: 0 # channel index used by the SDK wrapper
|
||||
bitrate: 19200 # typically set by SDF
|
||||
sdf_path: ./vendor/Example.sdf
|
||||
schedule_nr: 0 # schedule to start on connect
|
||||
```
|
||||
|
||||
## Test Categories
|
||||
@ -181,8 +204,8 @@ babylin:
|
||||
|
||||
### 2. Hardware Smoke Tests (`test_babylin_hardware_smoke.py`)
|
||||
|
||||
**Purpose**: Basic BabyLin hardware connectivity validation
|
||||
- ✅ BabyLin DLL loading and initialization
|
||||
**Purpose**: Basic BabyLIN hardware connectivity validation
|
||||
- ✅ SDK wrapper import and device open
|
||||
- ✅ Interface connection establishment
|
||||
- ✅ Basic send/receive operations
|
||||
- ✅ Error handling and cleanup
|
||||
@ -209,6 +232,8 @@ markers =
|
||||
smoke: Basic functionality tests
|
||||
integration: Integration tests requiring hardware
|
||||
hardware: Tests requiring physical BabyLin hardware
|
||||
babylin: Tests targeting the BabyLIN SDK adapter
|
||||
unit: Fast unit tests (no hardware)
|
||||
boundary: Boundary condition and edge case tests
|
||||
req_001: Tests validating requirement REQ-001 (LIN Interface Basic Operations)
|
||||
req_002: Tests validating requirement REQ-002 (Master Request/Response)
|
||||
@ -216,53 +241,37 @@ markers =
|
||||
req_004: Tests validating requirement REQ-004 (Timeout Handling)
|
||||
```
|
||||
|
||||
## BabyLin Integration Details
|
||||
## BabyLIN Integration Details
|
||||
|
||||
### ctypes Binding Implementation
|
||||
### SDK Python wrapper
|
||||
|
||||
The framework uses ctypes to interface with the BabyLin C DLL:
|
||||
The framework uses the official SDK Python wrapper `BabyLIN_library.py` (placed under `vendor/`) and calls its BLC_* APIs.
|
||||
|
||||
```python
|
||||
# Example function binding
|
||||
self._dll.BL_open.restype = ctypes.c_int
|
||||
self._dll.BL_open.argtypes = [ctypes.c_char_p]
|
||||
|
||||
# Frame structure mapping
|
||||
class _BL_frame_t(ctypes.Structure):
|
||||
_fields_ = [
|
||||
("id", ctypes.c_uint8),
|
||||
("len", ctypes.c_uint8),
|
||||
("data", ctypes.c_uint8 * 8),
|
||||
("timestamp", ctypes.c_uint32)
|
||||
]
|
||||
```
|
||||
|
||||
### Supported BabyLin Functions
|
||||
|
||||
- **BL_open**: Interface initialization
|
||||
- **BL_close**: Cleanup and disconnection
|
||||
- **BL_mon_set_xmit**: Frame transmission
|
||||
- **BL_getNextFrameTimeout**: Frame reception with timeout
|
||||
- **BL_getLastError**: Error code retrieval
|
||||
Key calls in the adapter (`ecu_framework/lin/babylin.py`):
|
||||
- `BLC_getBabyLinPorts`, `BLC_openPort` — discovery and open
|
||||
- `BLC_loadSDF`, `BLC_getChannelHandle`, `BLC_sendCommand('start schedule N;')` — SDF + scheduling
|
||||
- `BLC_mon_set_xmit` — transmit
|
||||
- `BLC_getNextFrameTimeout` — receive
|
||||
- `BLC_sendRawMasterRequest` — master request (length then bytes)
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### 1. Development Phase
|
||||
```powershell
|
||||
# Use mock interface for development
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest tests/test_smoke_mock.py -v
|
||||
python -m pytest tests\test_smoke_mock.py -v
|
||||
```
|
||||
|
||||
### 2. Hardware Integration Phase
|
||||
```powershell
|
||||
# Test with real BabyLin hardware
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "hardware" -v
|
||||
# Test with real BabyLIN hardware
|
||||
python -m pytest -m "hardware and babylin" -v
|
||||
```
|
||||
|
||||
### 3. Full System Testing
|
||||
```powershell
|
||||
# Complete test suite including ECU flashing
|
||||
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -v
|
||||
python -m pytest -v
|
||||
```
|
||||
|
||||
## Enhanced Reporting Output Example
|
||||
@ -294,7 +303,7 @@ The enhanced HTML report includes:
|
||||
**Configuration System**: ✅ **Complete**
|
||||
- YAML configuration loading: ✅ Working
|
||||
- Environment variable override: ✅ Working
|
||||
- BabyLin DLL path configuration: ✅ Working
|
||||
- BabyLIN SDF/schedule configuration: ✅ Working
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user