mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ci(console): improve esp-system console test-coverage
This commit is contained in:
parent
53e3833f44
commit
aa6a7bec76
@ -1,6 +1,5 @@
|
|||||||
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded import Dut
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
@ -13,7 +12,7 @@ from pytest_embedded import Dut
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'port, config',
|
'port, config',
|
||||||
[
|
[
|
||||||
('/dev/ttyACM0', 'release'),
|
pytest.param('/dev/serial_ports/ttyACM-esp32', 'release'),
|
||||||
],
|
],
|
||||||
indirect=True,
|
indirect=True,
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/esp_system/test_apps/console:
|
||||||
|
disable:
|
||||||
|
- if: CONFIG_NAME == "serial_jtag_only" and SOC_USB_SERIAL_JTAG_SUPPORTED != 1
|
||||||
|
|
||||||
components/esp_system/test_apps/esp_system_unity_tests:
|
components/esp_system/test_apps/esp_system_unity_tests:
|
||||||
disable:
|
disable:
|
||||||
- if: CONFIG_NAME == "psram" and SOC_SPIRAM_SUPPORTED != 1
|
- if: CONFIG_NAME == "psram" and SOC_SPIRAM_SUPPORTED != 1
|
||||||
|
12
components/esp_system/test_apps/console/CMakeLists.txt
Normal file
12
components/esp_system/test_apps/console/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# The following lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
|
list(PREPEND SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers")
|
||||||
|
|
||||||
|
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||||
|
set(COMPONENTS main)
|
||||||
|
|
||||||
|
project(test_esp_system_console_tests)
|
2
components/esp_system/test_apps/console/README.md
Normal file
2
components/esp_system/test_apps/console/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "test_app_main.c"
|
||||||
|
REQUIRES vfs esp_driver_uart
|
||||||
|
WHOLE_ARCHIVE)
|
55
components/esp_system/test_apps/console/main/test_app_main.c
Normal file
55
components/esp_system/test_apps/console/main/test_app_main.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#include "esp_rom_uart.h"
|
||||||
|
#include "esp_rom_sys.h"
|
||||||
|
|
||||||
|
#include "hal/uart_ll.h"
|
||||||
|
#include "esp_private/uart_share_hw_ctrl.h"
|
||||||
|
|
||||||
|
#include "driver/uart.h"
|
||||||
|
#include "soc/uart_channel.h"
|
||||||
|
|
||||||
|
#if CONFIG_ESP_CONSOLE_NONE
|
||||||
|
/* Set up UART on UART_0 (console) to be able to
|
||||||
|
notify pytest test case that app booted successfully
|
||||||
|
*/
|
||||||
|
#define CONSOLE_UART_NUM 0
|
||||||
|
|
||||||
|
static void console_none_print(void)
|
||||||
|
{
|
||||||
|
/* Configure parameters of an UART driver,
|
||||||
|
* communication pins and install the driver */
|
||||||
|
uart_config_t uart_config = {
|
||||||
|
.baud_rate = CONFIG_ESPTOOLPY_MONITOR_BAUD,
|
||||||
|
.data_bits = UART_DATA_8_BITS,
|
||||||
|
.parity = UART_PARITY_DISABLE,
|
||||||
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||||
|
.source_clk = UART_SCLK_DEFAULT,
|
||||||
|
};
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(uart_driver_install(CONSOLE_UART_NUM, 256, 0, 0, NULL, 0));
|
||||||
|
ESP_ERROR_CHECK(uart_param_config(CONSOLE_UART_NUM, &uart_config));
|
||||||
|
ESP_ERROR_CHECK(uart_set_pin(CONSOLE_UART_NUM, UART_NUM_0_TXD_DIRECT_GPIO_NUM, UART_NUM_0_RXD_DIRECT_GPIO_NUM, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
|
||||||
|
|
||||||
|
// Configure a temporary buffer for the incoming data
|
||||||
|
uint8_t data[] = "This message will be printed even with CONFIG_ESP_CONSOLE_NONE\r\n";
|
||||||
|
|
||||||
|
uart_write_bytes(CONSOLE_UART_NUM, data, sizeof(data));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
printf("Hello World\n");
|
||||||
|
|
||||||
|
#if CONFIG_ESP_CONSOLE_NONE
|
||||||
|
console_none_print();
|
||||||
|
#endif // CONFIG_ESP_CONSOLE_NONE
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
import pexpect
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded import Dut
|
||||||
|
|
||||||
|
|
||||||
|
def not_expect(dut: Dut, output_regex: str) -> None:
|
||||||
|
try:
|
||||||
|
dut.expect(output_regex, timeout=5)
|
||||||
|
except pexpect.TIMEOUT:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f'Found not_expect output {output_regex}')
|
||||||
|
|
||||||
|
|
||||||
|
JTAG_SERIAL_MARKS = [
|
||||||
|
pytest.mark.esp32s3,
|
||||||
|
pytest.mark.esp32c2,
|
||||||
|
pytest.mark.esp32c3,
|
||||||
|
pytest.mark.esp32c6,
|
||||||
|
pytest.mark.esp32h2,
|
||||||
|
pytest.mark.esp32p4,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.generic
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'config',
|
||||||
|
[
|
||||||
|
pytest.param('console_none', marks=pytest.mark.supported_targets),
|
||||||
|
],
|
||||||
|
indirect=True
|
||||||
|
)
|
||||||
|
def test_esp_system_console_no_output_uart(dut: Dut) -> None:
|
||||||
|
not_expect(dut, r'2nd stage bootloader|Hello World')
|
||||||
|
dut.expect('This message will be printed even with CONFIG_ESP_CONSOLE_NONE')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usb_serial_jtag
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'port, config',
|
||||||
|
[
|
||||||
|
pytest.param('/dev/serial_ports/ttyACM-esp32', 'serial_jtag_only', marks=JTAG_SERIAL_MARKS),
|
||||||
|
],
|
||||||
|
indirect=True,
|
||||||
|
)
|
||||||
|
def test_esp_system_console_only_serial_jtag(dut: Dut) -> None:
|
||||||
|
dut.expect('2nd stage bootloader')
|
||||||
|
dut.expect('Hello World')
|
@ -0,0 +1 @@
|
|||||||
|
CONFIG_ESP_CONSOLE_NONE=y
|
@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
|
||||||
|
# Disabled due to semihosting issue IDF-9574
|
||||||
|
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=n
|
Loading…
Reference in New Issue
Block a user