Zephyr Project API  3.3.0
A Scalable Open Source RTOS
test_mheap_api.c File Reference
#include <zephyr/ztest.h>
#include <kernel_internal.h>
#include <zephyr/irq_offload.h>
#include <zephyr/sys/multi_heap.h>
#include "test_mheap.h"

Macros

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define OVERFLOW_SIZE   SIZE_MAX
 
#define NMEMB   8
 
#define SIZE   16
 
#define BOUNDS   (NMEMB * SIZE)
 
#define N_MULTI_HEAPS   4
 
#define MHEAP_BYTES   128
 

Functions

 K_SEM_DEFINE (thread_sem, 0, 1)
 
 K_THREAD_STACK_DEFINE (tstack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void tIsr_malloc_and_free (void *data)
 
static void thread_entry (void *p1, void *p2, void *p3)
 
 ZTEST (mheap_api, test_mheap_malloc_free)
 Test to demonstrate k_malloc() and k_free() API usage. More...
 
 ZTEST (mheap_api, test_mheap_calloc)
 Test to demonstrate k_calloc() API functionality. More...
 
 ZTEST (mheap_api, test_k_aligned_alloc)
 
 ZTEST (mheap_api, test_sys_heap_mem_pool_assign)
 Validate allocation and free from system heap memory pool. More...
 
 ZTEST (mheap_api, test_malloc_in_isr)
 Validate allocation and free from system heap memory pool in isr context. More...
 
 ZTEST (mheap_api, test_malloc_in_thread)
 Validate allocation and free failure when thread's resource pool is not assigned. More...
 
void * multi_heap_choice (struct sys_multi_heap *mheap, void *cfg, size_t align, size_t size)
 
 ZTEST (mheap_api, test_multi_heap)
 

Variables

static struct sys_multi_heap multi_heap
 
static char heap_mem [4][128]
 
static struct sys_heap mheaps [4]
 
struct k_thread tdata
 

Macro Definition Documentation

◆ BOUNDS

#define BOUNDS   (NMEMB * SIZE)

◆ MHEAP_BYTES

#define MHEAP_BYTES   128

◆ N_MULTI_HEAPS

#define N_MULTI_HEAPS   4

◆ NMEMB

#define NMEMB   8

◆ OVERFLOW_SIZE

#define OVERFLOW_SIZE   SIZE_MAX

◆ SIZE

#define SIZE   16

◆ STACK_SIZE

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

Function Documentation

◆ K_SEM_DEFINE()

K_SEM_DEFINE ( thread_sem  ,
,
 
)

◆ K_THREAD_STACK_DEFINE()

K_THREAD_STACK_DEFINE ( tstack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ multi_heap_choice()

void * multi_heap_choice ( struct sys_multi_heap mheap,
void *  cfg,
size_t  align,
size_t  size 
)

◆ thread_entry()

static void thread_entry ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ tIsr_malloc_and_free()

static void tIsr_malloc_and_free ( void *  data)
static

◆ ZTEST() [1/2]

ZTEST ( mheap_api  ,
test_k_aligned_alloc   
)

◆ ZTEST() [2/2]

ZTEST ( mheap_api  ,
test_multi_heap   
)

Variable Documentation

◆ heap_mem

char heap_mem[4][128]
static

◆ mheaps

struct sys_heap mheaps[4]
static

◆ multi_heap

struct sys_multi_heap multi_heap
static

◆ tdata

struct k_thread tdata