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

Macros

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

Functions

void test_slab_get_all_blocks (void **p)
 Get all blocks from the memory slab. More...
 
void test_slab_free_all_blocks (void **p)
 Free all memory blocks. More...
 
 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. More...
 
void test_mslab (void)
 Main task to test memory slab interfaces. More...
 
 K_THREAD_DEFINE (HELPER,(1024+CONFIG_TEST_EXTRA_STACKSIZE), helper_thread, NULL, NULL, NULL, 7, 0, 0)
 
void test_main (void)
 

Macro Definition Documentation

◆ NUMBLOCKS

#define NUMBLOCKS   4

◆ STACKSIZE

#define STACKSIZE   (1024 + CONFIG_TEST_EXTRA_STACKSIZE)

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.

Returns
N/A

◆ 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_STACKSIZE)  ,
helper_thread  ,
NULL  ,
NULL  ,
NULL  ,
,
,
 
)

◆ test_main()

void test_main ( void  )

test case main entry

◆ 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
Returns
TC_PASS, TC_FAIL

◆ 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
Returns
TC_PASS, TC_FAIL