mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-22 13:01:16 +03:00
fix(mbedtls): Fix mbedtls testapps false memory leaks by lazy mutex creation
This commit is contained in:
committed by
Harshal Patil
parent
ce27a6e7e0
commit
6f6e2aa93c
@@ -10,10 +10,28 @@
|
||||
#include "esp_newlib.h"
|
||||
#include "memory_checks.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "psa/crypto.h"
|
||||
#include "unity.h"
|
||||
#include "test_persistent_format.h"
|
||||
|
||||
/* First ITS access caches the NVS psa_its namespace (and related one-shot
|
||||
* PSA storage state). Prime it before leak accounting so consume tests are
|
||||
* not charged ~1.2 KB against the 1200-byte critical threshold — the same
|
||||
* pattern mbedtls_ut uses for AES interrupt allocation. */
|
||||
static void prime_psa_its(psa_key_id_t id)
|
||||
{
|
||||
psa_key_attributes_t attr = PSA_KEY_ATTRIBUTES_INIT;
|
||||
(void)psa_get_key_attributes(id, &attr);
|
||||
psa_reset_key_attributes(&attr);
|
||||
(void)psa_purge_key(id);
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
prime_psa_its(ESP_PERSISTENT_FIXTURE_DS_KEY_ID);
|
||||
prime_psa_its(ESP_PERSISTENT_FIXTURE_HMAC_KEY_ID);
|
||||
prime_psa_its(ESP_PERSISTENT_FIXTURE_ECDSA_KEY_ID);
|
||||
|
||||
test_utils_record_free_mem();
|
||||
test_utils_set_leak_level(CONFIG_UNITY_CRITICAL_LEAK_LEVEL_GENERAL,
|
||||
ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL);
|
||||
|
||||
Reference in New Issue
Block a user