Zephyr Project API 3.7.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference
#include <zephyr/tc_util.h>
#include <stdbool.h>
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>

Macros

#define STACKSIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define NUMBLOCKS   4
 

Functions

void test_slab_get_all_blocks (void **p)
 Get all blocks from the memory slab.
 
void test_slab_free_all_blocks (void **p)
 Free all memory blocks.
 
 K_SEM_DEFINE (SEM_HELPERDONE, 0, 1)
 
 K_SEM_DEFINE (SEM_REGRESSDONE, 0, 1)
 
 K_MEM_SLAB_DEFINE (map_lgblks, 1024, 4, 4)
 
void helper_thread (void)
 Helper task.
 
 ZTEST (memory_slab_1cpu, test_mslab)
 Main task to test memory slab interfaces.
 
 K_THREAD_DEFINE (HELPER,(1024+CONFIG_TEST_EXTRA_STACK_SIZE), helper_thread, NULL, NULL, NULL, 7, 0, 0)
 
 ZTEST_SUITE (memory_slab_1cpu, NULL, NULL, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 

Macro Definition Documentation

◆ NUMBLOCKS

#define NUMBLOCKS   4

◆ STACKSIZE

#define STACKSIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

Function Documentation

◆ helper_thread()

void helper_thread ( void  )

Helper task.

This routine gets all blocks from the memory slab. It uses semaphores SEM_REGRESDONE and SEM_HELPERDONE to synchronize between different parts of the test.

◆ K_MEM_SLAB_DEFINE()

K_MEM_SLAB_DEFINE ( map_lgblks  ,
1024  ,
,
 
)

◆ K_SEM_DEFINE() [1/2]

K_SEM_DEFINE ( SEM_HELPERDONE  ,
,
 
)

◆ K_SEM_DEFINE() [2/2]

K_SEM_DEFINE ( SEM_REGRESSDONE  ,
,
 
)

◆ K_THREAD_DEFINE()

K_THREAD_DEFINE ( HELPER  ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)  ,
helper_thread  ,
NULL  ,
NULL  ,
NULL  ,
,
,
 
)

◆ test_slab_free_all_blocks()

void test_slab_free_all_blocks ( void **  p)

Free all memory blocks.

This routine frees all memory blocks and also verifies that the number of blocks used are correct.

This routine tests the following:

k_mem_slab_free(&), k_mem_slab_num_used_get(&)

Parameters
ppointer to pointer of allocated blocks

◆ test_slab_get_all_blocks()

void test_slab_get_all_blocks ( void **  p)

Get all blocks from the memory slab.

Get all blocks from the memory slab. It also tries to get one more block from the map after the map is empty to verify the error return code.

This routine tests the following:

k_mem_slab_alloc(), k_mem_slab_num_used_get()

Parameters
ppointer to pointer of allocated blocks

◆ ZTEST_SUITE()

ZTEST_SUITE ( memory_slab_1cpu  ,
NULL  ,
NULL  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)