forked from espressif/esp-idf
Merge branch 'feature/app_trace_component_test_app' into 'master'
feat(app_trace): migrate the tests from unit-test-app Closes IDF-5564 See merge request espressif/esp-idf!26273
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
idf_component_register(SRC_DIRS "."
|
|
||||||
PRIV_INCLUDE_DIRS "."
|
|
||||||
PRIV_REQUIRES cmock driver)
|
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
9
components/app_trace/test_apps/.build-test-rules.yml
Normal file
9
components/app_trace/test_apps/.build-test-rules.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||||
|
|
||||||
|
components/app_trace/test_apps:
|
||||||
|
depends_components:
|
||||||
|
- app_trace
|
||||||
|
- esp_timer
|
||||||
|
- soc
|
||||||
|
- driver
|
||||||
|
- esp_hw_support
|
9
components/app_trace/test_apps/CMakeLists.txt
Normal file
9
components/app_trace/test_apps/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
set(COMPONENTS main)
|
||||||
|
list(PREPEND SDKCONFIG_DEFAULTS
|
||||||
|
"$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers"
|
||||||
|
"sdkconfig.defaults")
|
||||||
|
|
||||||
|
project(app_trace_test)
|
16
components/app_trace/test_apps/README.md
Normal file
16
components/app_trace/test_apps/README.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||||
|
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
|
# app_trace test
|
||||||
|
|
||||||
|
To build and run this test app for app_trace related tests:
|
||||||
|
```bash
|
||||||
|
IDF_TARGET=esp32 idf.py @app_trace build flash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
To build and run this test app for SystemView related tests:
|
||||||
|
```bash
|
||||||
|
IDF_TARGET=esp32 idf.py @sysview build flash monitor
|
||||||
|
```
|
||||||
|
|
||||||
|
`@app_trace` and `@sysview` arguments apply additional `idf.py` options, from [app_trace](app_trace) and [sysview](sysview) files.
|
1
components/app_trace/test_apps/app_trace
Normal file
1
components/app_trace/test_apps/app_trace
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.ci.app_trace" -B build/app_trace -DSDKCONFIG=build/app_trace/sdkconfig
|
4
components/app_trace/test_apps/main/CMakeLists.txt
Normal file
4
components/app_trace/test_apps/main/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
idf_component_register(SRCS "test_app_trace_main.c" "test_trace.c"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
PRIV_REQUIRES app_trace unity driver
|
||||||
|
WHOLE_ARCHIVE)
|
48
components/app_trace/test_apps/main/test_app_trace_main.c
Normal file
48
components/app_trace/test_apps/main/test_app_trace_main.c
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "unity.h"
|
||||||
|
#include "unity_test_runner.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
#define TEST_MEMORY_LEAK_THRESHOLD_DEFAULT 0
|
||||||
|
static int leak_threshold = TEST_MEMORY_LEAK_THRESHOLD_DEFAULT;
|
||||||
|
void set_leak_threshold(int threshold)
|
||||||
|
{
|
||||||
|
leak_threshold = threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t before_free_8bit;
|
||||||
|
static size_t before_free_32bit;
|
||||||
|
|
||||||
|
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||||
|
{
|
||||||
|
ssize_t delta = after_free - before_free;
|
||||||
|
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||||
|
TEST_ASSERT_MESSAGE(delta >= leak_threshold, "memory leak");
|
||||||
|
}
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
|
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||||
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
|
||||||
|
leak_threshold = TEST_MEMORY_LEAK_THRESHOLD_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
printf("Running app_trace component tests\n");
|
||||||
|
unity_run_menu();
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#if CONFIG_APPTRACE_ENABLE == 1
|
|
||||||
#include "esp_app_trace.h"
|
#include "esp_app_trace.h"
|
||||||
#include "esp_app_trace_util.h"
|
#include "esp_app_trace_util.h"
|
||||||
|
|
||||||
@@ -423,7 +423,6 @@ TEST_CASE("App trace test (1 task + 1 crashed timer ISR @ 1 core)", "[trace][ign
|
|||||||
esp_apptrace_test(&test_cfg);
|
esp_apptrace_test(&test_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("App trace test (1 crashed task)", "[trace][ignore]")
|
TEST_CASE("App trace test (1 crashed task)", "[trace][ignore]")
|
||||||
{
|
{
|
||||||
esp_apptrace_test_task_arg_t s_test_tasks[1];
|
esp_apptrace_test_task_arg_t s_test_tasks[1];
|
||||||
@@ -717,6 +716,7 @@ typedef struct {
|
|||||||
static bool esp_sysview_test_timer_isr(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
|
static bool esp_sysview_test_timer_isr(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx)
|
||||||
{
|
{
|
||||||
esp_sysviewtrace_timer_arg_t *tim_arg = (esp_sysviewtrace_timer_arg_t *)user_ctx;
|
esp_sysviewtrace_timer_arg_t *tim_arg = (esp_sysviewtrace_timer_arg_t *)user_ctx;
|
||||||
|
(void) tim_arg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -724,7 +724,7 @@ static void esp_sysviewtrace_test_task(void *p)
|
|||||||
{
|
{
|
||||||
esp_sysviewtrace_task_arg_t *arg = (esp_sysviewtrace_task_arg_t *) p;
|
esp_sysviewtrace_task_arg_t *arg = (esp_sysviewtrace_task_arg_t *) p;
|
||||||
volatile uint32_t tmp = 0;
|
volatile uint32_t tmp = 0;
|
||||||
printf("%x: run sysview task\n", (uint32_t)xTaskGetCurrentTaskHandle());
|
printf("%p: run sysview task\n", xTaskGetCurrentTaskHandle());
|
||||||
|
|
||||||
if (arg->timer) {
|
if (arg->timer) {
|
||||||
gptimer_alarm_config_t alarm_config = {
|
gptimer_alarm_config_t alarm_config = {
|
||||||
@@ -744,7 +744,7 @@ static void esp_sysviewtrace_test_task(void *p)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
static uint32_t count;
|
static uint32_t count;
|
||||||
printf("%d", arg->id);
|
printf("%" PRIu32, arg->id);
|
||||||
if ((++count % 80) == 0) {
|
if ((++count % 80) == 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
@@ -890,22 +890,22 @@ TEST_CASE("SysView trace test 2", "[trace][ignore]")
|
|||||||
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg2.gptimer));
|
TEST_ESP_OK(gptimer_new_timer(&timer_config, &tim_arg2.gptimer));
|
||||||
|
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace0", 2048, &arg1, 3, &thnd, 0);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace0", 2048, &arg1, 3, &thnd, 0);
|
||||||
printf("Created task %x\n", (uint32_t)thnd);
|
printf("Created task %p\n", thnd);
|
||||||
#if CONFIG_FREERTOS_UNICORE == 0
|
#if CONFIG_FREERTOS_UNICORE == 0
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 1);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 1);
|
||||||
#else
|
#else
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 0);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svtrace1", 2048, &arg2, 4, &thnd, 0);
|
||||||
#endif
|
#endif
|
||||||
printf("Created task %x\n", (uint32_t)thnd);
|
printf("Created task %p\n", thnd);
|
||||||
|
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync0", 2048, &arg3, 3, &thnd, 0);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync0", 2048, &arg3, 3, &thnd, 0);
|
||||||
printf("Created task %x\n", (uint32_t)thnd);
|
printf("Created task %p\n", thnd);
|
||||||
#if CONFIG_FREERTOS_UNICORE == 0
|
#if CONFIG_FREERTOS_UNICORE == 0
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 1);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 1);
|
||||||
#else
|
#else
|
||||||
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 0);
|
xTaskCreatePinnedToCore(esp_sysviewtrace_test_task, "svsync1", 2048, &arg4, 5, &thnd, 0);
|
||||||
#endif
|
#endif
|
||||||
printf("Created task %x\n", (uint32_t)thnd);
|
printf("Created task %p\n", thnd);
|
||||||
|
|
||||||
xSemaphoreTake(arg1.done, portMAX_DELAY);
|
xSemaphoreTake(arg1.done, portMAX_DELAY);
|
||||||
vSemaphoreDelete(arg1.done);
|
vSemaphoreDelete(arg1.done);
|
||||||
@@ -924,4 +924,3 @@ TEST_CASE("SysView trace test 2", "[trace][ignore]")
|
|||||||
TEST_ESP_OK(gptimer_del_timer(tim_arg2.gptimer));
|
TEST_ESP_OK(gptimer_del_timer(tim_arg2.gptimer));
|
||||||
}
|
}
|
||||||
#endif // #if CONFIG_APPTRACE_SV_ENABLE == 0
|
#endif // #if CONFIG_APPTRACE_SV_ENABLE == 0
|
||||||
#endif // #if CONFIG_APPTRACE_ENABLE == 1
|
|
1
components/app_trace/test_apps/sdkconfig.ci.app_trace
Normal file
1
components/app_trace/test_apps/sdkconfig.ci.app_trace
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# app_trace is already enabled by sdkconfig.defaults, so no options are needed here
|
1
components/app_trace/test_apps/sdkconfig.ci.sysview
Normal file
1
components/app_trace/test_apps/sdkconfig.ci.sysview
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_APPTRACE_SV_ENABLE=y
|
2
components/app_trace/test_apps/sdkconfig.defaults
Normal file
2
components/app_trace/test_apps/sdkconfig.defaults
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
|
||||||
|
CONFIG_APPTRACE_DEST_JTAG=y
|
1
components/app_trace/test_apps/sysview
Normal file
1
components/app_trace/test_apps/sysview
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.ci.sysview" -B build/sysview -DSDKCONFIG=build/sysview/sdkconfig
|
Reference in New Issue
Block a user