heap/test_leak: changed requested memory on leak checks to match the threshold

This commit is contained in:
Felipe Neves 2019-11-11 11:34:37 +08:00
parent c0d12988d3
commit cf95ea40d4
4 changed files with 13 additions and 9 deletions

View File

@ -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);

View File

@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/param.h>
TEST_CASE_ESP32("Capabilities allocator test", "[heap]")
TEST_CASE("Capabilities allocator test", "[heap]")
{
char *m1, *m2[10];
int x;

View File

@ -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];

View File

@ -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;
}