Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
main.c File Reference
#include <zephyr/ztest.h>
#include <zephyr/kernel_structs.h>
#include <zephyr/kernel.h>
#include <kernel_internal.h>
#include <string.h>
#include <ksched.h>
#include <kthread.h>
#include <zephyr/logging/log.h>

Macros

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)
 
#define JOIN_TIMEOUT_MS   100
 
#define WAIT_TO_START_MS   100
 
#define INT_ARRAY_SIZE   128
 

Enumerations

enum  control_method {
  TIMEOUT , NO_WAIT , SELF_ABORT , OTHER_ABORT ,
  OTHER_ABORT_TIMEOUT , ALREADY_EXIT , ISR_ALREADY_EXIT , ISR_RUNNING
}
 

Functions

 LOG_MODULE_REGISTER (test)
 
 K_THREAD_STACK_DEFINE (tstack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack_custom,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static K_THREAD_STACK_DEFINE (tstack_name,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
 ZTEST (threads_lifecycle, test_systhreads_main)
 Verify main thread.
 
 ZTEST (threads_lifecycle, test_systhreads_idle)
 Verify idle thread.
 
static void customdata_entry (void *p1, void *p2, void *p3)
 
 ZTEST (threads_lifecycle_1cpu, test_customdata_get_set_coop)
 test thread custom data get/set from coop thread
 
static void thread_name_entry (void *p1, void *p2, void *p3)
 
 ZTEST (threads_lifecycle, test_thread_name_get_set)
 test thread name get/set from supervisor thread
 
 ZTEST_USER (threads_lifecycle, test_thread_name_user_get_set)
 test thread name get/set from user thread
 
 ZTEST_USER (threads_lifecycle_1cpu, test_customdata_get_set_preempt)
 test thread custom data get/set from preempt thread
 
static void umode_entry (void *thread_id, void *p2, void *p3)
 
static void enter_user_mode_entry (void *p1, void *p2, void *p3)
 Test k_thread_user_mode_enter() to cover when userspace is not supported/enabled.
 
 ZTEST_USER (threads_lifecycle, test_user_mode)
 
 K_THREAD_STACK_DEFINE (join_stack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
 K_THREAD_STACK_DEFINE (control_stack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void join_entry (void *p1, void *p2, void *p3)
 
static void control_entry (void *p1, void *p2, void *p3)
 
static void do_join_from_isr (const void *arg)
 
static int join_scenario_interval (enum control_method m, int64_t *interval)
 
static int join_scenario (enum control_method m)
 
 ZTEST_USER (threads_lifecycle, test_thread_join)
 
 ZTEST (threads_lifecycle, test_thread_join_isr)
 
 K_THREAD_STACK_DEFINE (deadlock1_stack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
 K_THREAD_STACK_DEFINE (deadlock2_stack,(512+CONFIG_TEST_EXTRA_STACK_SIZE))
 
static void deadlock1_entry (void *p1, void *p2, void *p3)
 
static void deadlock2_entry (void *p1, void *p2, void *p3)
 
 ZTEST_USER (threads_lifecycle, test_thread_join_deadlock)
 
static void user_start_thread (void *p1, void *p2, void *p3)
 
 ZTEST_USER (threads_lifecycle, test_thread_timeout_remaining_expires)
 
static void foreach_callback (const struct k_thread *thread, void *user_data)
 
 ZTEST (threads_lifecycle, test_thread_runtime_stats_get)
 
 ZTEST (threads_lifecycle, test_k_busy_wait)
 
static void tp_entry (void *p1, void *p2, void *p3)
 
 ZTEST_USER (threads_lifecycle_1cpu, test_k_busy_wait_user)
 
static int large_stack (size_t *space)
 
static int small_stack (size_t *space)
 
 ZTEST_USER (threads_lifecycle, test_k_thread_stack_space_get_user)
 
static void * thread_test_setup (void)
 
 ZTEST_SUITE (threads_lifecycle, NULL, thread_test_setup, NULL, NULL, NULL)
 
 ZTEST_SUITE (threads_lifecycle_1cpu, NULL, thread_test_setup, ztest_simple_1cpu_before, ztest_simple_1cpu_after, NULL)
 

Variables

struct k_thread tdata
 
size_t tstack_size = K_THREAD_STACK_SIZEOF(tstack)
 
static struct k_thread tdata_custom
 
static struct k_thread tdata_name
 
static int main_prio
 
static ZTEST_DMEM int tp = 10
 
static char unreadable_string [64]
 
static char not_my_buffer [CONFIG_THREAD_MAX_NAME_LEN]
 
struct k_sem sem
 
struct k_thread join_thread
 
struct k_thread control_thread
 
struct k_thread deadlock1_thread
 
struct k_thread deadlock2_thread
 

Macro Definition Documentation

◆ INT_ARRAY_SIZE

#define INT_ARRAY_SIZE   128

◆ JOIN_TIMEOUT_MS

#define JOIN_TIMEOUT_MS   100

◆ STACK_SIZE

#define STACK_SIZE   (512 + CONFIG_TEST_EXTRA_STACK_SIZE)

◆ WAIT_TO_START_MS

#define WAIT_TO_START_MS   100

Enumeration Type Documentation

◆ control_method

Enumerator
TIMEOUT 
NO_WAIT 
SELF_ABORT 
OTHER_ABORT 
OTHER_ABORT_TIMEOUT 
ALREADY_EXIT 
ISR_ALREADY_EXIT 
ISR_RUNNING 

Function Documentation

◆ control_entry()

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

◆ customdata_entry()

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

TESTPOINT: custom data comparison

◆ deadlock1_entry()

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

◆ deadlock2_entry()

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

◆ do_join_from_isr()

static void do_join_from_isr ( const void *  arg)
static

◆ foreach_callback()

static void foreach_callback ( const struct k_thread thread,
void *  user_data 
)
static

◆ join_entry()

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

◆ join_scenario()

static int join_scenario ( enum control_method  m)
inlinestatic

◆ join_scenario_interval()

static int join_scenario_interval ( enum control_method  m,
int64_t interval 
)
static

◆ K_THREAD_STACK_DEFINE() [1/7]

K_THREAD_STACK_DEFINE ( control_stack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ K_THREAD_STACK_DEFINE() [2/7]

K_THREAD_STACK_DEFINE ( deadlock1_stack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ K_THREAD_STACK_DEFINE() [3/7]

K_THREAD_STACK_DEFINE ( deadlock2_stack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ K_THREAD_STACK_DEFINE() [4/7]

K_THREAD_STACK_DEFINE ( join_stack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ K_THREAD_STACK_DEFINE() [5/7]

K_THREAD_STACK_DEFINE ( tstack  ,
(512+CONFIG_TEST_EXTRA_STACK_SIZE)   
)

◆ K_THREAD_STACK_DEFINE() [6/7]

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

◆ K_THREAD_STACK_DEFINE() [7/7]

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

◆ large_stack()

static int large_stack ( size_t space)
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( test  )

◆ small_stack()

static int small_stack ( size_t space)
static

◆ thread_name_entry()

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

◆ thread_test_setup()

static void * thread_test_setup ( void  )
static

◆ tp_entry()

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

◆ umode_entry()

static void umode_entry ( void *  thread_id,
void *  p2,
void *  p3 
)
static

◆ user_start_thread()

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

◆ ZTEST() [1/3]

ZTEST ( threads_lifecycle  ,
test_k_busy_wait   
)

◆ ZTEST() [2/3]

ZTEST ( threads_lifecycle  ,
test_thread_join_isr   
)

◆ ZTEST() [3/3]

ZTEST ( threads_lifecycle  ,
test_thread_runtime_stats_get   
)

◆ ZTEST_SUITE() [1/2]

ZTEST_SUITE ( threads_lifecycle  ,
NULL  ,
thread_test_setup  ,
NULL  ,
NULL  ,
NULL   
)

◆ ZTEST_SUITE() [2/2]

ZTEST_SUITE ( threads_lifecycle_1cpu  ,
NULL  ,
thread_test_setup  ,
ztest_simple_1cpu_before  ,
ztest_simple_1cpu_after  ,
NULL   
)

◆ ZTEST_USER() [1/6]

ZTEST_USER ( threads_lifecycle  ,
test_k_thread_stack_space_get_user   
)

◆ ZTEST_USER() [2/6]

ZTEST_USER ( threads_lifecycle  ,
test_thread_join   
)

◆ ZTEST_USER() [3/6]

ZTEST_USER ( threads_lifecycle  ,
test_thread_join_deadlock   
)

◆ ZTEST_USER() [4/6]

ZTEST_USER ( threads_lifecycle  ,
test_thread_timeout_remaining_expires   
)

◆ ZTEST_USER() [5/6]

ZTEST_USER ( threads_lifecycle  ,
test_user_mode   
)

◆ ZTEST_USER() [6/6]

ZTEST_USER ( threads_lifecycle_1cpu  ,
test_k_busy_wait_user   
)

Variable Documentation

◆ control_thread

struct k_thread control_thread

◆ deadlock1_thread

struct k_thread deadlock1_thread

◆ deadlock2_thread

struct k_thread deadlock2_thread

◆ join_thread

struct k_thread join_thread

◆ main_prio

int main_prio
static

◆ not_my_buffer

char not_my_buffer[CONFIG_THREAD_MAX_NAME_LEN]
static

◆ sem

struct k_sem sem

◆ tdata

struct k_thread tdata

◆ tdata_custom

struct k_thread tdata_custom
static

◆ tdata_name

struct k_thread tdata_name
static

◆ tp

ZTEST_DMEM int tp = 10
static

◆ tstack_size

◆ unreadable_string

char unreadable_string[64]
static