From cf95ea40d48197ed9c738b98a1a86c2ed6d4e338 Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Mon, 11 Nov 2019 11:34:37 +0800 Subject: [PATCH] heap/test_leak: changed requested memory on leak checks to match the threshold --- components/heap/test/test_leak.c | 14 +++++++------- components/heap/test/test_malloc_caps.c | 2 +- components/heap/test/test_realloc.c | 2 +- .../components/test_utils/test_runner.c | 4 ++++ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/heap/test/test_leak.c b/components/heap/test/test_leak.c index 1153fe1bc..0144cd937 100644 --- a/components/heap/test/test_leak.c +++ b/components/heap/test/test_leak.c @@ -18,18 +18,18 @@ static char* check_calloc(int size) TEST_CASE("Check for leaks (no leak)", "[heap]") { - char *arr = check_calloc(7000); + char *arr = check_calloc(1000); free(arr); } TEST_CASE("Check for leaks (leak)", "[heap][ignore]") { - check_calloc(7000); + check_calloc(1000); } TEST_CASE("Not check for leaks", "[heap][leaks]") { - check_calloc(7000); + check_calloc(1000); } TEST_CASE("Set a leak level = 7016", "[heap][leaks=7016]") @@ -39,7 +39,7 @@ TEST_CASE("Set a leak level = 7016", "[heap][leaks=7016]") static void test_fn(void) { - check_calloc(7000); + check_calloc(1000); } TEST_CASE_MULTIPLE_STAGES("Not check for leaks in MULTIPLE_STAGES mode", "[heap][leaks]", test_fn, test_fn, test_fn); @@ -48,13 +48,13 @@ TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (leak)", "[he static void test_fn2(void) { - check_calloc(7000); + check_calloc(1000); esp_restart(); } static void test_fn3(void) { - check_calloc(7000); + check_calloc(1000); } -TEST_CASE_MULTIPLE_STAGES_ESP32("Check for leaks in MULTIPLE_STAGES mode (manual reset)", "[heap][leaks][reset=SW_CPU_RESET, SW_CPU_RESET]", test_fn2, test_fn2, test_fn3); +TEST_CASE_MULTIPLE_STAGES("Check for leaks in MULTIPLE_STAGES mode (manual reset)", "[heap][leaks][reset=SW_CPU_RESET, SW_CPU_RESET]", test_fn2, test_fn2, test_fn3); diff --git a/components/heap/test/test_malloc_caps.c b/components/heap/test/test_malloc_caps.c index 9fdbec571..74c808477 100644 --- a/components/heap/test/test_malloc_caps.c +++ b/components/heap/test/test_malloc_caps.c @@ -11,7 +11,7 @@ #include #include -TEST_CASE_ESP32("Capabilities allocator test", "[heap]") +TEST_CASE("Capabilities allocator test", "[heap]") { char *m1, *m2[10]; int x; diff --git a/components/heap/test/test_realloc.c b/components/heap/test/test_realloc.c index 6781c2af3..290ee3da6 100644 --- a/components/heap/test/test_realloc.c +++ b/components/heap/test/test_realloc.c @@ -22,7 +22,7 @@ TEST_CASE("realloc shrink buffer in place", "[heap]") #endif -TEST_CASE_ESP32("realloc move data to a new heap type", "[heap]") +TEST_CASE("realloc move data to a new heap type", "[heap]") { const char *test = "I am some test content to put in the heap"; char buf[64]; diff --git a/tools/unit-test-app/components/test_utils/test_runner.c b/tools/unit-test-app/components/test_utils/test_runner.c index fc09d5a45..d6cdef9f4 100644 --- a/tools/unit-test-app/components/test_utils/test_runner.c +++ b/tools/unit-test-app/components/test_utils/test_runner.c @@ -87,6 +87,10 @@ void setUp(void) static void check_leak(size_t before_free, size_t after_free, const char *type) { + printf("MALLOC_CAP_%s leak: Leak threshold is: %u \n", + type, + critical_leak_threshold); + if (before_free <= after_free) { return; }