Skip to content

Commit 043ea23

Browse files
committed
fix(mdns): Add tests for service discovery
1 parent 9cc5e13 commit 043ea23

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

components/mdns/tests/host_test/pytest_mdns.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
1+
# SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
22
# SPDX-License-Identifier: Unlicense OR CC0-1.0
33
import logging
44

@@ -123,6 +123,23 @@ def test_add_delegated_service(mdns_console, dig_app):
123123
dig_app.check_record('extern._test2._tcp.local', query_type='SRV', expected=True)
124124

125125

126+
def test_service_discovery_dns_sd(dig_app):
127+
"""Query _services._dns-sd._udp.local PTR to discover registered service types (RFC 6763 §9)."""
128+
resp = dig_app.run_query('_services._dns-sd._udp.local', query_type='PTR')
129+
answers = dig_app.parse_answer_section(resp, 'PTR')
130+
assert any('_test._tcp.local' in a for a in answers), \
131+
f'Expected _test._tcp.local in DNS-SD response, got: {answers}'
132+
assert any('_test2._tcp.local' in a for a in answers), \
133+
f'Expected _test2._tcp.local in DNS-SD response, got: {answers}'
134+
135+
136+
def test_service_discovery_query(mdns_console):
137+
"""Test querier-side: query _services._dns-sd._udp via mdns_query_ptr (exercises multi-label splitting)."""
138+
mdns_console.send_input('mdns_query_ptr _services._dns-sd _udp -t 2000 -m 10')
139+
mdns_console.get_output('Query PTR: _services._dns-sd._udp.local')
140+
mdns_console.get_output('mdns>')
141+
142+
126143
def test_remove_delegated_service(mdns_console, dig_app):
127144
mdns_console.send_input('mdns_service_remove _test2 _tcp -h delegated')
128145
mdns_console.send_input('mdns_service_lookup _test2 _tcp -d')

0 commit comments

Comments
 (0)