fix(bootloader_support): Fix memory leak for unit tests

This commit is contained in:
KonstantinKondrashov 2023-07-19 21:25:31 +08:00
parent 13ea139a1a
commit 95626b9401
2 changed files with 5 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#include "unity.h"
#include "unity_test_runner.h"
#include "esp_heap_caps.h"
#include "esp_ota_ops.h"
// Some resources are lazy allocated, e.g. newlib locks, GDMA channel lazy installed by crypto driver
@ -25,12 +26,12 @@ static void check_leak(size_t before_free, size_t after_free, const char *type)
void setUp(void)
{
// load the partition table before measuring the initial free heap size.
TEST_ASSERT_NOT_EQUAL(NULL, esp_ota_get_running_partition());
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
}
void tearDown(void)
{
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);

View File

@ -46,6 +46,8 @@ TEST_CASE("Verify unit test app image", "[bootloader_support][qemu-ignore-c3]")
.offset = running->address,
.size = running->size,
};
TEST_ASSERT_GREATER_THAN(0, running->address);
TEST_ASSERT_GREATER_THAN(0, running->size);
TEST_ASSERT_EQUAL_HEX(ESP_OK, esp_image_verify(ESP_IMAGE_VERIFY, &running_pos, &data));
TEST_ASSERT_NOT_EQUAL(0, data.image_len);