test_a_registration_inside_a_macro_body_is_counted_not_ignored

Tests › tests/test_isr.py

passed Passed in the packaged run.

What this test is for

Why it exists

THE NUMBER THAT KEEPS A ZERO HONEST. A Zephyr driver instantiates itself once per devicetree node, so its IRQ_CONNECT is written inside a `#define` body and expanded by `DT_INST_FOREACH_STATUS_OKAY`. tree-sitter exposes a macro body as opaque text — there is no call node to match — and at v4.4.2 that is 718 of 1110 sites (64.7%).

Given

  1. src = b"""\ #define UART_INIT(n) \\ static void uart_irq_config_##n(const struct device *dev) \\ { \\ IRQ_CONNECT(DT_INST_IRQN(n), DT_INST_IRQ(n, priority), \\ uart_isr, DEVICE_DT_INST_GET(n), 0); \\ } void visible_setup(void) { IRQ_CONNECT(3, 1, other_isr, NULL, 0); } """
  2. parser = Parser("c")
  3. tree = parser.parse(src)
→

When

  1. spellings = frozenset(load_thread_patterns(None) and {p.name for p in DEFAULT_SPAWN_PATTERNS})
  2. hidden = count_macro_body_registrations(tree, src, spellings)
  3. visible = _sites(src)
→

Then

  1. ✓ hidden equals 1
  2. ✓ [site[ENTRY] for site in visible] equals ["other_isr"]

tests/test_isr.py:250 · its file's page

What it checks (2)

  1. assert hidden == 1, f"the registration inside the #define body must be counted, got {hidden}" observes count_macro_body_registrations via hidden
  2. assert [site[ENTRY] for site in visible] == ["other_isr"], ( f"only the call outside the macro body is harvested, got {visible}" ) observes _sites via visible

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_a_registration_inside_a_macro_body_is_counted_not_ignored→load_thread_patterns→count_macro_body_registrations→_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_a_registration_inside_a_macro_body_is_counted_not_ignored · 2 checks_sites_walk_spawn_sitesis_python_treeREQ-DDB-PIPE-003 · measuredcount_macro_body_registrationsREQ-DDB-SCHEMA-001 · measuredload_thread_patternsdeclaration_originREQ-DDB-SCHEMA-012 · inferred
Also reaches 3 requirements

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