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

Data Structures

struct  fifo_data
 
struct  lifo_data
 
struct  offload_work
 

Macros

#define NUM_SECONDS(x)   ((x) * 1000)
 
#define HALF_SECOND   (500)
 
#define THIRD_SECOND   (333)
 
#define FOURTH_SECOND   (250)
 
#define COOP_STACKSIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define PREEM_STACKSIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define FIFO_TEST_START   10
 
#define FIFO_TEST_END   20
 
#define SEM_TEST_START   30
 
#define SEM_TEST_END   40
 
#define LIFO_TEST_START   50
 
#define LIFO_TEST_END   60
 
#define NON_NULL_PTR   ((void *)0x12345678)
 
#define OFFLOAD_WORKQUEUE_STACK_SIZE   1024
 
#define OFFLOAD_WORKQUEUE_PRIORITY   (-1)
 

Functions

static K_THREAD_STACK_DEFINE (offload_work_q_stack, 1024)
 
static K_THREAD_STACK_ARRAY_DEFINE (coop_stack, 2,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void * my_fifo_get (struct k_fifo *my_fifo, int32_t timeout)
 
static void * my_lifo_get (struct k_lifo *my_lifo, int32_t timeout)
 
static int increment_counter (void)
 
static void sync_threads (struct k_work *work)
 
static void fifo_tests (int32_t timeout, volatile int *state, void *(*get)(struct k_fifo *, int32_t), int(*sem_take)(struct k_sem *, k_timeout_t))
 
static void lifo_tests (int32_t timeout, volatile int *state, void *(*get)(struct k_lifo *, int32_t), int(*sem_take)(struct k_sem *, k_timeout_t))
 
static void timer_tests (void)
 
static void coop_high (void *arg1, void *arg2, void *arg3)
 
static void coop_low (void *arg1, void *arg2, void *arg3)
 
void task_high (void)
 
void task_low (void)
 
 ZTEST (pending, test_pending_fifo)
 Test pending of workq, fifo and lifo.
 
 ZTEST (pending, test_pending_lifo)
 
 ZTEST (pending, test_pending_timer)
 
 K_THREAD_DEFINE (TASK_LOW,(1024+CONFIG_TEST_EXTRA_STACK_SIZE), task_low, NULL, NULL, NULL, 7, 0, 0)
 
 K_THREAD_DEFINE (TASK_HIGH,(1024+CONFIG_TEST_EXTRA_STACK_SIZE), task_high, NULL, NULL, NULL, 5, 0, 0)
 
 ZTEST_SUITE (pending, NULL, NULL, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 

Variables

static struct k_work_q offload_work_q
 
static struct k_thread coop_thread [2]
 
static struct k_fifo fifo
 
static struct k_lifo lifo
 
static struct k_timer timer
 
static struct k_sem start_test_sem
 
static struct k_sem sync_test_sem
 
static struct k_sem end_test_sem
 
struct fifo_data fifo_test_data [4]
 
struct lifo_data lifo_test_data [4]
 
static uint32_t timer_start_tick
 
static uint32_t timer_end_tick
 
static void * timer_data
 
static int __noinit coop_high_state
 
static int __noinit coop_low_state
 
static int __noinit task_high_state
 
static int __noinit task_low_state
 
static int __noinit counter
 

Macro Definition Documentation

◆ COOP_STACKSIZE

#define COOP_STACKSIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ FIFO_TEST_END

#define FIFO_TEST_END   20

◆ FIFO_TEST_START

#define FIFO_TEST_START   10

◆ FOURTH_SECOND

#define FOURTH_SECOND   (250)

◆ HALF_SECOND

#define HALF_SECOND   (500)

◆ LIFO_TEST_END

#define LIFO_TEST_END   60

◆ LIFO_TEST_START

#define LIFO_TEST_START   50

◆ NON_NULL_PTR

#define NON_NULL_PTR   ((void *)0x12345678)

◆ NUM_SECONDS

#define NUM_SECONDS (   x)    ((x) * 1000)

◆ OFFLOAD_WORKQUEUE_PRIORITY

#define OFFLOAD_WORKQUEUE_PRIORITY   (-1)

◆ OFFLOAD_WORKQUEUE_STACK_SIZE

#define OFFLOAD_WORKQUEUE_STACK_SIZE   1024

◆ PREEM_STACKSIZE

#define PREEM_STACKSIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ SEM_TEST_END

#define SEM_TEST_END   40

◆ SEM_TEST_START

#define SEM_TEST_START   30

◆ THIRD_SECOND

#define THIRD_SECOND   (333)

Function Documentation

◆ coop_high()

static void coop_high ( void *  arg1,
void *  arg2,
void *  arg3 
)
static

◆ coop_low()

static void coop_low ( void *  arg1,
void *  arg2,
void *  arg3 
)
static

◆ fifo_tests()

static void fifo_tests ( int32_t  timeout,
volatile int *  state,
void *(*)(struct k_fifo *, int32_t get,
int(*)(struct k_sem *, k_timeout_t sem_take 
)
static

◆ increment_counter()

static int increment_counter ( void  )
static

◆ K_THREAD_DEFINE() [1/2]

K_THREAD_DEFINE ( TASK_HIGH  ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)  ,
task_high  ,
NULL  ,
NULL  ,
NULL  ,
,
,
 
)

◆ K_THREAD_DEFINE() [2/2]

K_THREAD_DEFINE ( TASK_LOW  ,
(1024+CONFIG_TEST_EXTRA_STACK_SIZE)  ,
task_low  ,
NULL  ,
NULL  ,
NULL  ,
,
,
 
)

◆ K_THREAD_STACK_ARRAY_DEFINE()

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

◆ K_THREAD_STACK_DEFINE()

static K_THREAD_STACK_DEFINE ( offload_work_q_stack  ,
1024   
)
static

◆ lifo_tests()

static void lifo_tests ( int32_t  timeout,
volatile int *  state,
void *(*)(struct k_lifo *, int32_t get,
int(*)(struct k_sem *, k_timeout_t sem_take 
)
static

◆ my_fifo_get()

static void * my_fifo_get ( struct k_fifo my_fifo,
int32_t  timeout 
)
inlinestatic

◆ my_lifo_get()

static void * my_lifo_get ( struct k_lifo my_lifo,
int32_t  timeout 
)
inlinestatic

◆ sync_threads()

static void sync_threads ( struct k_work work)
static

◆ task_high()

void task_high ( void  )

◆ task_low()

void task_low ( void  )

◆ timer_tests()

static void timer_tests ( void  )
static

◆ ZTEST_SUITE()

ZTEST_SUITE ( pending  ,
NULL  ,
NULL  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)

Variable Documentation

◆ coop_high_state

int __noinit coop_high_state
static

◆ coop_low_state

int __noinit coop_low_state
static

◆ coop_thread

struct k_thread coop_thread[2]
static

◆ counter

int __noinit counter
static

◆ end_test_sem

struct k_sem end_test_sem
static

◆ fifo

struct k_fifo fifo
static

◆ fifo_test_data

struct fifo_data fifo_test_data[4]
Initial value:
= {
{ 0, 20 + 1 }, { 0, 20 + 2 },
{ 0, 20 + 3 }, { 0, 20 + 4 }
}

◆ lifo

struct k_lifo lifo
static

◆ lifo_test_data

struct lifo_data lifo_test_data[4]
Initial value:
= {
{ 0, 60 + 1 }, { 0, 60 + 2 },
{ 0, 60 + 3 }, { 0, 60 + 4 }
}

◆ offload_work_q

struct k_work_q offload_work_q
static

◆ start_test_sem

struct k_sem start_test_sem
static

◆ sync_test_sem

struct k_sem sync_test_sem
static

◆ task_high_state

int __noinit task_high_state
static

◆ task_low_state

int __noinit task_low_state
static

◆ timer

struct k_timer timer
static

◆ timer_data

void* timer_data
static

◆ timer_end_tick

uint32_t timer_end_tick
static

◆ timer_start_tick

uint32_t timer_start_tick
static