test_annotate_thread_boundaries_marks_queue_hop_crossing¶
Tests › tests/test_r1_richness.py
What this test is for
Why it exists
producer_task spawns thread A (entry producer_entry), consumer_task spawns thread B (entry consumer_entry). A queue hop producer_entry -> consumer_entry crosses the boundary.
Verifies REQ-DDB-SCHEMA-003 REQ-DDB-SCHEMA-004
Given
src = tmp_path / "src"src.mkdir()
4 more
(src / "foo.c").write_text( "void producer_entry(void) { QUEUESEND(&q, m); }\n" "void consumer_entry(void) { QUEUERECEIVE(&q, &m); }\n" "void boot(void) {\n" " pthread_create(&t1, 0, producer_entry, 0);\n" " pthread_create(&t2, 0, consumer_entry, 0);\n" "}\n", )db = _make_db( tmp_path, [ (1, "producer_entry", 1, 1), (2, "consumer_entry", 2, 2), (3, "boot", 3, 6), ], # no inter-entry call edges — each entry is its own closure call_edges=[], )patterns = tmp_path / "patterns.yaml"patterns.write_text( "writers:\n" " - pattern: QUEUESEND\n" " key_arg_index: 0\n" " dispatch_mode: queued\n" "readers:\n" " - pattern: QUEUERECEIVE\n" " key_arg_index: 0\n", )
When
import_shared_key_edges_inferred(db, tmp_path, patterns)extract_threads(db, tmp_path, None)annotate_thread_boundaries(db)
5 more
conn = sqlite3.connect(str(db))row = conn.execute( "SELECT writer_rowid, reader_rowid, dispatch_mode, crosses_thread, " "to_thread_id FROM shared_key_edges", ).fetchone()thread_for_consumer = conn.execute( "SELECT id FROM threads WHERE entry_memberdef_rowid = 2", ).fetchone()[0]conn.close()writer, reader, mode, crosses, to_thread = row
Then
- ✓ (writer, reader, mode) equals (1, 2, "queued")
- ✓ crosses equals 1
- ✓ to_thread equals thread_for_consumer
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
clew — `main` (clew/cli.py) · 7 of 400 steps
… 70 earlier steps
… 313 later steps
tests/test_r1_richness.py:938 · its file's page
What it checks (3)
assert (writer, reader, mode) == (1, 2, "queued")not attributedassert crosses == 1not attributedassert to_thread == thread_for_consumernot 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_annotate_thread_boundaries_marks_queue_hop_crossing→import_shared_key_edges_inferred→extract_threads→annotate_thread_boundariesWhat 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.
and 3 more requirement paths, listed below.
Requirements it verifies (2)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-SCHEMA-003 | catalog | unknown |
| REQ-DDB-SCHEMA-004 | catalog | unknown |
Also reaches 15 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-006 measured
- REQ-DDB-CONFIG-007 measured
- REQ-DDB-INDEX-002 measured
- REQ-DDB-PIPE-003 measured
- REQ-DDB-PIPE-004 measured
- REQ-DDB-PIPE-010 measured
- REQ-DDB-PIPE-011 measured
- REQ-DDB-PIPE-012 inferred
- REQ-DDB-QUERY-003 measured
- REQ-DDB-QUERY-011 measured
- REQ-DDB-SCHEMA-001 measured
- REQ-DDB-SCHEMA-002 measured
- REQ-DDB-SCHEMA-005 measured
- REQ-DDB-SCHEMA-007 measured
- REQ-DDB-SCHEMA-012 measured