diff --git a/examples/openthread/ot_ci_function.py b/examples/openthread/ot_ci_function.py index ddcdfa28c4..c84b96593e 100644 --- a/examples/openthread/ot_ci_function.py +++ b/examples/openthread/ot_ci_function.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 # !/usr/bin/env python3 # this file defines some functions for testing cli and br under pytest framework @@ -408,20 +408,21 @@ def get_host_ipv4_address() -> str: return host_ipv4_address -def start_avahi() -> None: - time.sleep(1) - command = '/etc/init.d/dbus start' +def restart_avahi() -> None: + command = 'avahi-daemon -k' subprocess.Popen(command, shell=True) - time.sleep(5) + time.sleep(2) command = 'avahi-daemon' subprocess.Popen(command, shell=True) time.sleep(5) -def host_publish_service() -> None: - command = 'avahi-publish-service testxxx _testxxx._udp 12347 test=1235 dn="for_ci_br_test"' +def start_avahi() -> None: + time.sleep(1) + command = '/etc/init.d/dbus start' subprocess.Popen(command, shell=True) - time.sleep(2) + time.sleep(5) + restart_avahi() def host_close_service() -> None: diff --git a/examples/openthread/pytest_otbr.py b/examples/openthread/pytest_otbr.py index bfa04f4231..846247e2ad 100644 --- a/examples/openthread/pytest_otbr.py +++ b/examples/openthread/pytest_otbr.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Unlicense OR CC0-1.0 # !/usr/bin/env python3 import copy @@ -447,7 +447,10 @@ def test_service_discovery_of_WiFi_device(Init_interface:bool, Init_avahi:bool, command = 'dns browse _testxxx._udp.default.service.arpa' tmp = ocf.get_ouput_string(cli, command, 5) assert 'Port:12347' not in str(tmp) - ocf.host_publish_service() + ocf.restart_avahi() + command = 'avahi-publish-service testxxx _testxxx._udp 12347 test=1235 dn="for_ci_br_test"' + sp = subprocess.Popen(command, shell=True) + time.sleep(2) ocf.wait(cli, 5) command = 'dns browse _testxxx._udp.default.service.arpa' @@ -455,14 +458,13 @@ def test_service_discovery_of_WiFi_device(Init_interface:bool, Init_avahi:bool, assert 'response for _testxxx' in str(tmp) assert 'Port:12347' in str(tmp) - command = 'dns browse _testxxx._udp.default.service.arpa' + command = 'dns service testxxx _testxxx._udp.default.service.arpa.' tmp = ocf.get_ouput_string(cli, command, 5) - ocf.execute_command(cli, 'dns service testxxx _testxxx._udp.default.service.arpa.') - tmp = cli.expect(pexpect.TIMEOUT, timeout=5) assert 'response for testxxx' in str(tmp) assert 'Port:12347' in str(tmp) finally: ocf.host_close_service() + sp.terminate() ocf.execute_command(br, 'factoryreset') ocf.execute_command(cli, 'factoryreset') time.sleep(3)