fix(ci): twai test disable board after test finish

This commit is contained in:
wanckl
2026-06-24 19:27:55 +08:00
parent 266b7697e8
commit 0b01a18fc9
2 changed files with 34 additions and 4 deletions

View File

@@ -1,12 +1,27 @@
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import time
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
def esp_enter_flash_mode(dut: Dut) -> None:
ser = dut.serial.proc
ser.setRTS(True) # EN Low
time.sleep(0.5)
ser.setDTR(True) # GPIO0 Low
ser.setRTS(False) # EN High
dut.expect('waiting for download', timeout=2)
ser.setDTR(False) # Back RTS/DTR to 1/1 to avoid affect to esptool
@pytest.mark.twai_adapter
@idf_parametrize('target', ['esp32'], indirect=['target'])
def test_twai_alert_recovery_example(dut: Dut) -> None:
dut.expect_exact('TWAI Alert and Recovery: Driver installed')
dut.expect_exact('TWAI Alert and Recovery: Driver uninstalled')
try:
dut.expect_exact('TWAI Alert and Recovery: Driver installed')
dut.expect_exact('TWAI Alert and Recovery: Driver uninstalled')
finally:
esp_enter_flash_mode(dut)

View File

@@ -1,12 +1,27 @@
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import time
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
def esp_enter_flash_mode(dut: Dut) -> None:
ser = dut.serial.proc
ser.setRTS(True) # EN Low
time.sleep(0.5)
ser.setDTR(True) # GPIO0 Low
ser.setRTS(False) # EN High
dut.expect('waiting for download', timeout=2)
ser.setDTR(False) # Back RTS/DTR to 1/1 to avoid affect to esptool
@pytest.mark.twai_adapter
@idf_parametrize('target', ['esp32'], indirect=['target'])
def test_twai_self_test_example(dut: Dut) -> None:
dut.expect_exact('TWAI Self Test: Driver installed')
dut.expect_exact('TWAI Self Test: Driver uninstalled')
try:
dut.expect_exact('TWAI Self Test: Driver installed')
dut.expect_exact('TWAI Self Test: Driver uninstalled')
finally:
esp_enter_flash_mode(dut)