Coverage for tests/io/test_evt3_edge_cases.py: 100%
7 statements
« prev ^ index » next coverage.py v7.15.1, created at 2026-07-15 09:33 +0000
« prev ^ index » next coverage.py v7.15.1, created at 2026-07-15 09:33 +0000
1"""EVT3 parser coverage gaps — recorded as skipped stubs to fill in later.
3The normal recordings exercise the common EVT3 packets, but a few real branches
4in ``EVT3_parse_chunk_soa`` (csrc/evt3.c) are never hit by them, and the
5target-clone build makes branch coverage look worse than it is. Each test below
6documents one gap: what input triggers the branch and what to assert. Drop the
7``skip`` and implement the body when writing the real test.
9These are correctness gaps, not known bugs.
10"""
11import pytest
14@pytest.mark.skip(reason="TODO: exercise incomplete vector continuation branch")
15def test_incomplete_vector_continuation() -> None:
16 """A VECT_BASE_X / VECT_12 group whose follow-up word is NOT the expected
17 continuation type.
19 In ``EVT3_parse_vector_12_12_8_soa`` the two nested ``if
20 (EVT3_get_packet_type(*current) == EVT3_VECT_12 / EVT3_VECT_8)`` checks
21 (evt3.c ~225 / ~229) only ever take the "present" side with real data, so
22 the "absent" side is never covered.
24 How to test: hand-craft a uint16 EVT3 word stream (not a full recording) with
25 a VECT_BASE_X followed by a single VECT_12 word and then a NON-VECT word
26 (e.g. an EVT_ADDR_X), so the 2nd/3rd continuation is missing. Feed it through
27 the low-level SOA parse step (see evutils.io._native_evt / _native_core
28 parse_step) and assert the decoded event count matches only the bits present
29 in the first vector word.
30 """
33@pytest.mark.skip(reason="TODO: exercise output-buffer-full early exit")
34def test_output_buffer_full_stops_mid_chunk() -> None:
35 """Main loop guard ``n_events_read < events_capacity_offset`` (and the
36 trigger equivalent) tripping before the input is consumed.
38 Normal runs size the output buffers generously, so the loop always exits on
39 end-of-input, never on capacity — leaving the capacity guards at ~83%
40 (evt3.c ~297 / ~322). This is the "small event array" case.
42 How to test: drive ``EVT3_parse_chunk_soa`` with a small event buffer
43 (capacity just above the 64-slot vector headroom) and enough input to
44 overflow it. Assert the parser returns with ``current`` short of ``end`` and
45 ``event_buffer.size`` at the cap, then that a second call resumes from
46 ``current`` and drains the rest with no lost/duplicated events.
47 """
50@pytest.mark.skip(reason="Measurement note, not a runtime test — see docstring")
51def test_note_target_clone_branch_coverage() -> None:
52 """gcovr under-reports EVT3 branch coverage because of function multi-versioning.
54 ``EVUTILS_TARGET_CLONES`` (csrc/include/evutils/compat.h) tags the hot chunk
55 parsers with ``__attribute__((target_clones("avx2","default")))`` on
56 GCC/x86-64, so the compiler emits TWO instantiations of each function. The
57 coverage host runs only one clone (whichever its CPU dispatches to); gcovr
58 still counts the branches of BOTH, so the unrun clone shows every branch as
59 "not taken" and halves the reported branch-rate.
61 Fix for a later PR (not code to run here): build the coverage target with the
62 clones disabled so branches attribute to a single instantiation. E.g. give
63 ``EVUTILS_COVERAGE`` in CMakeLists.txt a ``-DEVUTILS_NO_TARGET_CLONES``
64 define and make ``EVUTILS_TARGET_CLONES`` expand to nothing when it is set.
65 Then re-run scripts/coverage.sh and confirm evt3.c branch-rate jumps.
66 """