test_a_registration_inside_a_macro_body_is_counted_not_ignored¶
Tests › tests/test_isr.py
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
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); } """parser = Parser("c")tree = parser.parse(src)
When
spellings = frozenset(load_thread_patterns(None) and {p.name for p in DEFAULT_SPAWN_PATTERNS})hidden = count_macro_body_registrations(tree, src, spellings)visible = _sites(src)
Then
- ✓ hidden equals 1
- ✓ [site[ENTRY] for site in visible] equals ["other_isr"]
tests/test_isr.py:250 · its file's page
What it checks (2)
assert hidden == 1, f"the registration inside the #define body must be counted, got {hidden}"observescount_macro_body_registrationsviahiddenassert [site[ENTRY] for site in visible] == ["other_isr"], ( f"only the call outside the macro body is harvested, got {visible}" )observes_sitesviavisible
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→_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 3 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-PIPE-003 measured
- REQ-DDB-SCHEMA-001 measured
- REQ-DDB-SCHEMA-012 inferred