test_an_operandless_hold_is_paired_by_name_not_by_operand

Tests › tests/test_critical_sections.py

passed Passed in the packaged run.

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

  1. parser = Parser("c")
  2. patterns = { "irq_disable": LockPattern( "irq_disable", form="call", kind="mutex", role="acquire", releases="irq_restore" ) }
→

When

  1. sites = _walk_lock_sites(parser.parse(_OPERANDLESS_PAIRED), _OPERANDLESS_PAIRED, patterns)
  2. by_line = {site[3]: site for site in sites}
  3. paired = by_line[8]
  4. unreleased = by_line[15]
→

Then

  1. ✓ paired[END_LINE] equals 10
  2. ✓ paired[CONFIDENCE] equals EXTENT_EXACT
  3. ✓ [call[0] for call in paired[CALLS]] contains "touch"
  4. ✓ unreleased[END_LINE] is None
  5. ✓ unreleased[CONFIDENCE] equals EXTENT_UNRESOLVED

tests/test_critical_sections.py:822 · its file's page

What it checks (5)

  1. assert paired[END_LINE] == 10, f"the hold ends at its irq_restore, got {paired[END_LINE]}" not attributed
  2. assert paired[CONFIDENCE] == EXTENT_EXACT, ( f"one balanced pair needs no inference; got {paired[CONFIDENCE]}" ) not attributed
  3. assert "touch" in [call[0] for call in paired[CALLS]], ( f"the call under the hold must be recorded, got {paired[CALLS]}" ) not attributed
  4. assert unreleased[END_LINE] is None, "an unreleased hold has no measured extent" not attributed
  5. assert unreleased[CONFIDENCE] == EXTENT_UNRESOLVED not 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_sites

What 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.

test_an_operandless_hold_is_paired_by_name_not_by_operand · 5 checks_walk_lock_sites… 3 calls …enclosingREQ-DDB-PIPE-003 · measured_walk_lock_sites… 3 calls …resolve_sectionREQ-DDB-SCHEMA-011 · measured
Also reaches 2 requirements

Its run touches their code; that is reach, not proof.