test_annotate_thread_boundaries_marks_queue_hop_crossing

Tests › tests/test_r1_richness.py

passed Passed in the packaged run.

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

  1. src = tmp_path / "src"
  2. src.mkdir()
4 more
  1. (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", )
  2. 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=[], )
  3. patterns = tmp_path / "patterns.yaml"
  4. 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

  1. import_shared_key_edges_inferred(db, tmp_path, patterns)
  2. extract_threads(db, tmp_path, None)
  3. annotate_thread_boundaries(db)
5 more
  1. conn = sqlite3.connect(str(db))
  2. row = conn.execute( "SELECT writer_rowid, reader_rowid, dispatch_mode, crosses_thread, " "to_thread_id FROM shared_key_edges", ).fetchone()
  3. thread_for_consumer = conn.execute( "SELECT id FROM threads WHERE entry_memberdef_rowid = 2", ).fetchone()[0]
  4. conn.close()
  5. writer, reader, mode, crosses, to_thread = row
→

Then

  1. ✓ (writer, reader, mode) equals (1, 2, "queued")
  2. ✓ crosses equals 1
  3. ✓ 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

command-line usercommand-line usercommand-line usercommand-line userother filesother filesother filesother filesloop (line 134)looploop (line 135)loopopt (line 385)optmain71–72. repo_source_files → _scandir71_scandir +1 more73. _ts_language_for → _grammar_available73_grammar_available74–75. _grammar_available → has_language74has_language +1 more76. _ts_language_for → _try_import_ts_module76_try_import_ts_module77–80. build_context → scope_membership77scope_membership +3 more81. _ast_parse_one_file → _ts_language_for81_ts_language_for▶ test enters82–85. _ast_parse_one_file → _cached_parser82_cached_parser +3 more86–87. _ast_parse_one_file → _disambiguate_header86_disambiguate_header +1 more

… 313 later steps

tests/test_r1_richness.py:938 · its file's page

What it checks (3)

  1. assert (writer, reader, mode) == (1, 2, "queued") not attributed
  2. assert crosses == 1 not attributed
  3. assert to_thread == thread_for_consumer 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_annotate_thread_boundaries_marks_queue_hop_crossing→import_shared_key_edges_inferred→extract_threads→annotate_thread_boundaries

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_annotate_thread_boundaries_marks_queue_hop_crossing · 3 checksimport_shared_key_edges_inferredshared_key_harvesterresolve_shared_key_patternsREQ-DDB-CONFIG-006 · measuredimport_shared_key_edges_inferred_log_undeclared_accessor_hintdetect_undeclared_accessor_familiesREQ-DDB-CONFIG-007 · measuredextract_threadsspawn_harvestermanifest_keyhash_fileREQ-DDB-INDEX-002 · measuredimport_shared_key_edges_inferred_walk_all_files_for_shared_keysrun_harvestREQ-DDB-PIPE-003 · measuredextract_threads_populate_membership_bfs_live_setREQ-DDB-PIPE-004 · measuredimport_shared_key_edges_inferred_build_inferred_edgesREQ-DDB-PIPE-010 · measuredimport_shared_key_edges_inferred… 3 calls …_parseable_fileREQ-DDB-PIPE-011 · measuredimport_shared_key_edges_inferred… 5 calls …has_languageREQ-DDB-PIPE-012 · inferredextract_threads_definition_preferring_name_indexREQ-DDB-QUERY-003 · measuredextract_threads_ensure_threads_tablesREQ-DDB-QUERY-011 · measuredextract_threadsREQ-DDB-SCHEMA-001 · measuredimport_shared_key_edges_inferred_writer_dispatch_mapREQ-DDB-SCHEMA-002 · measured

and 3 more requirement paths, listed below.

Requirements it verifies (2)

requirementlinked byimplementers exercised
REQ-DDB-SCHEMA-003catalogunknown
REQ-DDB-SCHEMA-004catalogunknown
Also reaches 15 requirements

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