mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(esp_vfs_console): Update placement of cdcacm_xx_cb when ETS print enabled
This commit is contained in:
@@ -7,3 +7,17 @@ set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(usb_cdc_vfs_test)
|
||||
|
||||
idf_build_get_property(elf EXECUTABLE)
|
||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--elf-file ${CMAKE_BINARY_DIR}/*.elf
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
||||
--to-sections=.flash.text,.flash.rodata
|
||||
--exit-code
|
||||
DEPENDS ${elf}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/errno.h>
|
||||
#include "unity.h"
|
||||
#include "unity_test_utils_cache.h"
|
||||
#include "esp_private/usb_console.h"
|
||||
#include "esp_vfs_cdcacm.h"
|
||||
#include "esp_rom_sys.h"
|
||||
|
||||
static void flush_write(void)
|
||||
{
|
||||
@@ -263,6 +265,39 @@ static void test_usb_cdc_read_no_exit_on_newline_reception(void)
|
||||
vTaskDelay(2); // wait for tasks to exit
|
||||
}
|
||||
|
||||
static void IRAM_ATTR test_input_output_post_cache_disable(void *args)
|
||||
{
|
||||
static DRAM_ATTR const char test_msg[] = "test_message\n";
|
||||
esp_rom_printf(test_msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test that the tx and rx cb are placed in IRAM correctly
|
||||
*/
|
||||
static void test_usb_cdc_ets_printf_cache_disabled(void)
|
||||
{
|
||||
test_setup(__func__, sizeof(__func__));
|
||||
|
||||
/* make sure blocking mode is enabled */
|
||||
int flags = fcntl(STDIN_FILENO, F_GETFL, 0);
|
||||
fcntl(STDIN_FILENO, F_SETFL, flags & (~O_NONBLOCK));
|
||||
|
||||
#if CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF
|
||||
unity_utils_run_cache_disable_stub(test_input_output_post_cache_disable, NULL);
|
||||
#else
|
||||
#error This test must run with CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF enabled
|
||||
#endif
|
||||
|
||||
// send message to the test environment to report successful test
|
||||
char ready_msg[] = "successful test\n";
|
||||
write(fileno(stdout), ready_msg, sizeof(ready_msg));
|
||||
|
||||
fcntl(STDIN_FILENO, F_SETFL, flags);
|
||||
esp_vfs_dev_cdcacm_set_rx_line_endings(ESP_LINE_ENDINGS_CRLF);
|
||||
esp_vfs_dev_cdcacm_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
|
||||
vTaskDelay(2); // wait for tasks to exit
|
||||
}
|
||||
|
||||
/* Always make sure that the function calling sequence in the main
|
||||
* function matches the expected order in the pytest function.
|
||||
*/
|
||||
@@ -272,4 +307,5 @@ void app_main(void)
|
||||
test_usb_cdc_read_non_blocking();
|
||||
test_usb_cdc_read_blocking();
|
||||
test_usb_cdc_read_no_exit_on_newline_reception();
|
||||
test_usb_cdc_ets_printf_cache_disabled();
|
||||
}
|
||||
|
||||
@@ -37,3 +37,8 @@ def test_usb_cdc_vfs_default(dut: Dut) -> None:
|
||||
dut.expect_exact('test_usb_cdc_read_no_exit_on_newline_reception', timeout=2)
|
||||
dut.expect_exact('ready to receive', timeout=2)
|
||||
dut.write('!(@*#&(!*@&#((SDasdkjhad\nce')
|
||||
|
||||
# test run: test_usb_cdc_ets_printf_cache_disabled
|
||||
dut.expect_exact('test_usb_cdc_ets_printf_cache_disabled', timeout=2)
|
||||
dut.expect_exact('test_message', timeout=2)
|
||||
dut.expect_exact('successful test', timeout=2)
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
# Enable Unity fixture support
|
||||
CONFIG_UNITY_ENABLE_FIXTURE=n
|
||||
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
|
||||
CONFIG_COMPILER_DUMP_RTL_FILES=y
|
||||
|
||||
# Custom partition table for this test app
|
||||
CONFIG_ESP_TASK_WDT_INIT=n
|
||||
|
||||
CONFIG_ESP_CONSOLE_USB_CDC=y
|
||||
|
||||
# one test requires this option to be enabled
|
||||
CONFIG_ESP_CONSOLE_USB_CDC_SUPPORT_ETS_PRINTF=y
|
||||
|
||||
Reference in New Issue
Block a user