mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-18 04:52:18 +02:00
mdns test: Add test to resolve esp32 hostname with DiG
* Original commit: espressif/esp-idf@81e89476fe
This commit is contained in:
committed by
suren-gabrielyan-espressif
parent
ed77d65a82
commit
110f1f652d
@ -6,12 +6,11 @@ import struct
|
|||||||
import dpkt
|
import dpkt
|
||||||
import dpkt.dns
|
import dpkt.dns
|
||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from tiny_test_fw import DUT
|
from tiny_test_fw import DUT
|
||||||
import ttfw_idf
|
import ttfw_idf
|
||||||
|
|
||||||
# g_run_server = True
|
|
||||||
# g_done = False
|
|
||||||
stop_mdns_server = Event()
|
stop_mdns_server = Event()
|
||||||
esp_answered = Event()
|
esp_answered = Event()
|
||||||
|
|
||||||
@ -112,7 +111,8 @@ def test_examples_protocol_mdns(env, extra_data):
|
|||||||
thread1 = Thread(target=mdns_server, args=(specific_host,))
|
thread1 = Thread(target=mdns_server, args=(specific_host,))
|
||||||
thread1.start()
|
thread1.start()
|
||||||
try:
|
try:
|
||||||
dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30)
|
ip_address = dut1.expect(re.compile(r" sta ip: ([^,]+),"), timeout=30)[0]
|
||||||
|
print("Connected to AP with IP: {}".format(ip_address))
|
||||||
except DUT.ExpectTimeout:
|
except DUT.ExpectTimeout:
|
||||||
stop_mdns_server.set()
|
stop_mdns_server.set()
|
||||||
thread1.join()
|
thread1.join()
|
||||||
@ -125,6 +125,13 @@ def test_examples_protocol_mdns(env, extra_data):
|
|||||||
dut1.expect(re.compile(r"mdns-test: Query A: tinytester.local resolved to: 127.0.0.1"), timeout=30)
|
dut1.expect(re.compile(r"mdns-test: Query A: tinytester.local resolved to: 127.0.0.1"), timeout=30)
|
||||||
dut1.expect(re.compile(r"mdns-test: gethostbyname: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30)
|
dut1.expect(re.compile(r"mdns-test: gethostbyname: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30)
|
||||||
dut1.expect(re.compile(r"mdns-test: getaddrinfo: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30)
|
dut1.expect(re.compile(r"mdns-test: getaddrinfo: tinytester-lwip.local resolved to: 127.0.0.1"), timeout=30)
|
||||||
|
# 5. check the DUT answers to `dig` command
|
||||||
|
dig_output = subprocess.check_output(['dig', '+short', '-p', '5353', '@224.0.0.251',
|
||||||
|
'{}.local'.format(specific_host)])
|
||||||
|
print('Resolving {} using "dig" succeeded with:\n{}'.format(specific_host, dig_output))
|
||||||
|
if not ip_address.encode('utf-8') in dig_output:
|
||||||
|
raise ValueError("Test has failed: Incorrectly resolved DUT hostname using dig"
|
||||||
|
"Output should've contained DUT's IP address:{}".format(ip_address))
|
||||||
finally:
|
finally:
|
||||||
stop_mdns_server.set()
|
stop_mdns_server.set()
|
||||||
thread1.join()
|
thread1.join()
|
||||||
|
Reference in New Issue
Block a user