From be5af1c737240534c7889a24afef3ca104fdb8b2 Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 22 Mar 2024 12:24:29 +0800 Subject: [PATCH] test(cache): added test for cache_prefer_m/calloc --- .../mm/main/test_cache_msync_malloc.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 components/esp_mm/test_apps/mm/main/test_cache_msync_malloc.c diff --git a/components/esp_mm/test_apps/mm/main/test_cache_msync_malloc.c b/components/esp_mm/test_apps/mm/main/test_cache_msync_malloc.c new file mode 100644 index 0000000000..1c1a52e926 --- /dev/null +++ b/components/esp_mm/test_apps/mm/main/test_cache_msync_malloc.c @@ -0,0 +1,39 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdkconfig.h" +#include +#include +#include "inttypes.h" +#include "esp_log.h" +#include "esp_attr.h" +#include "unity.h" +#include "esp_private/esp_cache_private.h" +#include "esp_memory_utils.h" + +const static char *TAG = "CACHE_MALLOC_TEST"; + +TEST_CASE("test esp_cache_aligned_malloc_prefer", "[cache]") +{ + void *ptr = NULL; + size_t actual_size = 0; + TEST_ESP_OK(esp_cache_aligned_malloc_prefer(40, &ptr, &actual_size, 1, ESP_CACHE_MALLOC_FLAG_DMA, 0)); + TEST_ASSERT(esp_ptr_dma_capable(ptr)); + ESP_LOGI(TAG, "actual size: 0x%x", actual_size); + + free(ptr); +} + +TEST_CASE("test esp_cache_aligned_calloc_prefer", "[cache]") +{ + void *ptr = NULL; + size_t actual_size = 0; + TEST_ESP_OK(esp_cache_aligned_calloc_prefer(1, 40, &ptr, &actual_size, 1, ESP_CACHE_MALLOC_FLAG_DMA, 0)); + TEST_ASSERT(esp_ptr_dma_capable(ptr)); + ESP_LOGI(TAG, "actual size: 0d%d", actual_size); + + free(ptr); +}