mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'fix_otatool_serial_handoff_v5.5' into 'release/v5.5'
fix(otatool): fix flaky serial port handoff in otatool CI test (backport v5.5) See merge request espressif/esp-idf!47714
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
@@ -29,6 +31,10 @@ def test_otatool_example(dut: Dut) -> None:
|
|||||||
# Close connection to DUT
|
# Close connection to DUT
|
||||||
dut.serial.close()
|
dut.serial.close()
|
||||||
|
|
||||||
|
# Allow the OS to fully release the serial port. pytest-embedded's
|
||||||
|
# QueueFeederThread may still hold the port FD when close() returns.
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
|
script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
|
||||||
binary_path = ''
|
binary_path = ''
|
||||||
|
|
||||||
@@ -36,4 +42,20 @@ def test_otatool_example(dut: Dut) -> None:
|
|||||||
if 'otatool.bin' in flash_file[1]:
|
if 'otatool.bin' in flash_file[1]:
|
||||||
binary_path = flash_file[1]
|
binary_path = flash_file[1]
|
||||||
break
|
break
|
||||||
subprocess.check_call([sys.executable, script_path, '--binary', binary_path])
|
|
||||||
|
# Retry the subprocess to handle transient serial port contention.
|
||||||
|
# The otatool_example.py subprocess opens the serial port independently
|
||||||
|
# via esptool, and may fail if pytest-embedded's QueueFeederThread has
|
||||||
|
# not fully released the port file descriptor yet.
|
||||||
|
last_err = None
|
||||||
|
for attempt in range(3):
|
||||||
|
try:
|
||||||
|
subprocess.check_call([sys.executable, script_path, '--binary', binary_path])
|
||||||
|
return
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
last_err = e
|
||||||
|
logging.warning('otatool subprocess attempt %d/3 failed: %s', attempt + 1, e)
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
assert last_err is not None
|
||||||
|
raise last_err
|
||||||
|
|||||||
Reference in New Issue
Block a user