Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
test_mbox_api.c File Reference
#include <zephyr/ztest.h>

Macros

#define TIMEOUT   K_MSEC(100)
 
#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define MAIL_LEN   64
 

Enumerations

enum  mmsg_type {
  PUT_GET_NULL = 0 , PUT_GET_BUFFER , ASYNC_PUT_GET_BUFFER , ASYNC_PUT_GET_BLOCK ,
  TARGET_SOURCE_THREAD_BUFFER , MAX_INFO_TYPE , INCORRECT_RECEIVER_TID , INCORRECT_TRANSMIT_TID ,
  TIMED_OUT_MBOX_GET , MSG_TID_MISMATCH , DISPOSE_SIZE_0_MSG , ASYNC_PUT_TO_WAITING_GET ,
  GET_WAITING_PUT_INCORRECT_TID , ASYNC_MULTIPLE_PUT , MULTIPLE_WAITING_GET
}
 

Functions

 K_MBOX_DEFINE (kmbox)
 TESTPOINT: init via K_MBOX_DEFINE.
 
static K_THREAD_STACK_DEFINE (tstack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack_1,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_ARRAY_DEFINE (waiting_get_stack, 5,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void async_put_sema_give (void *p1, void *p2, void *p3)
 
static void mbox_get_waiting_thread (void *p1, void *p2, void *p3)
 
static void tmbox_put (struct k_mbox *pmbox)
 
static void tmbox_get (struct k_mbox *pmbox)
 
static void tmbox_entry (void *p1, void *p2, void *p3)
 
static void tmbox (struct k_mbox *pmbox)
 
 ZTEST (mbox_api, test_mbox_kinit)
 
 ZTEST (mbox_api, test_mbox_kdefine)
 
 ZTEST (mbox_api, test_enhance_capability)
 Test mailbox enhance capabilities.
 
 ZTEST (mbox_api, test_define_multi_mbox)
 
 ZTEST (mbox_api, test_mbox_put_get_null)
 
 ZTEST (mbox_api, test_mbox_put_get_buffer)
 
 ZTEST (mbox_api, test_mbox_async_put_get_buffer)
 
 ZTEST (mbox_api, test_mbox_async_put_get_block)
 
 ZTEST (mbox_api, test_mbox_target_source_thread_buffer)
 
 ZTEST (mbox_api, test_mbox_incorrect_receiver_tid)
 
 ZTEST (mbox_api, test_mbox_incorrect_transmit_tid)
 
 ZTEST (mbox_api, test_mbox_timed_out_mbox_get)
 
 ZTEST (mbox_api, test_mbox_msg_tid_mismatch)
 
 ZTEST (mbox_api, test_mbox_dispose_size_0_msg)
 
 ZTEST (mbox_api, test_mbox_async_put_to_waiting_get)
 
 ZTEST (mbox_api, test_mbox_get_waiting_put_incorrect_tid)
 
 ZTEST (mbox_api, test_mbox_async_multiple_put)
 
 ZTEST (mbox_api, test_mbox_multiple_waiting_get)
 
void * setup_mbox_api (void)
 
 ZTEST_SUITE (mbox_api, NULL, setup_mbox_api, NULL, NULL, NULL)
 

Variables

static struct k_mbox mbox
 
static k_tid_t sender_tid
 
static k_tid_t receiver_tid
 
static k_tid_t random_tid
 
static struct k_thread tdata async_tid waiting_get_tid [5]
 
static struct k_sem end_sema sync_sema
 
static enum mmsg_type info_type
 
static char data [MAX_INFO_TYPE][64]
 
static ZTEST_BMEM char buffer [8]
 

Macro Definition Documentation

◆ MAIL_LEN

#define MAIL_LEN   64

◆ STACK_SIZE

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ TIMEOUT

#define TIMEOUT   K_MSEC(100)

Enumeration Type Documentation

◆ mmsg_type

enum mmsg_type
Enumerator
PUT_GET_NULL 
PUT_GET_BUFFER 
ASYNC_PUT_GET_BUFFER 
ASYNC_PUT_GET_BLOCK 
TARGET_SOURCE_THREAD_BUFFER 
MAX_INFO_TYPE 
INCORRECT_RECEIVER_TID 
INCORRECT_TRANSMIT_TID 
TIMED_OUT_MBOX_GET 
MSG_TID_MISMATCH 
DISPOSE_SIZE_0_MSG 
ASYNC_PUT_TO_WAITING_GET 
GET_WAITING_PUT_INCORRECT_TID 
ASYNC_MULTIPLE_PUT 
MULTIPLE_WAITING_GET 

Function Documentation

◆ async_put_sema_give()

static void async_put_sema_give ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ K_MBOX_DEFINE()

K_MBOX_DEFINE ( kmbox  )

TESTPOINT: init via K_MBOX_DEFINE.

◆ K_THREAD_STACK_ARRAY_DEFINE()

static K_THREAD_STACK_ARRAY_DEFINE ( waiting_get_stack  ,
,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ K_THREAD_STACK_DEFINE() [1/2]

static K_THREAD_STACK_DEFINE ( tstack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ K_THREAD_STACK_DEFINE() [2/2]

static K_THREAD_STACK_DEFINE ( tstack_1  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ mbox_get_waiting_thread()

static void mbox_get_waiting_thread ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ setup_mbox_api()

void * setup_mbox_api ( void  )

◆ tmbox()

static void tmbox ( struct k_mbox pmbox)
static

TESTPOINT: thread-thread data passing via mbox

◆ tmbox_entry()

static void tmbox_entry ( void *  p1,
void *  p2,
void *  p3 
)
static

◆ tmbox_get()

static void tmbox_get ( struct k_mbox pmbox)
static

TESTPOINT: mbox sync get buffer

TESTPOINT: mbox sync get buffer

TESTPOINT: mbox async get buffer

◆ tmbox_put()

static void tmbox_put ( struct k_mbox pmbox)
static

TESTPOINT: mbox sync put empty message

TESTPOINT: mbox sync put buffer

TESTPOINT: mbox async put buffer

◆ ZTEST() [1/17]

ZTEST ( mbox_api  ,
test_define_multi_mbox   
)

TESTPOINT: init via k_mbox_init

◆ ZTEST() [2/17]

ZTEST ( mbox_api  ,
test_mbox_async_multiple_put   
)

◆ ZTEST() [3/17]

ZTEST ( mbox_api  ,
test_mbox_async_put_get_block   
)

◆ ZTEST() [4/17]

ZTEST ( mbox_api  ,
test_mbox_async_put_get_buffer   
)

◆ ZTEST() [5/17]

ZTEST ( mbox_api  ,
test_mbox_async_put_to_waiting_get   
)

◆ ZTEST() [6/17]

ZTEST ( mbox_api  ,
test_mbox_dispose_size_0_msg   
)

◆ ZTEST() [7/17]

ZTEST ( mbox_api  ,
test_mbox_get_waiting_put_incorrect_tid   
)

◆ ZTEST() [8/17]

ZTEST ( mbox_api  ,
test_mbox_incorrect_receiver_tid   
)

◆ ZTEST() [9/17]

ZTEST ( mbox_api  ,
test_mbox_incorrect_transmit_tid   
)

◆ ZTEST() [10/17]

ZTEST ( mbox_api  ,
test_mbox_kdefine   
)

◆ ZTEST() [11/17]

ZTEST ( mbox_api  ,
test_mbox_kinit   
)

TESTPOINT: init via k_mbox_init

◆ ZTEST() [12/17]

ZTEST ( mbox_api  ,
test_mbox_msg_tid_mismatch   
)

◆ ZTEST() [13/17]

ZTEST ( mbox_api  ,
test_mbox_multiple_waiting_get   
)

◆ ZTEST() [14/17]

ZTEST ( mbox_api  ,
test_mbox_put_get_buffer   
)

◆ ZTEST() [15/17]

ZTEST ( mbox_api  ,
test_mbox_put_get_null   
)

◆ ZTEST() [16/17]

ZTEST ( mbox_api  ,
test_mbox_target_source_thread_buffer   
)

◆ ZTEST() [17/17]

ZTEST ( mbox_api  ,
test_mbox_timed_out_mbox_get   
)

◆ ZTEST_SUITE()

ZTEST_SUITE ( mbox_api  ,
NULL  ,
setup_mbox_api  ,
NULL  ,
NULL  ,
NULL   
)

Variable Documentation

◆ buffer

ZTEST_BMEM char buffer[8]
static

◆ data

char data[MAX_INFO_TYPE][64]
static
Initial value:
= {
"send/recv an empty message",
"send/recv msg using a buffer",
"async send/recv msg using a memory block",
"specify target/source thread, using a memory block"
}

◆ info_type

enum mmsg_type info_type
static

◆ mbox

struct k_mbox mbox
static

◆ random_tid

k_tid_t random_tid
static

◆ receiver_tid

k_tid_t receiver_tid
static

◆ sender_tid

k_tid_t sender_tid
static

◆ sync_sema

struct k_sem end_sema sync_sema
static

◆ waiting_get_tid

struct k_thread tdata async_tid waiting_get_tid[5]
static