mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
Unit tests: If a test fails due to corrupting memory, don't print a misleading source file name
This commit is contained in:
committed by
Angus Gratton
parent
d20fbffae1
commit
6f07e0797d
@@ -59,7 +59,7 @@ static void check_leak(size_t before_free, size_t after_free, const char *type)
|
|||||||
leaked < CRITICAL_LEAK_THRESHOLD ? "potential" : "critical",
|
leaked < CRITICAL_LEAK_THRESHOLD ? "potential" : "critical",
|
||||||
before_free, after_free, leaked);
|
before_free, after_free, leaked);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
TEST_ASSERT(leaked < CRITICAL_LEAK_THRESHOLD); /* fail the test if it leaks too much */
|
TEST_ASSERT_MESSAGE(leaked < CRITICAL_LEAK_THRESHOLD, "The test leaked too much memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tearDown runs after every test */
|
/* tearDown runs after every test */
|
||||||
@@ -68,8 +68,12 @@ void tearDown(void)
|
|||||||
/* some FreeRTOS stuff is cleaned up by idle task */
|
/* some FreeRTOS stuff is cleaned up by idle task */
|
||||||
vTaskDelay(5);
|
vTaskDelay(5);
|
||||||
|
|
||||||
|
/* We want the teardown to have this file in the printout if TEST_ASSERT fails */
|
||||||
|
const char *real_testfile = Unity.TestFile;
|
||||||
|
Unity.TestFile = __FILE__;
|
||||||
|
|
||||||
/* check if unit test has caused heap corruption in any heap */
|
/* check if unit test has caused heap corruption in any heap */
|
||||||
TEST_ASSERT( heap_caps_check_integrity(MALLOC_CAP_INVALID, true) );
|
TEST_ASSERT_MESSAGE( heap_caps_check_integrity(MALLOC_CAP_INVALID, true), "The test has corrupted the heap");
|
||||||
|
|
||||||
/* check for leaks */
|
/* check for leaks */
|
||||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||||
@@ -77,6 +81,8 @@ void tearDown(void)
|
|||||||
|
|
||||||
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||||
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||||
|
|
||||||
|
Unity.TestFile = real_testfile; // go back to the real filename
|
||||||
}
|
}
|
||||||
|
|
||||||
void unity_putc(int c)
|
void unity_putc(int c)
|
||||||
|
@@ -302,7 +302,6 @@ CONFIG_LOG_COLORS=y
|
|||||||
#
|
#
|
||||||
CONFIG_L2_TO_L3_COPY=
|
CONFIG_L2_TO_L3_COPY=
|
||||||
CONFIG_LWIP_MAX_SOCKETS=4
|
CONFIG_LWIP_MAX_SOCKETS=4
|
||||||
CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX=0
|
|
||||||
CONFIG_LWIP_SO_REUSE=
|
CONFIG_LWIP_SO_REUSE=
|
||||||
CONFIG_LWIP_SO_RCVBUF=
|
CONFIG_LWIP_SO_RCVBUF=
|
||||||
CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1
|
CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1
|
||||||
|
Reference in New Issue
Block a user