test_an_operandless_hold_gets_a_persisted_global_identity¶
Tests › tests/test_critical_sections.py
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
conn = sqlite3.connect(":memory:")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
_ensure_lock_tables(conn)record = [ "irq_disable", "", "global", 8, 10, "call", "mutex", "exclusive", "acquire", "high", [], ]unresolved = [ "m_lock", "", "unknown", 20, None, "call", "mutex", "exclusive", "acquire", "low", [], ]
3 more
_insert_sites(conn, 1, [record, unresolved], [(1, "paired", 1, 40)], {})rows = conn.execute("SELECT name, scope, kind, identity_confidence FROM locks").fetchall()held = conn.execute( "SELECT pattern_name, lock_id IS NOT NULL FROM lock_acquisitions ORDER BY start_line" ).fetchall()
Then
- ✓ rows equals [("irq_disable", "global", "mutex", "high")]
- ✓ held equals [("irq_disable", 1), ("m_lock", 0)]
tests/test_critical_sections.py:874 · its file's page
What it checks (2)
assert rows == [("irq_disable", "global", "mutex", "high")], ( f"the operand-less hold must be persisted under the primitive's name, got {rows}" )not attributedassert 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_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-SCHEMA-011 measured
- REQ-DDB-SCHEMA-012 measured