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

Data Structures

struct  scratch_lifo_packet
 
struct  reply_packet
 
struct  timeout_order_data
 

Macros

#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define LIST_LEN   2
 
#define NUM_SCRATCH_LIFO_PACKETS   20
 
#define TIMEOUT_ORDER_NUM_THREADS   ARRAY_SIZE(timeout_order_data_mult_lifo)
 
#define TSTACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define LIFO_THREAD_PRIO   -5
 

Functions

static K_THREAD_STACK_DEFINE (tstack,(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack1,(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
void test_thread_pend_and_timeout (void *p1, void *p2, void *p3)
 a thread pends on a lifo then times out
 
static K_THREAD_STACK_ARRAY_DEFINE (ttstack, ARRAY_SIZE(timeout_order_data_mult_lifo),(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void * get_scratch_packet (void)
 
static void put_scratch_packet (void *packet)
 
static void thread_entry_nowait (void *p1, void *p2, void *p3)
 
static bool is_timeout_in_range (uint32_t start_time, uint32_t timeout)
 
static int test_multiple_threads_pending (struct timeout_order_data *test_data, int test_data_size)
 
static void thread_entry_wait (void *p1, void *p2, void *p3)
 
static void test_thread_timeout_reply_values (void *p1, void *p2, void *p3)
 try getting data on lifo with special timeout value, return result in lifo
 
static void test_thread_timeout_reply_values_wfe (void *p1, void *p2, void *p3)
 
static void test_thread_put_timeout (void *p1, void *p2, void *p3)
 A thread sleeps then puts data on the lifo.
 
 ZTEST (lifo_usage, test_lifo_nowait)
 Test last in, first out queue using LIFO.
 
 ZTEST (lifo_usage_1cpu, test_lifo_wait)
 Test pending reader in LIFO.
 
 ZTEST (lifo_usage_1cpu, test_timeout_empty_lifo)
 Test reading empty LIFO.
 
 ZTEST (lifo_usage, test_timeout_non_empty_lifo)
 Test read and write operation in LIFO with timeout.
 
 ZTEST (lifo_usage_1cpu, test_timeout_lifo_thread)
 Test LIFO with timeout.
 
 ZTEST (lifo_usage_1cpu, test_timeout_threads_pend_on_lifo)
 Test multiple pending readers in LIFO.
 
static void test_para_init (void)
 Test LIFO initialization with various parameters.
 
void * lifo_usage_setup (void)
 test case main entry
 
 ZTEST_SUITE (lifo_usage_1cpu, NULL, lifo_usage_setup, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 
 ZTEST_SUITE (lifo_usage, NULL, lifo_usage_setup, NULL, NULL, NULL)
 

Variables

struct k_lifo lifo plifo
 
static ldata_t lifo_data [2]
 
struct k_lifo timeout_order_lifo
 
static struct k_thread tdata tdata1
 
static struct k_sem start_sema wait_sema
 
static struct k_lifo lifo_timeout [2]
 
struct timeout_order_data timeout_order_data []
 
struct timeout_order_data timeout_order_data_mult_lifo []
 
struct scratch_lifo_packet scratch_lifo_packets [20]
 
struct k_lifo scratch_lifo_packets_lifo
 
static k_tid_t to_ord_tid [ARRAY_SIZE(timeout_order_data_mult_lifo)]
 
static struct k_thread ttdata [ARRAY_SIZE(timeout_order_data_mult_lifo)]
 

Macro Definition Documentation

◆ LIFO_THREAD_PRIO

#define LIFO_THREAD_PRIO   -5

◆ LIST_LEN

#define LIST_LEN   2

◆ NUM_SCRATCH_LIFO_PACKETS

#define NUM_SCRATCH_LIFO_PACKETS   20

◆ STACK_SIZE

#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ TIMEOUT_ORDER_NUM_THREADS

#define TIMEOUT_ORDER_NUM_THREADS   ARRAY_SIZE(timeout_order_data_mult_lifo)

◆ TSTACK_SIZE

#define TSTACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

Function Documentation

◆ get_scratch_packet()

static void * get_scratch_packet ( void  )
static

◆ is_timeout_in_range()

static bool is_timeout_in_range ( uint32_t  start_time,
uint32_t  timeout 
)
static

◆ K_THREAD_STACK_ARRAY_DEFINE()

static K_THREAD_STACK_ARRAY_DEFINE ( ttstack  ,
ARRAY_SIZE(timeout_order_data_mult_lifo ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)   
)
static

◆ K_THREAD_STACK_DEFINE() [1/2]

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

◆ K_THREAD_STACK_DEFINE() [2/2]

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

◆ lifo_usage_setup()

void * lifo_usage_setup ( void  )

test case main entry

◆ put_scratch_packet()

static void put_scratch_packet ( void *  packet)
static

◆ test_multiple_threads_pending()

static int test_multiple_threads_pending ( struct timeout_order_data test_data,
int  test_data_size 
)
static

◆ thread_entry_nowait()

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

◆ thread_entry_wait()

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

◆ ZTEST_SUITE() [1/2]

ZTEST_SUITE ( lifo_usage  ,
NULL  ,
lifo_usage_setup  ,
NULL  ,
NULL  ,
NULL   
)

◆ ZTEST_SUITE() [2/2]

ZTEST_SUITE ( lifo_usage_1cpu  ,
NULL  ,
lifo_usage_setup  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)

Variable Documentation

◆ lifo_data

ldata_t lifo_data[2]
static

◆ lifo_timeout

struct k_lifo lifo_timeout[2]
static

◆ plifo

struct k_lifo lifo plifo

◆ scratch_lifo_packets

struct scratch_lifo_packet scratch_lifo_packets[20]

◆ scratch_lifo_packets_lifo

struct k_lifo scratch_lifo_packets_lifo

◆ tdata1

struct k_thread tdata tdata1
static

◆ timeout_order_data

Initial value:
= {
{0, &lifo_timeout[0], 200, 2, 0},
{0, &lifo_timeout[0], 400, 4, 1},
{0, &lifo_timeout[0], 0, 0, 2},
{0, &lifo_timeout[0], 100, 1, 3},
{0, &lifo_timeout[0], 300, 3, 4},
}
static struct k_lifo lifo_timeout[2]
Definition main.c:43

◆ timeout_order_data_mult_lifo

struct timeout_order_data timeout_order_data_mult_lifo[]
Initial value:
= {
{0, &lifo_timeout[1], 0, 0, 0},
{0, &lifo_timeout[0], 300, 3, 1},
{0, &lifo_timeout[0], 500, 5, 2},
{0, &lifo_timeout[1], 800, 8, 3},
{0, &lifo_timeout[1], 700, 7, 4},
{0, &lifo_timeout[0], 100, 1, 5},
{0, &lifo_timeout[0], 600, 6, 6},
{0, &lifo_timeout[0], 200, 2, 7},
{0, &lifo_timeout[1], 400, 4, 8},
}

◆ timeout_order_lifo

struct k_lifo timeout_order_lifo

◆ to_ord_tid

◆ ttdata

◆ wait_sema

struct k_sem start_sema wait_sema
static