fix(twai): enable twai interactive test for all targets on new std runner

This commit is contained in:
wanlei 2023-12-26 10:38:06 +08:00
parent 22f2ecc400
commit 8536ffb490
5 changed files with 76 additions and 8 deletions

View File

@ -926,6 +926,60 @@ pytest_components_esp32_psramv0:
artifacts: false artifacts: false
tags: [ esp32, psramv0 ] tags: [ esp32, psramv0 ]
pytest_components_esp32_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32
needs:
- job: build_pytest_components_esp32
artifacts: false
tags: [ esp32, twai_std ]
pytest_components_esp32s2_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32s2
needs:
- job: build_pytest_components_esp32s2
artifacts: false
tags: [ esp32s2, twai_std ]
pytest_components_esp32s3_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32s3
needs:
- job: build_pytest_components_esp32s3
artifacts: false
tags: [ esp32s3, twai_std ]
pytest_components_esp32c3_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32c3
needs:
- job: build_pytest_components_esp32c3
artifacts: false
tags: [ esp32c3, twai_std ]
pytest_components_esp32c6_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32c6
needs:
- job: build_pytest_components_esp32c6
artifacts: false
tags: [ esp32c6, twai_std ]
pytest_components_esp32h2_twai_std:
extends:
- .pytest_components_dir_template
- .rules:test:component_ut-esp32h2
needs:
- job: build_pytest_components_esp32h2
artifacts: false
tags: [ esp32h2, twai_std ]
pytest_components_esp32s2_generic: pytest_components_esp32s2_generic:
extends: extends:
- .pytest_components_dir_template - .pytest_components_dir_template

View File

@ -93,6 +93,10 @@ components/driver/test_apps/twai:
- if: IDF_TARGET == "esp32p4" - if: IDF_TARGET == "esp32p4"
temporary: true temporary: true
reason: test not pass, should be re-enable # TODO: IDF-8966 reason: test not pass, should be re-enable # TODO: IDF-8966
depends_filepatterns:
- components/driver/twai/**/*
depends_components:
- esp_driver_gpio
components/driver/test_apps/usb_serial_jtag: components/driver/test_apps/usb_serial_jtag:
disable: disable:

View File

@ -27,7 +27,7 @@ TEST_CASE("twai_listen_only", "[twai]")
{ {
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 2, TWAI_MODE_LISTEN_ONLY); twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_LISTEN_ONLY);
#if CONFIG_TWAI_ISR_IN_IRAM #if CONFIG_TWAI_ISR_IN_IRAM
g_config.intr_flags |= ESP_INTR_FLAG_IRAM; g_config.intr_flags |= ESP_INTR_FLAG_IRAM;
#endif #endif
@ -60,8 +60,10 @@ TEST_CASE("twai_remote_request", "[twai]")
twai_handle_t bus_handle; twai_handle_t bus_handle;
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 2, TWAI_MODE_NORMAL); twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(4, 5, TWAI_MODE_NORMAL);
g_config.controller_id = 2; #if CONFIG_IDF_TARGET_ESP32C6
g_config.controller_id = 1;
#endif
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle)); TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle));
TEST_ESP_OK(twai_start_v2(bus_handle)); TEST_ESP_OK(twai_start_v2(bus_handle));

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
import logging import logging
import subprocess
from time import sleep from time import sleep
import pytest import pytest
@ -29,10 +30,14 @@ def test_twai_self(dut: Dut) -> None:
@pytest.fixture(name='socket_can', scope='module') @pytest.fixture(name='socket_can', scope='module')
def fixture_create_socket_can() -> Bus: def fixture_create_socket_can() -> Bus:
# See README.md for instructions on how to set up the socket CAN with the bitrate # Set up the socket CAN with the bitrate
start_command = 'sudo ip link set can0 up type can bitrate 250000 restart-ms 100'
stop_command = 'sudo ip link set can0 down'
subprocess.run(start_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
bus = Bus(interface='socketcan', channel='can0', bitrate=250000) bus = Bus(interface='socketcan', channel='can0', bitrate=250000)
yield bus yield bus # test invoked here
bus.shutdown() bus.shutdown()
subprocess.run(stop_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
@pytest.mark.esp32 @pytest.mark.esp32
@ -41,7 +46,7 @@ def fixture_create_socket_can() -> Bus:
@pytest.mark.esp32h2 @pytest.mark.esp32h2
@pytest.mark.esp32s2 @pytest.mark.esp32s2
@pytest.mark.esp32s3 @pytest.mark.esp32s3
@pytest.mark.skip(reason='Runner not set up yet') @pytest.mark.twai_std
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', 'config',
[ [
@ -50,6 +55,7 @@ def fixture_create_socket_can() -> Bus:
indirect=True, indirect=True,
) )
def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None: def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
dut.serial.hard_reset()
dut.expect_exact('Press ENTER to see the list of tests') dut.expect_exact('Press ENTER to see the list of tests')
# TEST_CASE("twai_listen_only", "[twai]") # TEST_CASE("twai_listen_only", "[twai]")
@ -73,7 +79,7 @@ def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
@pytest.mark.esp32h2 @pytest.mark.esp32h2
@pytest.mark.esp32s2 @pytest.mark.esp32s2
@pytest.mark.esp32s3 @pytest.mark.esp32s3
@pytest.mark.skip(reason='Runner not set up yet') @pytest.mark.twai_std
@pytest.mark.parametrize( @pytest.mark.parametrize(
'config', 'config',
[ [
@ -82,6 +88,7 @@ def test_twai_listen_only(dut: Dut, socket_can: Bus) -> None:
indirect=True, indirect=True,
) )
def test_twai_remote_request(dut: Dut, socket_can: Bus) -> None: def test_twai_remote_request(dut: Dut, socket_can: Bus) -> None:
dut.serial.hard_reset()
dut.expect_exact('Press ENTER to see the list of tests') dut.expect_exact('Press ENTER to see the list of tests')
# TEST_CASE("twai_remote_request", "[twai]") # TEST_CASE("twai_remote_request", "[twai]")

View File

@ -108,7 +108,8 @@ ENV_MARKERS = {
'twai_network': 'multiple runners form a TWAI network.', 'twai_network': 'multiple runners form a TWAI network.',
'sdio_master_slave': 'Test sdio multi board, esp32+esp32', 'sdio_master_slave': 'Test sdio multi board, esp32+esp32',
'sdio_multidev_32_c6': 'Test sdio multi board, esp32+esp32c6', 'sdio_multidev_32_c6': 'Test sdio multi board, esp32+esp32c6',
'usj_device': 'Test usb_serial_jtag and usb_serial_jtag is used as serial only (not console)' 'usj_device': 'Test usb_serial_jtag and usb_serial_jtag is used as serial only (not console)',
'twai_std': 'twai runner with all twai supported targets connect to usb-can adapter'
} }