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

Data Structures

struct  delayed_test_item
 
struct  triggered_test_item
 
struct  triggered_from_msgq_test_item
 

Macros

#define NUM_TEST_ITEMS   6
 
#define WORK_ITEM_WAIT   (CONFIG_TEST_WORK_ITEM_WAIT_MS)
 
#define WORK_ITEM_WAIT_ALIGNED    k_ticks_to_ms_floor64(k_ms_to_ticks_ceil32(WORK_ITEM_WAIT) + _TICK_ALIGN)
 
#define SUBMIT_WAIT   (CONFIG_TEST_SUBMIT_WAIT_MS)
 
#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define CHECK_WAIT   ((NUM_TEST_ITEMS + 1) * WORK_ITEM_WAIT_ALIGNED)
 
#define MSG_PROVIDER_THREAD_STACK_SIZE   0x400U
 
#define MSG_CONSUMER_WORKQ_STACK_SIZE   0x400U
 
#define MSG_PROVIDER_THREAD_PRIO   K_PRIO_PREEMPT(8)
 
#define MSG_CONSUMER_WORKQ_PRIO   K_PRIO_COOP(7)
 
#define MSG_SIZE   16U
 

Functions

 LOG_MODULE_REGISTER (test)
 
static K_THREAD_STACK_DEFINE (co_op_stack,(1024+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (provider_thread_stack, 0x400U)
 
static K_THREAD_STACK_DEFINE (consumer_workq_stack, 0x400U)
 
static void work_handler (struct k_work *work)
 
static void delayed_test_items_init (void)
 
static void reset_results (void)
 
static void coop_work_main (void *p1, void *p2, void *p3)
 
static void delayed_test_items_submit (void)
 
static void check_results (int num_tests)
 
static void test_sequence (void)
 Test work queue items submission sequence.
 
static void resubmit_work_handler (struct k_work *work)
 
 ZTEST (workqueue_triggered, test_resubmit)
 Test work queue item resubmission.
 
static void delayed_work_handler (struct k_work *work)
 
static void test_delayed_init (void)
 Test delayed work queue init.
 
static void coop_delayed_work_main (void *p1, void *p2, void *p3)
 
static void test_delayed_submit (void)
 Test delayed workqueue submit.
 
static void coop_delayed_work_cancel_main (void *p1, void *p2, void *p3)
 
 ZTEST (workqueue_delayed, test_delayed_cancel)
 Test work queue delayed cancel.
 
 ZTEST (workqueue_delayed, test_delayed_pending)
 
 ZTEST (workqueue_delayed, test_delayed)
 Test delayed work items.
 
static void triggered_work_handler (struct k_work *work)
 
static void test_triggered_init (void)
 Test triggered work queue init.
 
static void test_triggered_submit (k_timeout_t timeout)
 Test triggered workqueue submit.
 
static void test_triggered_trigger (void)
 Trigger triggered workqueue execution.
 
 ZTEST (workqueue_triggered, test_triggered)
 Test triggered work items.
 
 ZTEST (workqueue_triggered, test_already_triggered)
 Test already triggered work items.
 
static void triggered_resubmit_work_handler (struct k_work *work)
 
 ZTEST (workqueue_triggered, test_triggered_resubmit)
 Test resubmission of triggered work queue item.
 
 ZTEST (workqueue_triggered, test_triggered_no_wait)
 Test triggered work items with K_NO_WAIT timeout.
 
 ZTEST (workqueue_triggered, test_triggered_no_wait_expired)
 Test expired triggered work items with K_NO_WAIT timeout.
 
 ZTEST (workqueue_triggered, test_triggered_wait)
 Test triggered work items with arbitrary timeout.
 
 ZTEST (workqueue_triggered, test_triggered_wait_expired)
 Test expired triggered work items with arbitrary timeout.
 
static void msg_provider_thread (void *p1, void *p2, void *p3)
 
static void triggered_from_msgq_work_handler (struct k_work *work)
 
static void test_triggered_from_msgq_init (void)
 
static void test_triggered_from_msgq_start (void)
 
 ZTEST (workqueue_triggered, test_triggered_from_msgq)
 Test triggered work item, triggered by a msgq message.
 
 ZTEST (workqueue_triggered, test_delayed_work_define)
 Test delayed work queue define macro.
 
 ZTEST (workqueue_triggered, test_triggered_cancel)
 Verify k_work_poll_cancel()
 
static void * workq_setup (void)
 
 ZTEST_SUITE (workqueue_delayed, NULL, workq_setup, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 
 ZTEST_SUITE (workqueue_triggered, NULL, workq_setup, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 

Variables

static struct k_thread co_op_data
 
static struct delayed_test_item delayed_tests [6]
 
static struct triggered_test_item triggered_tests [6]
 
static int results [6]
 
static int num_results
 
static int expected_poll_result
 
static struct triggered_from_msgq_test_item triggered_from_msgq_test
 

Macro Definition Documentation

◆ CHECK_WAIT

#define CHECK_WAIT   ((NUM_TEST_ITEMS + 1) * WORK_ITEM_WAIT_ALIGNED)

◆ MSG_CONSUMER_WORKQ_PRIO

#define MSG_CONSUMER_WORKQ_PRIO   K_PRIO_COOP(7)

◆ MSG_CONSUMER_WORKQ_STACK_SIZE

#define MSG_CONSUMER_WORKQ_STACK_SIZE   0x400U

◆ MSG_PROVIDER_THREAD_PRIO

#define MSG_PROVIDER_THREAD_PRIO   K_PRIO_PREEMPT(8)

◆ MSG_PROVIDER_THREAD_STACK_SIZE

#define MSG_PROVIDER_THREAD_STACK_SIZE   0x400U

◆ MSG_SIZE

#define MSG_SIZE   16U

◆ NUM_TEST_ITEMS

#define NUM_TEST_ITEMS   6

◆ STACK_SIZE

#define STACK_SIZE   (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ SUBMIT_WAIT

#define SUBMIT_WAIT   (CONFIG_TEST_SUBMIT_WAIT_MS)

◆ WORK_ITEM_WAIT

#define WORK_ITEM_WAIT   (CONFIG_TEST_WORK_ITEM_WAIT_MS)

◆ WORK_ITEM_WAIT_ALIGNED

#define WORK_ITEM_WAIT_ALIGNED    k_ticks_to_ms_floor64(k_ms_to_ticks_ceil32(WORK_ITEM_WAIT) + _TICK_ALIGN)

Function Documentation

◆ check_results()

static void check_results ( int  num_tests)
static

◆ coop_delayed_work_cancel_main()

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

◆ coop_delayed_work_main()

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

◆ coop_work_main()

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

◆ delayed_work_handler()

static void delayed_work_handler ( struct k_work work)
static

◆ K_THREAD_STACK_DEFINE() [1/3]

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

◆ K_THREAD_STACK_DEFINE() [2/3]

static K_THREAD_STACK_DEFINE ( consumer_workq_stack  ,
0x400U   
)
static

◆ K_THREAD_STACK_DEFINE() [3/3]

static K_THREAD_STACK_DEFINE ( provider_thread_stack  ,
0x400U   
)
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( test  )

◆ msg_provider_thread()

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

◆ reset_results()

static void reset_results ( void  )
static

◆ resubmit_work_handler()

static void resubmit_work_handler ( struct k_work work)
static

◆ test_triggered_from_msgq_init()

static void test_triggered_from_msgq_init ( void  )
static

◆ test_triggered_from_msgq_start()

static void test_triggered_from_msgq_start ( void  )
static

◆ triggered_from_msgq_work_handler()

static void triggered_from_msgq_work_handler ( struct k_work work)
static

◆ triggered_resubmit_work_handler()

static void triggered_resubmit_work_handler ( struct k_work work)
static

◆ triggered_work_handler()

static void triggered_work_handler ( struct k_work work)
static

◆ work_handler()

static void work_handler ( struct k_work work)
static

◆ workq_setup()

static void * workq_setup ( void  )
static

◆ ZTEST()

ZTEST ( workqueue_delayed  ,
test_delayed_pending   
)

◆ ZTEST_SUITE() [1/2]

ZTEST_SUITE ( workqueue_delayed  ,
NULL  ,
workq_setup  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)

◆ ZTEST_SUITE() [2/2]

ZTEST_SUITE ( workqueue_triggered  ,
NULL  ,
workq_setup  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)

Variable Documentation

◆ co_op_data

struct k_thread co_op_data
static

◆ delayed_tests

struct delayed_test_item delayed_tests[6]
static

◆ expected_poll_result

int expected_poll_result
static

◆ num_results

int num_results
static

◆ results

int results[6]
static

◆ triggered_from_msgq_test

struct triggered_from_msgq_test_item triggered_from_msgq_test
static

◆ triggered_tests

struct triggered_test_item triggered_tests[6]
static