Merge branch 'fix/twai_ci_job_pollution' into 'master'

fix(ci): twai test close board to fixed ci jobs pullotion

Closes IDFCI-4973

See merge request espressif/esp-idf!49894
This commit is contained in:
Wan Lei
2026-06-23 11:10:42 +08:00
5 changed files with 153 additions and 131 deletions
@@ -97,22 +97,24 @@ def fixture_create_socket_can() -> Bus:
'target', ['esp32', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32s2', 'esp32s3', 'esp32p4'], indirect=['target']
)
def test_legacy_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
esp_reset_and_wait_ready(dut)
try:
esp_reset_and_wait_ready(dut)
# TEST_CASE("twai_listen_only", "[twai]")
dut.write('"twai_listen_only"')
# TEST_CASE("twai_listen_only", "[twai]")
dut.write('"twai_listen_only"')
# wait the DUT to start listening
time.sleep(0.1)
# wait the DUT to start listening
time.sleep(0.1)
message = Message(
arbitration_id=0x123,
is_extended_id=False,
data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88],
)
socket_can.send(message, timeout=0.2)
dut.expect_unity_test_output()
esp_enter_flash_mode(dut)
message = Message(
arbitration_id=0x123,
is_extended_id=False,
data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88],
)
socket_can.send(message, timeout=0.2)
dut.expect_unity_test_output()
finally:
esp_enter_flash_mode(dut)
@pytest.mark.twai_adapter
@@ -127,30 +129,31 @@ def test_legacy_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
'target', ['esp32', 'esp32c3', 'esp32c6', 'esp32h2', 'esp32s2', 'esp32s3', 'esp32p4'], indirect=['target']
)
def test_legacy_twai_remote_request(dut: Dut, socket_can: Bus) -> None:
esp_reset_and_wait_ready(dut)
try:
esp_reset_and_wait_ready(dut)
# TEST_CASE("twai_remote_request", "[twai]")
dut.write('"twai_remote_request"')
# TEST_CASE("twai_remote_request", "[twai]")
dut.write('"twai_remote_request"')
deadline = time.time() + 2.0
req = None
while time.time() < deadline:
req = socket_can.recv(timeout=0.2)
if req is not None and req.is_remote_frame:
break
deadline = time.time() + 2.0
req = None
while time.time() < deadline:
req = socket_can.recv(timeout=0.2)
if req is not None and req.is_remote_frame:
break
if req is None:
raise Exception('Remote frame not received')
if req is None:
raise Exception('Remote frame not received')
logging.info(f'Received message: {req}')
logging.info(f'Received message: {req}')
reply = Message(
arbitration_id=req.arbitration_id,
is_extended_id=req.is_extended_id,
data=[0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80],
)
socket_can.send(reply, timeout=0.2)
print('send', reply)
reply = Message(
arbitration_id=req.arbitration_id,
is_extended_id=req.is_extended_id,
data=[0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80],
)
socket_can.send(reply, timeout=0.2)
print('send', reply)
dut.expect_unity_test_output()
esp_enter_flash_mode(dut)
dut.expect_unity_test_output()
finally:
esp_enter_flash_mode(dut)
@@ -84,20 +84,22 @@ def fixture_create_socket_can() -> Bus:
@idf_parametrize('target', soc_filtered_targets('SOC_TWAI_SUPPORTED == 1'), indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='no runner') # TODO: IDFCI-11110
def test_driver_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('"twai_listen_only"')
try:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('"twai_listen_only"')
# wait the DUT to finish initialize
time.sleep(0.1)
# wait the DUT to finish initialize
time.sleep(0.1)
message = Message(
arbitration_id=0x6688,
is_extended_id=True,
data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88],
)
print('USB Socket CAN Send:', message, 'Return:', socket_can.send(message))
dut.expect_unity_test_output(timeout=10)
esp_enter_flash_mode(dut)
message = Message(
arbitration_id=0x6688,
is_extended_id=True,
data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88],
)
print('USB Socket CAN Send:', message, 'Return:', socket_can.send(message))
dut.expect_unity_test_output(timeout=10)
finally:
esp_enter_flash_mode(dut)
@pytest.mark.twai_adapter
@@ -106,29 +108,30 @@ def test_driver_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
@idf_parametrize('target', soc_filtered_targets('SOC_TWAI_SUPPORTED == 1'), indirect=['target'])
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='no runner') # TODO: IDFCI-11110
def test_driver_twai_remote_request(dut: Dut, socket_can: Bus) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('"twai_remote_request"')
try:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('"twai_remote_request"')
print('Waiting remote frame ...')
deadline = time.time() + 5.0
req = None
while time.time() < deadline:
req = socket_can.recv(timeout=0.2)
if req is not None and req.is_remote_frame:
break
print('Waiting remote frame ...')
deadline = time.time() + 5.0
req = None
while time.time() < deadline:
req = socket_can.recv(timeout=0.2)
if req is not None and req.is_remote_frame:
break
if req is None:
raise Exception('Remote frame not received')
if req is None:
raise Exception('Remote frame not received')
print(f'USB Socket CAN Received: {req}')
print(f'USB Socket CAN Received: {req}')
reply = Message(
arbitration_id=req.arbitration_id,
is_extended_id=req.is_extended_id,
data=[0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10],
)
socket_can.send(reply, timeout=0.2)
print('USB Socket CAN Replied:', reply)
reply = Message(
arbitration_id=req.arbitration_id,
is_extended_id=req.is_extended_id,
data=[0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10],
)
socket_can.send(reply, timeout=0.2)
print('USB Socket CAN Replied:', reply)
dut.expect_unity_test_output(timeout=10)
esp_enter_flash_mode(dut)
dut.expect_unity_test_output(timeout=10)
finally:
esp_enter_flash_mode(dut)