Merge branch 'feat/add_teardown_for_openthread_case' into 'master'

ci: add tear down for openthread ci case

See merge request espressif/esp-idf!48776
This commit is contained in:
Shu Chen
2026-05-26 06:32:05 +00:00

View File

@@ -11,6 +11,7 @@ import subprocess
import sys
import threading
import time
from collections.abc import Generator
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import ot_ci_function as ocf
@@ -105,6 +106,25 @@ ESPPORT4 = os.getenv('ESPPORT4')
PORT_MAPPING = {'ESPPORT1': 'esp32h2', 'ESPPORT2': 'esp32s3', 'ESPPORT3': 'esp32c6', 'ESPPORT4': 'esp32c5'}
@pytest.fixture(scope='module', autouse=True)
def erase_flash_after_all_cases() -> Generator[None, None, None]:
yield
serial_ports = list(dict.fromkeys(filter(None, map(os.getenv, PORT_MAPPING))))
failed_ports = []
for serial_port in serial_ports:
command = ['python', '-m', 'esptool', '--port', serial_port, 'erase_flash']
logging.info('Erasing flash on %s: %s', serial_port, ' '.join(command))
result = subprocess.run(command, capture_output=True, text=True)
logging.info('Erase flash stdout on %s:\n%s', serial_port, result.stdout)
if result.stderr:
logging.info('Erase flash stderr on %s:\n%s', serial_port, result.stderr)
if result.returncode != 0:
failed_ports.append(serial_port)
assert not failed_ports, f'Failed to erase flash on ports: {failed_ports}'
# Case 1: Thread network formation and attaching
@pytest.mark.openthread_br
@pytest.mark.flaky(reruns=1, reruns_delay=5)