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

Functions

 K_MEM_SLAB_DEFINE (kmslab, 16, 3, 8)
 
void tmslab_alloc_free (void *data)
 
static void tmslab_alloc_align (void *data)
 
static void tmslab_alloc_timeout (void *data)
 
static void tmslab_used_get (void *data)
 
void test_mslab_kinit (void)
 Initialize the memory slab using k_mem_slab_init() and allocates/frees blocks. More...
 
void test_mslab_kdefine (void)
 Verify K_MEM_SLAB_DEFINE() with allocates/frees blocks. More...
 
void test_mslab_alloc_free_thread (void)
 Verify alloc and free of blocks from mem_slab. More...
 
void test_mslab_alloc_align (void)
 Allocate memory blocks and check for alignment of 8 bytes. More...
 
void test_mslab_alloc_timeout (void)
 Verify allocation of memory blocks with timeouts. More...
 
void test_mslab_used_get (void)
 Verify count of allocated blocks. More...
 

Variables

static char tslab [16 *3]
 
static struct k_mem_slab mslab
 

Function Documentation

◆ K_MEM_SLAB_DEFINE()

K_MEM_SLAB_DEFINE ( kmslab  ,
16  ,
,
 
)

TESTPOINT: Statically define and initialize a memory slab

◆ tmslab_alloc_align()

static void tmslab_alloc_align ( void data)
static

TESTPOINT: To ensure that each memory block is similarly aligned to this boundary

◆ tmslab_alloc_free()

void tmslab_alloc_free ( void data)

TESTPOINT: The memory slab's buffer contains slab_num_blocks memory blocks that are slab_block_size bytes long.

TESTPOINT: Allocate memory from a memory slab.

TESTPOINT:

Return values
0Memory allocated.

TESTPOINT: The block address area pointed at by mem is set to the starting address of the memory block.

TESTPOINT: Free memory allocated from a memory slab.

◆ tmslab_alloc_timeout()

static void tmslab_alloc_timeout ( void data)
static

TESTPOINT: Use K_NO_WAIT to return without waiting

TESTPOINT: -ENOMEM Returned without waiting.

TESTPOINT: -EAGAIN Waiting period timed out

TESTPOINT: timeout Maximum time to wait for operation to complete (in milliseconds)

◆ tmslab_used_get()

static void tmslab_used_get ( void data)
static

TESTPOINT: Get the number of used blocks in a memory slab.

TESTPOINT: Get the number of unused blocks in a memory slab.

Variable Documentation

◆ mslab

struct k_mem_slab mslab
static

◆ tslab

char tslab[16 * 3]
static