This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nuttx-ntfc.git
commit 9d6214868d3f079a3a35106b41e2232b59827576 Author: raiden00pl <[email protected]> AuthorDate: Tue Nov 10 13:12:37 2026 +0100 tests/device: fix flaky serial soft reboot test Give the soft reboot boot wait time to retry, and always stop the fake device thread so a failure cannot hang the test run. Signed-off-by: raiden00pl <[email protected]> --- tests/device/test_serial.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/device/test_serial.py b/tests/device/test_serial.py index 11f577f..15b8894 100644 --- a/tests/device/test_serial.py +++ b/tests/device/test_serial.py @@ -137,9 +137,17 @@ def test_device_sim_init(serial_config, serial_pair): stop = threading.Event() device_thread = threading.Thread( - target=fake_device_thread, args=(serial_pair[0], stop) + target=fake_device_thread, args=(serial_pair[0], stop), daemon=True ) device_thread.start() + try: + _sim_init_running(ser) + finally: + stop.set() + device_thread.join(timeout=1) + + +def _sim_init_running(ser): global g_fake_device_retval g_fake_device_retval = b"\n\rnsh>" @@ -156,14 +164,11 @@ def test_device_sim_init(serial_config, serial_pair): # soft reboot: device must respond with prompt for boot wait to succeed g_fake_device_retval = b"\n\rnsh>" - assert ser.reboot(hard=False) is True + assert ser.reboot(timeout=5, hard=False) is True # soft poweroff: sends OS command, no boot wait required assert ser.poweroff(hard=False) is True - stop.set() - device_thread.join(timeout=1) - def test_device_serial_boot_timeout(serial_pair, monkeypatch):
