2019-04-12 01:31:23 +00:00
/*
Tests for a leak tag
*/
# include <stdio.h>
# include "unity.h"
# include "esp_heap_caps_init.h"
# include "esp_system.h"
# include <stdlib.h>
static char * check_calloc ( int size )
{
char * arr = calloc ( size , sizeof ( char ) ) ;
TEST_ASSERT_NOT_NULL ( arr ) ;
return arr ;
}
TEST_CASE ( " Check for leaks (no leak) " , " [heap] " )
{
2019-11-11 03:34:37 +00:00
char * arr = check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
free ( arr ) ;
}
TEST_CASE ( " Check for leaks (leak) " , " [heap][ignore] " )
{
2019-11-11 03:34:37 +00:00
check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
}
TEST_CASE ( " Not check for leaks " , " [heap][leaks] " )
{
2019-11-11 03:34:37 +00:00
check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
}
TEST_CASE ( " Set a leak level = 7016 " , " [heap][leaks=7016] " )
{
check_calloc ( 7000 ) ;
}
static void test_fn ( void )
{
2019-11-11 03:34:37 +00:00
check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
}
TEST_CASE_MULTIPLE_STAGES ( " Not check for leaks in MULTIPLE_STAGES mode " , " [heap][leaks] " , test_fn , test_fn , test_fn ) ;
TEST_CASE_MULTIPLE_STAGES ( " Check for leaks in MULTIPLE_STAGES mode (leak) " , " [heap][ignore] " , test_fn , test_fn , test_fn ) ;
static void test_fn2 ( void )
{
2019-11-11 03:34:37 +00:00
check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
esp_restart ( ) ;
}
static void test_fn3 ( void )
{
2019-11-11 03:34:37 +00:00
check_calloc ( 1000 ) ;
2019-04-12 01:31:23 +00:00
}
2019-11-11 03:34:37 +00:00
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 ) ;