mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
104 lines
2.8 KiB
C
104 lines
2.8 KiB
C
|
/*
|
||
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||
|
*
|
||
|
* SPDX-License-Identifier: Apache-2.0
|
||
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <unistd.h>
|
||
|
#include <assert.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
#include "esp_err.h"
|
||
|
#include "esp_system.h"
|
||
|
|
||
|
#include "freertos/FreeRTOS.h"
|
||
|
#include "freertos/task.h"
|
||
|
|
||
|
#include "test_panic.h"
|
||
|
|
||
|
/* Test Utility Functions */
|
||
|
|
||
|
#define BOOT_CMD_MAX_LEN (128)
|
||
|
|
||
|
#define HANDLE_TEST(test_name, name_) \
|
||
|
if (strcmp(test_name, #name_) == 0) { \
|
||
|
name_(); \
|
||
|
die("Test function has returned"); \
|
||
|
}
|
||
|
|
||
|
static const char* get_test_name(void)
|
||
|
{
|
||
|
static char test_name_str[BOOT_CMD_MAX_LEN] = {0};
|
||
|
|
||
|
printf("Enter test name: ");
|
||
|
fflush(stdout);
|
||
|
|
||
|
/* Not using blocking fgets(stdin) here, as QEMU doesn't yet implement RX timeout interrupt,
|
||
|
* which is required for the UART driver and blocking stdio to work.
|
||
|
*/
|
||
|
int c = EOF;
|
||
|
char *p = test_name_str;
|
||
|
const char *end = test_name_str + sizeof(test_name_str) - 1;
|
||
|
while (p < end) {
|
||
|
c = getchar();
|
||
|
if (c == EOF) {
|
||
|
vTaskDelay(pdMS_TO_TICKS(10));
|
||
|
} else if ((c == '\r' || c == '\n') && p != test_name_str) {
|
||
|
/* terminate the line */
|
||
|
puts("\n\r");
|
||
|
fflush(stdout);
|
||
|
*p = '\0';
|
||
|
break;
|
||
|
} else {
|
||
|
/* echo the received character */
|
||
|
putchar(c);
|
||
|
fflush(stdout);
|
||
|
/* and save it */
|
||
|
*p = c;
|
||
|
++p;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return test_name_str;
|
||
|
}
|
||
|
|
||
|
/* app_main */
|
||
|
|
||
|
void app_main(void)
|
||
|
{
|
||
|
/* Needed to allow the tick hook to set correct INT WDT timeouts */
|
||
|
vTaskDelay(2);
|
||
|
|
||
|
/* Test script sends to command over UART. Read it and determine how to proceed. */
|
||
|
const char* test_name = get_test_name();
|
||
|
if (test_name == NULL) {
|
||
|
/* Nothing to do */
|
||
|
return;
|
||
|
}
|
||
|
printf("Got test name: %s\n", test_name);
|
||
|
|
||
|
HANDLE_TEST(test_name, test_abort);
|
||
|
HANDLE_TEST(test_name, test_abort_cache_disabled);
|
||
|
HANDLE_TEST(test_name, test_int_wdt);
|
||
|
HANDLE_TEST(test_name, test_task_wdt_cpu0);
|
||
|
#if CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||
|
HANDLE_TEST(test_name, test_panic_extram_stack);
|
||
|
#endif
|
||
|
#if !CONFIG_FREERTOS_UNICORE
|
||
|
HANDLE_TEST(test_name, test_task_wdt_cpu1);
|
||
|
HANDLE_TEST(test_name, test_task_wdt_both_cpus);
|
||
|
#endif
|
||
|
HANDLE_TEST(test_name, test_storeprohibited);
|
||
|
HANDLE_TEST(test_name, test_cache_error);
|
||
|
HANDLE_TEST(test_name, test_int_wdt_cache_disabled);
|
||
|
HANDLE_TEST(test_name, test_stack_overflow);
|
||
|
HANDLE_TEST(test_name, test_illegal_instruction);
|
||
|
HANDLE_TEST(test_name, test_instr_fetch_prohibited);
|
||
|
HANDLE_TEST(test_name, test_ub);
|
||
|
HANDLE_TEST(test_name, test_assert);
|
||
|
HANDLE_TEST(test_name, test_assert_cache_disabled);
|
||
|
|
||
|
die("Unknown test name");
|
||
|
}
|