FIXUP! update documentation

This commit is contained in:
Hosam-Eldin.mostafa 2025-10-20 20:54:40 +02:00
parent 030a813177
commit 93463789a5

View File

@ -8,7 +8,7 @@ This comprehensive ECU Testing Framework provides a robust solution for testing
### ✅ **Complete Implementation Status** ### ✅ **Complete Implementation Status**
- **✅ pytest-based testing framework** with custom plugins - **✅ 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** - **✅ Mock interface for hardware-independent development**
- **✅ Enhanced HTML/XML reporting with test metadata** - **✅ Enhanced HTML/XML reporting with test metadata**
- **✅ Detailed test documentation extraction** - **✅ Detailed test documentation extraction**
@ -87,9 +87,9 @@ ecu_tests/
├── config/ # Configuration files ├── config/ # Configuration files
│ ├── test_config.yaml # Main test configuration │ ├── test_config.yaml # Main test configuration
│ └── babylin.example.yaml # BabyLin configuration template │ └── babylin.example.yaml # BabyLin configuration template
├── vendor/babylin/ # BabyLin SDK integration ├── vendor/ # BabyLIN SDK placement
│ ├── BabyLIN.dll # Hardware interface library | ├── BabyLIN_library.py # Official SDK Python wrapper
│ └── include/BabyLIN.h # SDK header definitions | └── platform libs # OS-specific native libs (DLL/.so/.dylib)
├── reports/ # Generated test reports ├── reports/ # Generated test reports
│ ├── report.html # Enhanced HTML report │ ├── report.html # Enhanced HTML report
│ └── junit.xml # JUnit XML report │ └── junit.xml # JUnit XML report
@ -105,19 +105,55 @@ ecu_tests/
```powershell ```powershell
# Run all tests with verbose output # 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 # 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 # Run tests with specific markers
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "smoke" -v python -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 "req_001" -v
# Run hardware tests (requires BabyLin hardware) # Run hardware tests (requires BabyLIN hardware); join with adapter marker
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "hardware" -v 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 ### Report Generation
Tests automatically generate enhanced reports: Tests automatically generate enhanced reports:
@ -130,40 +166,27 @@ Tests automatically generate enhanced reports:
```yaml ```yaml
interface: interface:
type: "mock" # or "babylin" for hardware type: mock # or babylin for hardware
timeout: 1.0 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: flash:
hex_file_path: "firmware/ecu_firmware.hex" hex_file_path: firmware/ecu_firmware.hex
flash_timeout: 30.0 flash_timeout: 30.0
ecu: ecu:
name: "Test ECU" name: Test ECU
lin_id_range: [0x01, 0x3F] lin_id_range: [0x01, 0x3F]
``` ```
### BabyLin Configuration (`config/babylin.example.yaml`) ### BabyLIN Configuration (`config/babylin.example.yaml`)
```yaml ```yaml
babylin: interface:
dll_path: "C:/Path/To/BabyLIN.dll" type: babylin
interface_index: 0 channel: 0 # channel index used by the SDK wrapper
baudrate: 19200 bitrate: 19200 # typically set by SDF
functions: sdf_path: ./vendor/Example.sdf
open: "BL_open" schedule_nr: 0 # schedule to start on connect
close: "BL_close"
send: "BL_mon_set_xmit"
receive: "BL_getNextFrameTimeout"
error: "BL_getLastError"
``` ```
## Test Categories ## Test Categories
@ -181,8 +204,8 @@ babylin:
### 2. Hardware Smoke Tests (`test_babylin_hardware_smoke.py`) ### 2. Hardware Smoke Tests (`test_babylin_hardware_smoke.py`)
**Purpose**: Basic BabyLin hardware connectivity validation **Purpose**: Basic BabyLIN hardware connectivity validation
- ✅ BabyLin DLL loading and initialization - ✅ SDK wrapper import and device open
- ✅ Interface connection establishment - ✅ Interface connection establishment
- ✅ Basic send/receive operations - ✅ Basic send/receive operations
- ✅ Error handling and cleanup - ✅ Error handling and cleanup
@ -209,6 +232,8 @@ markers =
smoke: Basic functionality tests smoke: Basic functionality tests
integration: Integration tests requiring hardware integration: Integration tests requiring hardware
hardware: Tests requiring physical BabyLin 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 boundary: Boundary condition and edge case tests
req_001: Tests validating requirement REQ-001 (LIN Interface Basic Operations) req_001: Tests validating requirement REQ-001 (LIN Interface Basic Operations)
req_002: Tests validating requirement REQ-002 (Master Request/Response) req_002: Tests validating requirement REQ-002 (Master Request/Response)
@ -216,53 +241,37 @@ markers =
req_004: Tests validating requirement REQ-004 (Timeout Handling) 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 Key calls in the adapter (`ecu_framework/lin/babylin.py`):
# Example function binding - `BLC_getBabyLinPorts`, `BLC_openPort` — discovery and open
self._dll.BL_open.restype = ctypes.c_int - `BLC_loadSDF`, `BLC_getChannelHandle`, `BLC_sendCommand('start schedule N;')` — SDF + scheduling
self._dll.BL_open.argtypes = [ctypes.c_char_p] - `BLC_mon_set_xmit` — transmit
- `BLC_getNextFrameTimeout` — receive
# Frame structure mapping - `BLC_sendRawMasterRequest` — master request (length then bytes)
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
## Development Workflow ## Development Workflow
### 1. Development Phase ### 1. Development Phase
```powershell ```powershell
# Use mock interface for development # 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 ### 2. Hardware Integration Phase
```powershell ```powershell
# Test with real BabyLin hardware # Test with real BabyLIN hardware
C:/E/TeqanyLogix_repos/ecu_tests/.venv/Scripts/python.exe -m pytest -m "hardware" -v python -m pytest -m "hardware and babylin" -v
``` ```
### 3. Full System Testing ### 3. Full System Testing
```powershell ```powershell
# Complete test suite including ECU flashing # 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 ## Enhanced Reporting Output Example
@ -294,7 +303,7 @@ The enhanced HTML report includes:
**Configuration System**: ✅ **Complete** **Configuration System**: ✅ **Complete**
- YAML configuration loading: ✅ Working - YAML configuration loading: ✅ Working
- Environment variable override: ✅ Working - Environment variable override: ✅ Working
- BabyLin DLL path configuration: ✅ Working - BabyLIN SDF/schedule configuration: ✅ Working
## Next Steps ## Next Steps