uart_driver_install(UART_NUM1, BUF_SIZE * 2, BUF_SIZE * 2, 20, NULL, 0);
}
-TEST_CASE("test uart get baud-rate","[uart]")
+TEST_CASE("test uart get baud-rate", "[uart]")
{
uint32_t baud_rate1 = 0;
uint32_t baud_rate2 = 0;
ESP_LOGI(UART_TAG, "get baud-rate test passed ....\n");
}
-TEST_CASE("test uart tx data with break","[uart][leaks=2192]")
+TEST_CASE("test uart tx data with break", "[uart]")
{
const int buf_len = 200;
const int send_len = 128;
const int brk_len = 10;
char *psend = (char *)malloc(buf_len);
- TEST_ASSERT( psend != NULL);
+ TEST_ASSERT(psend != NULL);
memset(psend, '0', buf_len);
uart_config(UART_BAUD_115200, false);
printf("Uart%d send %d bytes with break\n", UART_NUM1, send_len);
//If the code is running here, it means the test passed, otherwise it will crash due to the interrupt wdt timeout.
printf("Send data with break test passed\n");
free(psend);
+ uart_driver_delete(UART_NUM1);
}
// Calculate buffer checksum using tables
performance_test(true);
}
-TEST_CASE("performance test - no dedicated task", "[event][leaks=2736]")
+TEST_CASE("performance test - no dedicated task", "[event]")
{
performance_test(false);
}
//must run here, not blocking in above code
TEST_ASSERT(1);
+ nvs_flash_deinit();
}
static IRAM_ATTR void test_phy_rtc_cache_task(void *arg)
vTaskDelete(NULL);
}
-TEST_CASE("Test PHY/RTC functions called when cache is disabled", "[phy_rtc][cache_disabled][leaks=1216]")
+TEST_CASE("Test PHY/RTC functions called when cache is disabled", "[phy_rtc][cache_disabled]")
{
semphr_done = xSemaphoreCreateCounting(1, 0);
test_teardown();
}
-TEST_CASE("(raw) can open maximum number of files", "[fatfs][leaks=2028]")
+TEST_CASE("(raw) can open maximum number of files", "[fatfs]")
{
size_t max_files = FOPEN_MAX - 3; /* account for stdin, stdout, stderr */
test_setup(max_files);
test_teardown();
}
-TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][test_env=UT_T1_SDMODE][leaks=1264]")
+TEST_CASE("(SD) multiple tasks can use same volume", "[fatfs][test_env=UT_T1_SDMODE]")
{
test_setup();
test_fatfs_concurrent("/sdcard/f");
static void speed_test(void* buf, size_t buf_size, size_t file_size, bool write);
-TEST_CASE("(SD) write/read speed test", "[fatfs][sd][test_env=UT_T1_SDMODE][timeout=60][leaks=1080]")
+TEST_CASE("(SD) write/read speed test", "[fatfs][sd][test_env=UT_T1_SDMODE][timeout=60]")
{
size_t heap_size;
HEAP_SIZE_CAPTURE(heap_size);
test_teardown();
}
-TEST_CASE("(WL) can open maximum number of files", "[fatfs][wear_levelling][leaks=2460]")
+TEST_CASE("(WL) can open maximum number of files", "[fatfs][wear_levelling]")
{
size_t max_files = FOPEN_MAX - 3; /* account for stdin, stdout, stderr */
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
test_teardown();
}
-TEST_CASE("(WL) multiple tasks can use same volume", "[fatfs][wear_levelling][leaks=1340]")
+TEST_CASE("(WL) multiple tasks can use same volume", "[fatfs][wear_levelling]")
{
test_setup();
test_fatfs_concurrent("/spiflash/f");
test_teardown();
}
-TEST_CASE("(WL) write/read speed test", "[fatfs][wear_levelling][timeout=60][leaks=1156]")
+TEST_CASE("(WL) write/read speed test", "[fatfs][wear_levelling][timeout=60]")
{
/* Erase partition before running the test to get consistent results */
const esp_partition_t* part = get_test_data_partition();
*/
void esp_reent_init(struct _reent* r);
+/**
+ * Clean up some of lazily allocated buffers in REENT structures.
+ */
+void esp_reent_cleanup();
+
/**
* Function which sets up syscall table used by newlib functions in ROM.
*
// limitations under the License.
#include <string.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <sys/reent.h>
#include "esp_attr.h"
r->__sglue._niobs = 0;
r->__sglue._iobs = NULL;
}
+
+/* only declared in private stdio header file, local.h */
+extern void __sfp_lock_acquire();
+extern void __sfp_lock_release();
+
+void esp_reent_cleanup()
+{
+ struct _reent* r = __getreent();
+ /* Clean up storage used by mprec functions */
+ if (r->_mp) {
+ if (_REENT_MP_FREELIST(r)) {
+ for (int i = 0; i < _Kmax; ++i) {
+ struct _Bigint *cur, *next;
+ next = _REENT_MP_FREELIST(r)[i];
+ while (next) {
+ cur = next;
+ next = next->_next;
+ free(cur);
+ }
+ }
+ }
+ free(_REENT_MP_FREELIST(r));
+ free(_REENT_MP_RESULT(r));
+ }
+
+ /* Clean up "glue" (lazily-allocated FILE objects) */
+ struct _glue* prev = &_GLOBAL_REENT->__sglue;
+ for (struct _glue* cur = _GLOBAL_REENT->__sglue._next; cur != NULL;) {
+ if (cur->_niobs == 0) {
+ cur = cur->_next;
+ continue;
+ }
+ bool has_open_files = false;
+ for (int i = 0; i < cur->_niobs; ++i) {
+ FILE* fp = &cur->_iobs[i];
+ if (fp->_flags != 0) {
+ has_open_files = true;
+ break;
+ }
+ }
+ if (has_open_files) {
+ prev = cur;
+ cur = cur->_next;
+ continue;
+ }
+ struct _glue* next = cur->_next;
+ prev->_next = next;
+ free(cur);
+ cur = next;
+ }
+
+ /* Clean up various other buffers */
+ free(r->_mp);
+ r->_mp = NULL;
+ free(r->_r48);
+ r->_r48 = NULL;
+ free(r->_localtime_buf);
+ r->_localtime_buf = NULL;
+ free(r->_asctime_buf);
+ r->_asctime_buf = NULL;
+}
test_teardown();
}
-TEST_CASE("can open maximum number of files", "[spiffs][leaks=2244]")
+TEST_CASE("can open maximum number of files", "[spiffs]")
{
size_t max_files = FOPEN_MAX - 3; /* account for stdin, stdout, stderr */
esp_vfs_spiffs_conf_t conf = {
test_teardown();
}
-TEST_CASE("multiple tasks can use same volume", "[spiffs][leaks=1128]")
+TEST_CASE("multiple tasks can use same volume", "[spiffs]")
{
test_setup();
test_spiffs_concurrent("/spiffs/f");
#include "freertos/task.h"
#include "unity.h"
#include "test_utils.h"
+#include "esp_newlib.h"
#ifdef CONFIG_HEAP_TRACING
#include "esp_heap_trace.h"
/* some FreeRTOS stuff is cleaned up by idle task */
vTaskDelay(5);
+ /* clean up some of the newlib's lazy allocations */
+ esp_reent_cleanup();
+
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
/* We want the teardown to have this file in the printout if TEST_ASSERT fails */