|
Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
|
Kernel Heap API Tests. More...
Functions | |
| void | test_k_heap_min_size (void) |
| Test a minimum-size static k_heap. | |
| void | test_k_heap_alloc (void) |
| Test to demonstrate k_heap_alloc() and k_heap_free() API usage. | |
| void | test_k_heap_alloc_fail (void) |
| Test to demonstrate k_heap_alloc() and k_heap_free() API usage. | |
| void | test_k_heap_free (void) |
| Test to demonstrate k_heap_free() API functionality. | |
| void | test_kheap_alloc_in_isr_nowait (void) |
| Validate allocation and free heap memory in isr context. | |
| void | test_k_heap_alloc_pending (void) |
| Validate the k_heap support wait between different threads. | |
| void | test_k_heap_alloc_pending_null (void) |
| Validate the k_heap alloc_pending_null support. | |
| void | test_k_heap_calloc (void) |
| Test to demonstrate k_heap_calloc() and k_heap_free() API usage. | |
Kernel Heap API Tests.
| void test_k_heap_alloc | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
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
| void test_k_heap_alloc_fail | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
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
| void test_k_heap_alloc_pending | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
Validate the k_heap support wait between different threads.
In main thread alloc a buffer from the heap, then run the child thread. If there isn't enough space in the heap, the child thread will wait timeout long until main thread free the buffer to heap.
| void test_k_heap_alloc_pending_null | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
Validate the k_heap alloc_pending_null support.
In main thread alloc two buffer from the heap, then run the child thread which alloc a buffer larger than remaining space. The child thread will wait timeout long until main thread free one of the buffer to heap, space in the heap is still not enough and then return null after timeout.
| void test_k_heap_calloc | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
Test to demonstrate k_heap_calloc() and k_heap_free() API usage.
The test allocates 256 unsigned integers of 4 bytes for a total of 1024 bytes from the 2048 byte heap. It checks if allocation and initialization are successful or not
| void test_k_heap_free | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
Test to demonstrate k_heap_free() API functionality.
The test validates k_heap_free() API, by using below steps
| void test_k_heap_min_size | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
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.
| void test_kheap_alloc_in_isr_nowait | ( | void | ) |
#include </home/runner/work/safety-doc/zephyr/tests/kernel/mem_heap/k_heap_api/src/test_kheap_api.c>
Validate allocation and free heap memory in isr context.
The test validates k_heap_alloc() in isr context, the timeout param should be K_NO_WAIT, because this situation isn't allow to wait.