mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-09 08:41:37 +03:00
Modular backend for the BLE log console rewrite:
- Frame parser with sync state machine and checksum auto-detection
(4 modes: XOR/Sum x Full/Header-only); handles incomplete frames
during re-sync search when previously synced
- Internal frame decoder (INIT_DONE, ENH_STAT, FLUSH, INFO)
- Data models: SourceCode, FrameByteCount, FunnelSnapshot, LossType
- Stats package with composition-root StatsAccumulator orchestrating:
- TransportMetrics (RX bytes, lifetime-average throughput)
- FirmwareLossTracker / FirmwareWrittenTracker (ENH_STAT deltas
with first-report absolute value initialization)
- SNGapTracker (sliding window reorder-tolerant SN gap detection)
- PeakBurstTracker (per-source sliding window burst density)
- TrafficSpikeDetector (wire utilization spike detection)
- Wall-clock burst tracker for non-timestamped sources (REDIR)
- Torn-read guard on ENH_STAT reports (baudrate-based plausibility)
with prev-state update on discard to prevent cascading drops
- Console-local metrics (TransportMetrics, PeakBurstTracker) preserved
across INIT_DONE resets; only ENH_STAT-coupled components reset
- UART transport with port validation and exclusive serial access
- Comprehensive test suite (17 test files, 223 tests)
36 lines
992 B
Python
36 lines
992 B
Python
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from src.backend.models import FrameByteCount
|
|
from src.backend.models import FunnelSnapshot
|
|
from src.backend.models import LossType
|
|
from src.backend.models import ThroughputInfo
|
|
|
|
|
|
def test_frame_byte_count():
|
|
fbc = FrameByteCount(frames=100, bytes=5000)
|
|
assert fbc.frames == 100
|
|
assert fbc.bytes == 5000
|
|
|
|
|
|
def test_loss_type_enum():
|
|
assert LossType.BUFFER == 'buffer'
|
|
assert LossType.TRANSPORT == 'transport'
|
|
|
|
|
|
def test_funnel_snapshot_structure():
|
|
zero = FrameByteCount(frames=0, bytes=0)
|
|
tp = ThroughputInfo(
|
|
throughput_fps=0.0, throughput_bps=0.0, peak_write_frames=0, peak_write_bytes=0, peak_window_ms=10
|
|
)
|
|
snap = FunnelSnapshot(
|
|
source=0,
|
|
produced=zero,
|
|
written=zero,
|
|
received=zero,
|
|
buffer_loss=zero,
|
|
transport_loss=zero,
|
|
throughput=tp,
|
|
)
|
|
assert snap.produced.frames == 0
|