test_an_operandless_hold_gets_a_persisted_global_identity

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 half that never reached the DB. f037905 scopes an operand-less acquisition `global` IN THE HARVEST PAYLOAD, and `_lock_id` then drops it: it returns None whenever the operand is empty, so `irq_disable()` gets `lock_id NULL`, no `locks` row, and neither its kind nor its global scope is persisted at all.

Given

  1. conn = sqlite3.connect(":memory:")
  2. conn.executescript( """ CREATE TABLE path (name TEXT); CREATE TABLE memberdef (name TEXT, kind TEXT); INSERT INTO path (name) VALUES ('src/irq.c'); INSERT INTO memberdef (name, kind) VALUES ('paired', 'function'); """ )
→

When

  1. _ensure_lock_tables(conn)
  2. record = [ "irq_disable", "", "global", 8, 10, "call", "mutex", "exclusive", "acquire", "high", [], ]
  3. unresolved = [ "m_lock", "", "unknown", 20, None, "call", "mutex", "exclusive", "acquire", "low", [], ]
3 more
  1. _insert_sites(conn, 1, [record, unresolved], [(1, "paired", 1, 40)], {})
  2. rows = conn.execute("SELECT name, scope, kind, identity_confidence FROM locks").fetchall()
  3. held = conn.execute( "SELECT pattern_name, lock_id IS NOT NULL FROM lock_acquisitions ORDER BY start_line" ).fetchall()
→

Then

  1. ✓ rows equals [("irq_disable", "global", "mutex", "high")]
  2. ✓ held equals [("irq_disable", 1), ("m_lock", 0)]

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

What it checks (2)

  1. assert rows == [("irq_disable", "global", "mutex", "high")], ( f"the operand-less hold must be persisted under the primitive's name, got {rows}" ) not attributed
  2. assert held == [("irq_disable", 1), ("m_lock", 0)], ( f"only the global hold gets an identity; an unresolved operand keeps none, got {held}" ) 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_gets_a_persisted_global_identity→_ensure_lock_tables→_insert_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_gets_a_persisted_global_identity · 2 checks_ensure_lock_tablesensure_section_tableREQ-DDB-SCHEMA-011 · measured
Also reaches 2 requirements

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