test_an_operandless_hold_is_paired_by_name_not_by_operand¶
Tests › tests/test_critical_sections.py
What this test is for
Why it exists
gh#47 part 3, the extent half. `_releases` matches a release BY OPERAND, deliberately — "releasing a DIFFERENT mutex inside this section is not the end of this hold, and treating it as one would truncate the section at an unrelated statement". That rule is right for `pthread_mutex_unlock(&m)` and cannot work here: `irq_restore(irqstate)` names the SAVED STATE, not the lock, and that variable differs at every site.
Given
parser = Parser("c")patterns = { "irq_disable": LockPattern( "irq_disable", form="call", kind="mutex", role="acquire", releases="irq_restore" ) }
When
sites = _walk_lock_sites(parser.parse(_OPERANDLESS_PAIRED), _OPERANDLESS_PAIRED, patterns)by_line = {site[3]: site for site in sites}paired = by_line[8]unreleased = by_line[15]
Then
- ✓ paired[END_LINE] equals 10
- ✓ paired[CONFIDENCE] equals EXTENT_EXACT
- ✓ [call[0] for call in paired[CALLS]] contains "touch"
- ✓ unreleased[END_LINE] is None
- ✓ unreleased[CONFIDENCE] equals EXTENT_UNRESOLVED
tests/test_critical_sections.py:822 · its file's page
What it checks (5)
assert paired[END_LINE] == 10, f"the hold ends at its irq_restore, got {paired[END_LINE]}"not attributedassert paired[CONFIDENCE] == EXTENT_EXACT, ( f"one balanced pair needs no inference; got {paired[CONFIDENCE]}" )not attributedassert "touch" in [call[0] for call in paired[CALLS]], ( f"the call under the hold must be recorded, got {paired[CALLS]}" )not attributedassert unreleased[END_LINE] is None, "an unreleased hold has no measured extent"not attributedassert unreleased[CONFIDENCE] == EXTENT_UNRESOLVEDnot attributed
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
Call flow
test_an_operandless_hold_is_paired_by_name_not_by_operand→_walk_lock_sitesWhat it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-PIPE-003 measured
- REQ-DDB-SCHEMA-011 measured