Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Queues

Tests for queue. More...

Macros

#define QUEUE_NUM   10
 Verify that multiple queues can be defined simultaneously.
 

Functions

 ZTEST (queue_api_1cpu, test_queue_thread2thread)
 Verify data passing between threads using queue.
 
 ZTEST (queue_api, test_queue_thread2isr)
 Verify data passing between thread and ISR.
 
 ZTEST (queue_api, test_queue_isr2thread)
 Verify data passing between ISR and thread.
 
 ZTEST (queue_api_1cpu, test_queue_get_2threads)
 Verify k_queue_get()
 
 ZTEST (queue_api, test_queue_alloc)
 Test queue alloc append and prepend.
 
 ZTEST (queue_api_1cpu, test_queue_multithread_competition)
 Test multi-threads to get data from a queue.
 
 ZTEST (queue_api, test_queue_unique_append)
 Verify k_queue_unique_append()
 
 ZTEST (queue_api_1cpu, test_queue_get_fail)
 Test k_queue_get() failure scenario.
 
 ZTEST (queue_api, test_queue_append_list_error)
 Test k_queue_append_list() failure scenario.
 
 ZTEST (queue_api, test_queue_merge_list_error)
 Test k_queue_merge_slist() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_init_null)
 Test k_queue_init() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_alloc_append_null)
 Test k_queue_alloc_append() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_alloc_prepend_null)
 Test k_queue_alloc_prepend() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_get_null)
 Test k_queue_get() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_is_empty_null)
 Test k_queue_is_empty() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_peek_head_null)
 Test k_queue_peek_head() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_peek_tail_null)
 Test k_queue_peek_tail() failure scenario.
 
 ZTEST_USER (queue_api, test_queue_cancel_wait_error)
 Test k_queue_merge_slist() failure scenario.
 
 ZTEST (queue_api_1cpu, test_queue_loop)
 Test queue operations in loop.
 
 ZTEST (queue_api_1cpu, test_queue_supv_to_user)
 Verify queue elements and cancel wait from a user thread.
 
 ZTEST_USER (queue_api, test_queue_alloc_prepend_user)
 verify allocate and feature "Last In, First Out"
 
 ZTEST_USER (queue_api, test_queue_alloc_append_user)
 verify feature of queue "First In, First Out"
 
 ZTEST (queue_api, test_auto_free)
 Test to verify free of allocated elements of queue.
 

Detailed Description

Tests for queue.

Macro Definition Documentation

◆ QUEUE_NUM

#define QUEUE_NUM   10

#include <tests/kernel/queue/src/test_queue_contexts.c>

Verify that multiple queues can be defined simultaneously.

define multiple queues to verify they can work.

See also
k_queue_init()

Function Documentation

◆ ZTEST() [1/13]

ZTEST ( queue_api  ,
test_auto_free   
)

#include <tests/kernel/queue/src/test_queue_user.c>

Test to verify free of allocated elements of queue.

◆ ZTEST() [2/13]

ZTEST ( queue_api  ,
test_queue_alloc   
)

◆ ZTEST() [3/13]

ZTEST ( queue_api  ,
test_queue_append_list_error   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_append_list() failure scenario.

According to the API k_queue_append_list to design some error condition to verify error branch of the API.

  1. Verify that the list's head is empty.
  2. Verify that the list's tail is empty.
  3. Verify that append list to the queue when a sub-thread is waiting for data.
See also
k_queue_append_list()

◆ ZTEST() [4/13]

ZTEST ( queue_api  ,
test_queue_isr2thread   
)

#include <tests/kernel/queue/src/test_queue_contexts.c>

Verify data passing between ISR and thread.

Create a new ISR and ready for getting data And current thread is used for inserting data Verify if the rx_data is equal insert-data address.

See also
k_queue_init(), k_queue_insert(), k_queue_get(), k_queue_append(), k_queue_remove()

TESTPOINT: test k_queue_init queue

TESTPOINT: test K_QUEUE_DEFINE queue

◆ ZTEST() [5/13]

ZTEST ( queue_api  ,
test_queue_merge_list_error   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_merge_slist() failure scenario.

Verify the API k_queue_merge_slist when a slist is empty or a slist's tail is null.

See also
k_queue_merge_slist()

◆ ZTEST() [6/13]

ZTEST ( queue_api  ,
test_queue_thread2isr   
)

#include <tests/kernel/queue/src/test_queue_contexts.c>

Verify data passing between thread and ISR.

Create a new ISR to insert data And current thread is used for getting data Verify if the rx_data is equal insert-data address. If the received data address is the same as the created array, prove that the queue data structures are stored within the provided data items.

See also
k_queue_init(), k_queue_insert(), k_queue_append()

TESTPOINT: init via k_queue_init

TESTPOINT: test K_QUEUE_DEFINEed queue

◆ ZTEST() [7/13]

ZTEST ( queue_api  ,
test_queue_unique_append   
)

#include <tests/kernel/queue/src/test_queue_contexts.c>

Verify k_queue_unique_append()

Append the same data to the queue repeatedly, see if it returns expected value. And verify operation succeed if append different data to the queue.

See also
k_queue_unique_append()

◆ ZTEST() [8/13]

ZTEST ( queue_api_1cpu  ,
test_queue_get_2threads   
)

◆ ZTEST() [9/13]

ZTEST ( queue_api_1cpu  ,
test_queue_get_fail   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_get() failure scenario.

See also
k_queue_get()

TESTPOINT: queue get returns NULL

◆ ZTEST() [10/13]

ZTEST ( queue_api_1cpu  ,
test_queue_loop   
)

◆ ZTEST() [11/13]

ZTEST ( queue_api_1cpu  ,
test_queue_multithread_competition   
)

#include <tests/kernel/queue/src/test_queue_contexts.c>

Test multi-threads to get data from a queue.

Define three threads, and set a higher priority for two of them, and set a lower priority for the last one. Then Add a delay between creating the two high priority threads. Test point:

  1. Any number of threads may wait on an empty FIFO simultaneously.
  2. When a data item is added, it is given to the highest priority thread that has waited longest.

◆ ZTEST() [12/13]

ZTEST ( queue_api_1cpu  ,
test_queue_supv_to_user   
)

#include <tests/kernel/queue/src/test_queue_user.c>

Verify queue elements and cancel wait from a user thread.

The test adds elements to queue and then verified by the child user thread. Get data from a empty queue,and use K_FORVER to wait for available And to cancel wait from current thread.

See also
k_queue_append(), k_queue_alloc_append(), k_queue_init(), k_queue_cancel_wait()

◆ ZTEST() [13/13]

ZTEST ( queue_api_1cpu  ,
test_queue_thread2thread   
)

#include <tests/kernel/queue/src/test_queue_contexts.c>

Verify data passing between threads using queue.

Static define and Dynamic define queues, Then initialize them. Create a new thread to wait for reading data. Current thread will append item into queue. Verify if rx_data is equal insert-data address. Verify queue can be define at compile time.

See also
k_queue_init(), k_queue_insert(), k_queue_append() K_THREAD_STACK_DEFINE()

TESTPOINT: init via k_queue_init

TESTPOINT: test K_QUEUE_DEFINEed queue

◆ ZTEST_USER() [1/10]

ZTEST_USER ( queue_api  ,
test_queue_alloc_append_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_alloc_append() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_alloc_append()

◆ ZTEST_USER() [2/10]

ZTEST_USER ( queue_api  ,
test_queue_alloc_append_user   
)

#include <tests/kernel/queue/src/test_queue_user.c>

verify feature of queue "First In, First Out"

Create a new queue And allocated memory for the queue Initialize and insert data item in sequence. Verify the feather "First in,First out"

See also
k_queue_init(), k_queue_alloc_append()

◆ ZTEST_USER() [3/10]

ZTEST_USER ( queue_api  ,
test_queue_alloc_prepend_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_alloc_prepend() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_alloc_prepend()

◆ ZTEST_USER() [4/10]

ZTEST_USER ( queue_api  ,
test_queue_alloc_prepend_user   
)

#include <tests/kernel/queue/src/test_queue_user.c>

verify allocate and feature "Last In, First Out"

Create a new queue And allocated memory for the queue Initialize and insert data item in sequence. Verify the feather "Last in,First out"

See also
k_queue_alloc_prepend()

◆ ZTEST_USER() [5/10]

ZTEST_USER ( queue_api  ,
test_queue_cancel_wait_error   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_merge_slist() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_merge_slist()

◆ ZTEST_USER() [6/10]

ZTEST_USER ( queue_api  ,
test_queue_get_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_get() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_get()

◆ ZTEST_USER() [7/10]

ZTEST_USER ( queue_api  ,
test_queue_init_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_init() failure scenario.

Verify that the parameter of API k_queue_init() is NULL, what will happen.

See also
k_queue_init()

◆ ZTEST_USER() [8/10]

ZTEST_USER ( queue_api  ,
test_queue_is_empty_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_is_empty() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_is_empty()

◆ ZTEST_USER() [9/10]

ZTEST_USER ( queue_api  ,
test_queue_peek_head_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_peek_head() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_peek_head()

◆ ZTEST_USER() [10/10]

ZTEST_USER ( queue_api  ,
test_queue_peek_tail_null   
)

#include <tests/kernel/queue/src/test_queue_fail.c>

Test k_queue_peek_tail() failure scenario.

Verify that the parameter of the API is NULL, what will happen.

See also
k_queue_peek_tail()