Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
main.c File Reference
#include <ztest.h>

Functions

void test_k_heap_min_size (void)
 Test a minimum-size static k_heap. More...
 
void test_k_heap_alloc (void)
 Test to demonstrate k_heap_alloc() and k_heap_free() API usage. More...
 
void test_k_heap_alloc_fail (void)
 Test to demonstrate k_heap_alloc() and k_heap_free() API usage. More...
 
void test_k_heap_free (void)
 Test to demonstrate k_heap_free() API functionality. More...
 
void test_kheap_alloc_in_isr_nowait (void)
 Validate allocation and free heap memory in isr context. More...
 
void test_k_heap_alloc_pending (void)
 Validate the k_heap support wait between different threads. More...
 
void test_main (void)
 

Function Documentation

◆ test_k_heap_alloc()

void test_k_heap_alloc ( void  )

Test to demonstrate k_heap_alloc() and k_heap_free() API usage.

The test allocates 1024 bytes from 2048 byte heap, and checks if allocation is successful or not

See also
k_heap_malloc(), k_heap_Free()

◆ test_k_heap_alloc_fail()

void test_k_heap_alloc_fail ( void  )

Test to demonstrate k_heap_alloc() and k_heap_free() API usage.

The test allocates 2049 bytes, which is greater than the heap size(2048 bytes), and checks for NULL return from k_heap_alloc

See also
k_heap_malloc(), k_heap_Free()

◆ test_k_heap_free()

void test_k_heap_free ( void  )

Test to demonstrate k_heap_free() API functionality.

The test validates k_heap_free() API, by using below steps

  1. allocate the memory from the heap,
  2. free the allocated memory
  3. allocate memory more than the first allocation. the allocation in the 3rd step should succeed if k_heap_free() works as expected
See also
k_heap_alloc, k_heap_free()

◆ test_k_heap_min_size()

void test_k_heap_min_size ( void  )

Test a minimum-size static k_heap.

Create a minimum size (1-byte) static heap, verify that it works to allocate that byte at runtime and that it doesn't overflow its memory bounds.

◆ test_main()

void test_main ( void  )

test case main entry