Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Thread Tests. More...
Functions | |
static void | test_dyn_thread_perms (void) |
Test object permission on dynamic user thread when index is reused. More... | |
static void | test_kernel_create_dyn_user_thread (void) |
Test creation of dynamic user thread under kernel thread. More... | |
static void | test_user_create_dyn_user_thread (void) |
Test creation of dynamic user thread under user thread. More... | |
void | test_systhreads_main (void) |
Verify main thread. More... | |
void | test_systhreads_idle (void) |
Verify idle thread. More... | |
void | test_customdata_get_set_coop (void) |
test thread custom data get/set from coop thread More... | |
void | test_thread_name_get_set (void) |
test thread name get/set from supervisor thread More... | |
void | test_thread_name_user_get_set (void) |
test thread name get/set from user thread More... | |
void | test_customdata_get_set_preempt (void) |
test thread custom data get/set from preempt thread More... | |
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. More... | |
void | test_essential_thread_operation (void) |
Test to validate essential flag set/clear. More... | |
void | test_essential_thread_abort (void) |
Abort an essential thread. More... | |
void | test_k_thread_foreach (void) |
Test k_thread_foreach API. More... | |
void | test_k_thread_foreach_unlocked (void) |
Test k_thread_foreach_unlock API. More... | |
void | test_k_thread_foreach_null_cb (void) |
Test k_thread_foreach API with null callback. More... | |
void | test_k_thread_foreach_unlocked_null_cb (void) |
Test k_thread_foreach_unlocked API with null callback. More... | |
void | test_k_thread_state_str (void) |
Test k_thread_state_str API with null callback. More... | |
void | test_threads_abort_self (void) |
Validate k_thread_abort() when called by current thread. More... | |
void | test_threads_abort_others (void) |
Validate k_thread_abort() when called by other thread. More... | |
void | test_threads_abort_repeat (void) |
Test abort on a terminated thread. More... | |
void | test_delayed_thread_abort (void) |
Test abort on delayed thread before it has started execution. More... | |
void | test_abort_from_isr (void) |
Show that threads can be aborted from interrupt context by itself. More... | |
void | test_abort_from_isr_not_self (void) |
Show that threads can be aborted from interrupt context. More... | |
void | test_threads_priority_set (void) |
Test the k_thread_priority_set() API. More... | |
void | test_threads_spawn_params (void) |
Check the parameters passed to thread entry function. More... | |
void | test_threads_spawn_priority (void) |
Spawn thread with higher priority. More... | |
void | test_threads_spawn_delay (void) |
Spawn thread with a delay. More... | |
void | test_threads_spawn_forever (void) |
Spawn thread with forever delay and highest priority. More... | |
void | test_thread_start (void) |
Validate behavior of multiple calls to k_thread_start() More... | |
void | test_threads_suspend_resume_cooperative (void) |
Check the suspend and resume functionality in a cooperative thread. More... | |
void | test_threads_suspend_resume_preemptible (void) |
Check the suspend and resume functionality in preemptive thread. More... | |
void | test_threads_suspend (void) |
Check that k_thread_suspend() is a schedule point when called on the current thread. More... | |
void | test_threads_suspend_timeout (void) |
Check that k_thread_suspend() cancels a preexisting thread timeout. More... | |
void | test_resume_unsuspend_thread (void) |
Check resume an unsuspend thread. More... | |
void | test_kdefine_preempt_thread (void) |
test preempt thread initialization via K_THREAD_DEFINE More... | |
void | test_kdefine_coop_thread (void) |
test coop thread initialization via K_THREAD_DEFINE More... | |
void | test_kinit_preempt_thread (void) |
test preempt thread initialization via k_thread_create More... | |
void | test_kinit_coop_thread (void) |
test coop thread initialization via k_thread_create More... | |
Thread Tests.
#include <tests/kernel/threads/thread_apis/src/main.c>
Test k_thread_user_mode_enter() to cover when userspace is not supported/enabled.
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Show that threads can be aborted from interrupt context by itself.
Spwan a thread, then enter ISR context in child thread and abort the child thread. Check if ISR completed and target thread was aborted.
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Show that threads can be aborted from interrupt context.
Spwan a thread, then enter ISR context in main thread and abort the child thread. Check if ISR completed and target thread was aborted.
#include <tests/kernel/threads/thread_apis/src/main.c>
test thread custom data get/set from coop thread
#include <tests/kernel/threads/thread_apis/src/main.c>
test thread custom data get/set from preempt thread
TESTPOINT: custom data of preempt thread
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Test abort on delayed thread before it has started execution.
#include <tests/kernel/threads/dynamic_thread/src/main.c>
Test object permission on dynamic user thread when index is reused.
This creates one dynamic thread with permissions to both semaphores so there is no fault. Then a new thread is created and will be re-using the thread index in first pass. Except the second thread does not have permission to one of the semaphore. If permissions are cleared correctly when thread is destroyed, the second should raise kernel oops.
#include <tests/kernel/threads/thread_apis/src/test_essential_thread.c>
Abort an essential thread.
The kernel shall raise a fatal system error if an essential thread aborts, implement k_sys_fatal_error_handler to handle this error.
#include <tests/kernel/threads/thread_apis/src/test_essential_thread.c>
Test to validate essential flag set/clear.
#include <tests/kernel/threads/thread_apis/src/test_kthread_for_each.c>
Test k_thread_foreach API.
Call k_thread_foreach() at the beginning of the test and call it again after creating a thread, See k_thread_foreach() iterates over the newly created thread and calls the user passed callback function.
#include <tests/kernel/threads/thread_apis/src/test_kthread_for_each.c>
Test k_thread_foreach API with null callback.
Call k_thread_foreach() with null callback will triger __ASSERT() and this test thread will be aborted by z_fatal_error()
#include <tests/kernel/threads/thread_apis/src/test_kthread_for_each.c>
Test k_thread_foreach_unlock API.
Call k_thread_foreach_unlocked() at the beginning of the test and call it again after creating a thread, See k_thread_foreach_unlocked() iterates over the newly created thread and calls the user passed callback function. In contrast to k_thread_foreach(), k_thread_foreach_unlocked() allow callback function created or abort threads
#include <tests/kernel/threads/thread_apis/src/test_kthread_for_each.c>
Test k_thread_foreach_unlocked API with null callback.
Call k_thread_foreach_unlocked() with null callback will triger __ASSERT() and this test thread will be aborted by z_fatal_error()
#include <tests/kernel/threads/thread_apis/src/test_kthread_for_each.c>
Test k_thread_state_str API with null callback.
It's impossible to sched a thread step by step manually to experence each state from _THREAD_PRESTART to _THREAD_DEAD. To cover each line of function k_thread_state_str(), set thread_state of tdata1 and check the string this function returns
#include <tests/kernel/threads/thread_init/src/main.c>
test coop thread initialization via K_THREAD_DEFINE
#include <tests/kernel/threads/thread_init/src/main.c>
test preempt thread initialization via K_THREAD_DEFINE
#include <tests/kernel/threads/dynamic_thread/src/main.c>
Test creation of dynamic user thread under kernel thread.
This is a simple test to create a user thread dynamically via k_object_alloc() under a kernel thread.
#include <tests/kernel/threads/thread_init/src/main.c>
test coop thread initialization via k_thread_create
#include <tests/kernel/threads/thread_init/src/main.c>
test preempt thread initialization via k_thread_create
#include <tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c>
Check resume an unsuspend thread.
Use k_thread_state_str() to get thread state. Resume an unsuspend thread will not change the thread state.
#include <tests/kernel/threads/thread_apis/src/main.c>
Verify idle thread.
TESTPOINT: check working thread priority should
#include <tests/kernel/threads/thread_apis/src/main.c>
Verify main thread.
#include <tests/kernel/threads/thread_apis/src/main.c>
test thread name get/set from supervisor thread
#include <tests/kernel/threads/thread_apis/src/main.c>
test thread name get/set from user thread
#include <tests/kernel/threads/thread_apis/src/test_threads_spawn.c>
Validate behavior of multiple calls to k_thread_start()
Call k_thread_start() on an already terminated thread
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Validate k_thread_abort() when called by other thread.
Create a user thread and abort the thread before its execution. Create a another user thread and abort the thread after it has started.
TESTPOINT: check not-started thread is aborted
TESTPOINT: check running thread is aborted
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Test abort on a terminated thread.
#include <tests/kernel/threads/thread_apis/src/test_threads_cancel_abort.c>
Validate k_thread_abort() when called by current thread.
Create a user thread and let the thread execute. Then call k_thread_abort() and check if the thread is terminated. Here the main thread is also a user thread.
TESTPOINT: spawned thread executed but abort itself
#include <tests/kernel/threads/thread_apis/src/test_threads_set_priority.c>
Test the k_thread_priority_set() API.
#include <tests/kernel/threads/thread_apis/src/test_threads_spawn.c>
Spawn thread with a delay.
Create a user thread with delay and check if the thread entry function is executed only after the timeout occurs.
#include <tests/kernel/threads/thread_apis/src/test_threads_spawn.c>
Spawn thread with forever delay and highest priority.
Create an user thread with forever delay and yield the current thread. Even though the current thread has yielded, the thread will not be put in ready queue since it has forever delay, the thread is explicitly started using k_thread_start() and checked if thread has started executing.
#include <tests/kernel/threads/thread_apis/src/test_threads_spawn.c>
Check the parameters passed to thread entry function.
Create an user thread and pass 2 variables and a semaphore to a thread entry function. Check for the correctness of the parameters passed.
#include <tests/kernel/threads/thread_apis/src/test_threads_spawn.c>
Spawn thread with higher priority.
Create an user thread with priority greater than current thread and check its behavior.
#include <tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c>
Check that k_thread_suspend() is a schedule point when called on the current thread.
#include <tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c>
Check the suspend and resume functionality in a cooperative thread.
Create a thread with the priority lower than the current thread which is cooperative and suspend it, make sure it doesn't gets scheduled, and resume and check if the entry function is executed.
#include <tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c>
Check the suspend and resume functionality in preemptive thread.
Create a thread with the priority lower than the current thread which is preemptive and suspend it, make sure it doesn't gets scheduled, and resume and check if the entry function is executed.
#include <tests/kernel/threads/thread_apis/src/test_threads_suspend_resume.c>
Check that k_thread_suspend() cancels a preexisting thread timeout.
Suspended threads should not wake up unexpectedly if they happened to have been sleeping when suspended.
#include <tests/kernel/threads/dynamic_thread/src/main.c>
Test creation of dynamic user thread under user thread.
This is a simple test to create a user thread dynamically via k_object_alloc() under a user thread.