Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
test_queue_contexts.c File Reference
#include "test_queue.h"

Macros

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define LIST_LEN   2
 
#define QUEUE_NUM   10
 Verify that multiple queues can be defined simultaneously.
 

Functions

 K_QUEUE_DEFINE (kqueue)
 TESTPOINT: init via K_QUEUE_DEFINE.
 
 K_HEAP_DEFINE (mem_pool_fail, 8+128)
 
 K_HEAP_DEFINE (mem_pool_pass, 64 *4+128)
 
static K_THREAD_STACK_DEFINE (tstack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack1,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack2,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void tqueue_append (struct k_queue *pqueue)
 
static void tqueue_get (struct k_queue *pqueue)
 
static void tIsr_entry_append (const void *p)
 
static void tIsr_entry_get (const void *p)
 
static void tThread_entry (void *p1, void *p2, void *p3)
 
static void tqueue_thread_thread (struct k_queue *pqueue)
 
static void tqueue_thread_isr (struct k_queue *pqueue)
 
static void tqueue_isr_thread (struct k_queue *pqueue)
 
 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.
 
static void tThread_get (void *p1, void *p2, void *p3)
 
static void tqueue_get_2threads (struct k_queue *pqueue)
 
 ZTEST (queue_api_1cpu, test_queue_get_2threads)
 Verify k_queue_get()
 
static void tqueue_alloc (struct k_queue *pqueue)
 
 ZTEST (queue_api, test_queue_alloc)
 Test queue alloc append and prepend.
 
static void queue_poll_race_consume (void *p1, void *p2, void *p3)
 
 ZTEST (queue_api_1cpu, test_queue_poll_race)
 
 ZTEST (queue_api, test_multiple_queues)
 
void user_access_queue_private_data (void *p1, void *p2, void *p3)
 
 ZTEST (queue_api, test_access_kernel_obj_with_priv_data)
 Test access kernel object with private data using system call.
 
static void low_prio_wait_for_queue (void *p1, void *p2, void *p3)
 
static void high_prio_t1_wait_for_queue (void *p1, void *p2, void *p3)
 
static void high_prio_t2_wait_for_queue (void *p1, void *p2, void *p3)
 
 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()
 

Variables

struct k_queue queue
 
static qdata_t data [2]
 
static qdata_t data_p [2]
 
static qdata_t data_l [2]
 
static qdata_t data_sl [2]
 
static qdata_tdata_append
 
static qdata_tdata_prepend
 
static struct k_thread tdata
 
static struct k_thread tdata1
 
static struct k_thread tdata2
 
static struct k_sem end_sema
 

Macro Definition Documentation

◆ LIST_LEN

#define LIST_LEN   2

◆ STACK_SIZE

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

Function Documentation

◆ high_prio_t1_wait_for_queue()

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

◆ high_prio_t2_wait_for_queue()

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

◆ K_HEAP_DEFINE() [1/2]

K_HEAP_DEFINE ( mem_pool_fail  ,
8+  128 
)

◆ K_HEAP_DEFINE() [2/2]

K_HEAP_DEFINE ( mem_pool_pass  ,
64 *4+  128 
)

◆ K_QUEUE_DEFINE()

K_QUEUE_DEFINE ( kqueue  )

TESTPOINT: init via K_QUEUE_DEFINE.

◆ K_THREAD_STACK_DEFINE() [1/3]

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

◆ K_THREAD_STACK_DEFINE() [2/3]

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

◆ K_THREAD_STACK_DEFINE() [3/3]

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

◆ low_prio_wait_for_queue()

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

◆ queue_poll_race_consume()

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

◆ tIsr_entry_append()

static void tIsr_entry_append ( const void *  p)
static

◆ tIsr_entry_get()

static void tIsr_entry_get ( const void *  p)
static

◆ tqueue_alloc()

static void tqueue_alloc ( struct k_queue pqueue)
static

◆ tqueue_append()

static void tqueue_append ( struct k_queue pqueue)
static

TESTPOINT: queue append

TESTPOINT: queue prepend

TESTPOINT: queue append list

TESTPOINT: queue merge slist

◆ tqueue_get()

static void tqueue_get ( struct k_queue pqueue)
static

TESTPOINT: queue get

TESTPOINT: queue get

◆ tqueue_get_2threads()

static void tqueue_get_2threads ( struct k_queue pqueue)
static

◆ tqueue_isr_thread()

static void tqueue_isr_thread ( struct k_queue pqueue)
static

TESTPOINT: isr-thread data passing via queue

◆ tqueue_thread_isr()

static void tqueue_thread_isr ( struct k_queue pqueue)
static

TESTPOINT: thread-isr data passing via queue

◆ tqueue_thread_thread()

static void tqueue_thread_thread ( struct k_queue pqueue)
static

TESTPOINT: thread-thread data passing via queue

◆ tThread_entry()

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

◆ tThread_get()

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

◆ user_access_queue_private_data()

void user_access_queue_private_data ( void *  p1,
void *  p2,
void *  p3 
)

◆ ZTEST() [1/3]

ZTEST ( queue_api  ,
test_access_kernel_obj_with_priv_data   
)

Test access kernel object with private data using system call.

  • When defining system calls, it is very important to ensure that access to the API’s private data is done exclusively through system call interfaces. Private kernel data should never be made available to user mode threads directly. For example, the k_queue APIs were intentionally not made available as they store bookkeeping information about the queue directly in the queue buffers which are visible from user mode.
  • Current test makes user thread try to access private kernel data within their associated data structures. Kernel will track that system call access to these object with the kernel object permission system. Current user thread doesn't have permission on it, trying to access &pqueue kernel object will happen kernel oops, because current user thread doesn't have permission on k_queue object with private kernel data.

◆ ZTEST() [2/3]

ZTEST ( queue_api  ,
test_multiple_queues   
)

◆ ZTEST() [3/3]

ZTEST ( queue_api_1cpu  ,
test_queue_poll_race   
)

Variable Documentation

◆ data

qdata_t data[2]
static

◆ data_append

qdata_t* data_append
static

◆ data_l

qdata_t data_l[2]
static

◆ data_p

qdata_t data_p[2]
static

◆ data_prepend

qdata_t* data_prepend
static

◆ data_sl

qdata_t data_sl[2]
static

◆ end_sema

struct k_sem end_sema
static

◆ queue

struct k_queue queue

◆ tdata

struct k_thread tdata
static

◆ tdata1

struct k_thread tdata1
static

◆ tdata2

struct k_thread tdata2
static