The MUM (Melexis Universal Master) adapter is the current default; the
BabyLIN SDK adapter is retained only for backward compatibility with
existing rigs.
Code:
- Emit DeprecationWarning when BabyLinInterface is instantiated and
when tests/conftest.py routes interface.type=='babylin' to it.
- Update module/class docstrings in ecu_framework/{__init__,config,
lin/__init__,lin/babylin}.py to label BabyLIN-specific fields and
paths as deprecated.
Config / scripts / pytest:
- pytest.ini: relabel the babylin marker as deprecated.
- config/{babylin.example,examples,test_config}.yaml: add deprecation
banners and field comments.
- scripts/99-babylin.rules and scripts/pi_install.sh: annotate the
udev-rule install block as legacy-only.
Documentation:
- TESTING_FRAMEWORK_GUIDE.md, docs/08_babylin_internals.md, and
vendor/README.md: prepend explicit "DEPRECATED" banners.
- docs/{README,01,02,04,05,07,09,10,12,13,14,15,18,DEVELOPER_COMMIT_
GUIDE}.md: relabel "legacy" to "deprecated" where babylin is
mentioned, present MUM as the primary path, and steer new work
toward the MUM examples.
No tests, configs, or modules were deleted; existing BabyLIN setups
keep working but now produce a clear DeprecationWarning at runtime.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.6 KiB
5.6 KiB
Run Sequence: What Happens When You Start Tests
This document walks through the exact order of operations when you run the framework with pytest, what gets called, and where configuration/data is fetched from.
High-level flow
- You run pytest from PowerShell
- pytest reads
pytest.iniand loads configured plugins (including our customconftest_plugin) - Test discovery collects tests under
tests/ - Session fixtures run:
config()loads YAML configurationlin()selects and connects the LIN interface (Mock, MUM, or the deprecated BabyLIN)flash_ecu()optionally flashes the ECU (if enabled)
- Tests execute using fixtures and call interface methods
- Our plugin extracts test metadata (Title, Requirements, Steps) from docstrings
- Reports are written to
reports/report.htmlandreports/junit.xml
Detailed call sequence
sequenceDiagram
autonumber
participant U as User (PowerShell)
participant P as pytest
participant PI as pytest.ini
participant PL as conftest_plugin.py
participant T as Test Discovery (tests/*)
participant F as Fixtures (conftest.py)
participant C as Config Loader (ecu_framework/config.py)
participant PS as Power Supply (optional)
participant L as LIN Adapter (mock/MUM/BabyLIN)
participant X as HexFlasher (optional)
participant R as Reports (HTML/JUnit)
U->>P: python -m pytest [args]
P->>PI: Read addopts, markers, plugins
P->>PL: Load custom plugin hooks
P->>T: Collect tests
P->>F: Init session fixtures
F->>C: load_config(workspace_root)
C-->>F: EcuTestConfig (merged dataclasses)
F->>L: Create interface (mock, MUM, or BabyLIN SDK)
L-->>F: Instance ready
F->>L: connect()
alt flash.enabled and hex_path provided
F->>X: HexFlasher(lin).flash_hex(hex_path)
X-->>F: Flash result (ok/fail)
end
opt power_supply.enabled and port provided
Note over PS: owon_psu_quick_demo may open PSU via ecu_framework.power.owon_psu
end
loop for each test
P->>PL: runtest_makereport(item, call)
Note over PL: Parse docstring and attach metadata
P->>L: send()/receive()/request()
L-->>P: Frames or None (timeout)
end
P->>R: Write HTML (with metadata columns)
P->>R: Write JUnit XML
PowerShell → python -m pytest
↓
pytest loads pytest.ini
- addopts: --junitxml, --html, --self-contained-html, -p conftest_plugin
- markers registered
↓
pytest collects tests in tests/
↓
Session fixture: config()
→ calls ecu_framework.config.load_config(workspace_root)
→ determines config file path by precedence
→ merges YAML + overrides into dataclasses (EcuTestConfig)
→ optionally merges config/owon_psu.yaml (or OWON_PSU_CONFIG) into power_supply
↓
Session fixture: lin(config)
→ chooses interface by config.interface.type
- mock → ecu_framework.lin.mock.MockBabyLinInterface(...)
- mum → ecu_framework.lin.mum.MumLinInterface(host, lin_device, power_device, ...)
- babylin → ecu_framework.lin.babylin.BabyLinInterface(...) [DEPRECATED]
→ lin.connect()
- MUM connect() also powers up the ECU via power_out0 and waits boot_settle_seconds
↓
Optional session fixture: flash_ecu(config, lin)
→ if config.flash.enabled and hex_path set
→ ecu_framework.flashing.HexFlasher(lin).flash_hex(hex_path)
↓
Test functions execute
→ use the lin fixture to send/receive/request
↓
Reporting plugin (conftest_plugin.py)
→ pytest_runtest_makereport parses test docstring
→ attaches user_properties: title, requirements, steps, expected_result
→ pytest-html hooks add Title and Requirements columns
↓
Reports written
→ reports/report.html (HTML with metadata columns)
→ reports/junit.xml (JUnit XML for CI)
Where information is fetched from
- pytest configuration:
pytest.ini - YAML config (default):
config/test_config.yaml - YAML override via env var:
ECU_TESTS_CONFIG - BabyLIN SDK wrapper and SDF path (DEPRECATED):
interface.sdf_pathandinterface.schedule_nrin YAML - Test metadata: parsed from each test’s docstring
- Markers: declared in
pytest.ini, attached in tests via@pytest.mark.*
Key components involved
tests/conftest.py: definesconfig,lin, andflash_ecufixturesecu_framework/config.py: loads and merges configuration into dataclassesecu_framework/lin/base.py: abstract LIN interface contract and frame shapeecu_framework/lin/mock.py: mock behavior for send/receive/requestecu_framework/lin/mum.py: MUM adapter (Melexis Universal Master via pylin + pymumclient)ecu_framework/lin/babylin.py: BabyLIN SDK wrapper adapter (DEPRECATED real hardware path via BabyLIN_library.py; emitsDeprecationWarningon use)ecu_framework/flashing/hex_flasher.py: placeholder flashing logicconftest_plugin.py: report customization and metadata extraction
Edge cases and behavior
- If
interface.typeisbabylin(deprecated) but the SDK wrapper or libraries cannot be loaded, hardware tests are skipped - If
interface.typeismumbutpylin/pymumclientaren't importable, orinterface.hostis unset, hardware tests are skipped with a clear message - If
flash.enabledis true buthex_pathis missing, flashing fixture skips - Timeouts are honored in
receive()andrequest()implementations - Invalid frame IDs (outside 0x00–0x3F) or data > 8 bytes will raise in
LinFrame - MUM
receive()is master-driven: it requires a frame ID;receive(id=None)raises NotImplementedError. Diagnostic frames needing LIN 1.x Classic checksum should useMumLinInterface.send_raw().