diff --git a/components/esp_timer/test_apps/main/CMakeLists.txt b/components/esp_timer/test_apps/main/CMakeLists.txt index 53c4d8eed69..2b3721d0163 100644 --- a/components/esp_timer/test_apps/main/CMakeLists.txt +++ b/components/esp_timer/test_apps/main/CMakeLists.txt @@ -23,3 +23,12 @@ idf_component_register(SRCS ${srcs} PRIV_INCLUDE_DIRS "../../private_include" "../include" PRIV_REQUIRES cmock test_utils esp_timer spi_flash esp_psram esp_driver_gpio esp_pm WHOLE_ARCHIVE) + +if(CONFIG_IDF_TARGET_LINUX AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + # Linux host heap integrity checks are stubs, so use ASan to catch dump overflows. + set(asan_options -fsanitize=address -fno-omit-frame-pointer) + idf_component_get_property(esp_timer_lib esp_timer COMPONENT_LIB) + target_compile_options(${esp_timer_lib} PRIVATE ${asan_options}) + target_compile_options(${COMPONENT_LIB} PRIVATE ${asan_options}) + idf_build_set_property(LINK_OPTIONS -fsanitize=address APPEND) +endif() diff --git a/components/esp_timer/test_apps/main/test_esp_timer.c b/components/esp_timer/test_apps/main/test_esp_timer.c index 6b670aeaf81..993273c9a06 100644 --- a/components/esp_timer/test_apps/main/test_esp_timer.c +++ b/components/esp_timer/test_apps/main/test_esp_timer.c @@ -6,6 +6,7 @@ #include "sdkconfig.h" #include #include +#include #include #include #include @@ -506,27 +507,6 @@ TEST_CASE("Can dump esp_timer stats", "[esp_timer]") overflow the internal string buffer if the length calculation is not correct. */ -#if CONFIG_IDF_TARGET_LINUX - const int NUM_TIMERS = 200; - esp_timer_handle_t timers[NUM_TIMERS]; - - for (int i = 0; i < NUM_TIMERS; ++i) { - char name[30]; - snprintf(name, sizeof(name), "test_timer_number_%d", i); - esp_timer_create_args_t timer_args = { - .callback = &empty_cb, - .arg = NULL, - .name = name - }; - TEST_ESP_OK(esp_timer_create(&timer_args, &timers[i])); - } - - esp_timer_dump(stdout); - - for (int i = 0; i < NUM_TIMERS; ++i) { - TEST_ESP_OK(esp_timer_delete(timers[i])); - } -#else enum { INACTIVE_TIMER_COUNT = 64, NUM_TIMERS = 256, @@ -566,7 +546,9 @@ TEST_CASE("Can dump esp_timer stats", "[esp_timer]") fclose(stream); TEST_ASSERT_NOT_NULL(strstr(dump_buf, "Timer stats:")); TEST_ASSERT_NOT_NULL(strstr(dump_buf, "72057594037927935")); +#if !CONFIG_IDF_TARGET_LINUX TEST_ASSERT_TRUE(heap_caps_check_integrity_all(true)); +#endif for (size_t i = 0; i < NUM_TIMERS; ++i) { TEST_ESP_OK(esp_timer_stop(timers[i])); @@ -576,7 +558,6 @@ TEST_CASE("Can dump esp_timer stats", "[esp_timer]") for (size_t i = 0; i < INACTIVE_TIMER_COUNT; ++i) { TEST_ESP_OK(esp_timer_delete(inactive_timers[i])); } -#endif } typedef struct {