Merge branch 'ci/fix_qemu_intr_tests' into 'master'

ci: fix flakey intr_dump tests in QEMU

Closes IDF-8899

See merge request espressif/esp-idf!27983
This commit is contained in:
Marius Vikhammer
2023-12-21 10:25:06 +08:00
4 changed files with 20 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ extern "C" {
#include "sdkconfig.h"
#include "esp_heap_caps.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
// Forward declaration. Definition in linenoise/linenoise.h.
typedef struct linenoiseCompletions linenoiseCompletions;
@@ -50,6 +51,7 @@ typedef struct {
const char *history_save_path; //!< file path used to save history commands, set to NULL won't save to file system
uint32_t task_stack_size; //!< repl task stack size
uint32_t task_priority; //!< repl task priority
BaseType_t task_core_id; //!< repl task affinity, i.e. which core the task is pinned to
const char *prompt; //!< prompt (NULL represents default: "esp> ")
size_t max_cmdline_length; //!< maximum length of a command line. If 0, default value will be used
} esp_console_repl_config_t;
@@ -64,6 +66,7 @@ typedef struct {
.history_save_path = NULL, \
.task_stack_size = 4096, \
.task_priority = 2, \
.task_core_id = tskNO_AFFINITY, \
.prompt = NULL, \
.max_cmdline_length = 0, \
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -107,8 +107,8 @@ esp_err_t esp_console_new_repl_usb_cdc(const esp_console_dev_usb_cdc_config_t *d
cdc_repl->repl_com.repl_core.del = esp_console_repl_usb_cdc_delete;
/* spawn a single thread to run REPL */
if (xTaskCreate(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
cdc_repl, repl_config->task_priority, &cdc_repl->repl_com.task_hdl) != pdTRUE) {
if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
cdc_repl, repl_config->task_priority, &cdc_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) {
ret = ESP_FAIL;
goto _exit;
}
@@ -184,8 +184,8 @@ esp_err_t esp_console_new_repl_usb_serial_jtag(const esp_console_dev_usb_serial_
usb_serial_jtag_repl->repl_com.repl_core.del = esp_console_repl_usb_serial_jtag_delete;
/* spawn a single thread to run REPL */
if (xTaskCreate(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
usb_serial_jtag_repl, repl_config->task_priority, &usb_serial_jtag_repl->repl_com.task_hdl) != pdTRUE) {
if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
usb_serial_jtag_repl, repl_config->task_priority, &usb_serial_jtag_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) {
ret = ESP_FAIL;
goto _exit;
}
@@ -286,8 +286,8 @@ esp_err_t esp_console_new_repl_uart(const esp_console_dev_uart_config_t *dev_con
/* Spawn a single thread to run REPL, we need to pass `uart_repl` to it as
* it also requires the uart channel. */
if (xTaskCreate(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
uart_repl, repl_config->task_priority, &uart_repl->repl_com.task_hdl) != pdTRUE) {
if (xTaskCreatePinnedToCore(esp_console_repl_task, "console_repl", repl_config->task_stack_size,
uart_repl, repl_config->task_priority, &uart_repl->repl_com.task_hdl, repl_config->task_core_id) != pdTRUE) {
ret = ESP_FAIL;
goto _exit;
}

View File

@@ -27,6 +27,10 @@ static void start_console(void)
{
esp_console_repl_t *repl = NULL;
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
/* Pin repl task to ensure all interrupts are allocated on the same core */
repl_config.task_core_id = 0;
/* Prompt to be printed before each line.
* This can be customized, made dynamic, etc.
*/
@@ -136,6 +140,9 @@ static int cmd_intr_alloc(int argc, char **argv)
printf("Failed to allocate interrupt (source: %d, flags: 0x%x): %s\n", source_num, flags, esp_err_to_name(ret));
return 1;
}
printf("Allocated %s %s\n", source_str, flags_str);
return 0;
}

View File

@@ -15,6 +15,7 @@ def test_esp_intr_dump_nonshared(dut: Dut) -> None:
dut.expect_exact(PROMPT, timeout=10)
dut.write('intr_alloc GPIO LEVEL3\n')
dut.expect_exact('Allocated GPIO LEVEL3')
dut.expect_exact(PROMPT)
dut.write('intr_dump\n')
@@ -27,6 +28,7 @@ def test_esp_intr_dump_shared(dut: Dut) -> None:
dut.expect_exact(PROMPT, timeout=10)
dut.write('intr_alloc GPIO SHARED\n')
dut.expect_exact('Allocated GPIO SHARED')
dut.expect_exact(PROMPT)
dut.write('intr_dump\n')
@@ -34,6 +36,7 @@ def test_esp_intr_dump_shared(dut: Dut) -> None:
dut.expect_exact(PROMPT)
dut.write('intr_alloc UART1 SHARED\n')
dut.expect_exact('Allocated UART1 SHARED')
dut.expect_exact(PROMPT)
dut.write('intr_dump\n')