mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
Merge branch 'bugfix/parttool-serial-handoff_v6.1' into 'release/v6.1'
fix(storage): stabilize parttool pytest serial handoff (v6.1) See merge request espressif/esp-idf!50912
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
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
@@ -19,12 +21,32 @@ def test_examples_parttool(dut: Dut) -> None:
|
||||
# Close connection to DUT
|
||||
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)
|
||||
|
||||
# Run the example python script
|
||||
idf_path = os.getenv('IDF_PATH')
|
||||
assert idf_path is not None
|
||||
script_path = os.path.join(idf_path, 'examples', 'storage', 'parttool', 'parttool_example.py')
|
||||
binary_path = os.path.join(dut.app.binary_path, 'parttool.bin')
|
||||
subprocess.check_call([sys.executable, script_path, '--binary', binary_path, '--port', dut.serial.port])
|
||||
|
||||
# Retry the subprocess to handle transient serial port contention.
|
||||
# parttool_example.py 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, '--port', dut.serial.port])
|
||||
break
|
||||
except subprocess.CalledProcessError as e:
|
||||
last_err = e
|
||||
logging.warning('parttool subprocess attempt %d/3 failed: %s', attempt + 1, e)
|
||||
time.sleep(3)
|
||||
else:
|
||||
assert last_err is not None
|
||||
raise last_err
|
||||
|
||||
# following tests check the external interface (parsing) of the parttool commands
|
||||
with open('custom.bin', 'wb') as f:
|
||||
|
||||
Reference in New Issue
Block a user