Zephyr Project API  3.1.0
A Scalable Open Source RTOS
test_thread_runtime_stats.c File Reference
#include <ztest.h>

Macros

#define HELPER_STACK_SIZE   500
 
#define TEST_WITHIN_X_PERCENT(val1, val2, pcnt)
 Verify va1 and val2 are within pcnt % of each other. More...
 

Functions

static K_THREAD_STACK_DEFINE (helper_stack, 500)
 
void helper1 (void *p1, void *p2, void *p3)
 Helper thread to test_thread_runtime_stats_get() More...
 
void busy_loop (uint32_t ticks)
 Busy wait for specified number of ticks. More...
 
void test_all_stats_usage (void)
 Test the k_threads_runtime_stats_all_get() API. More...
 
void test_thread_stats_enable_disable (void)
 
void test_sys_stats_enable_disable (void)
 
void resume_main (struct k_timer *timer)
 Timer handler to resume the main thread. More...
 
void test_thread_stats_usage (void)
 Test the k_thread_runtime_stats_get() API. More...
 
void test_main (void)
 
  • main entry point for thread runtime statistics (usage) test
More...
 

Variables

static struct k_thread helper_thread
 
static struct k_threadmain_thread
 

Macro Definition Documentation

◆ HELPER_STACK_SIZE

#define HELPER_STACK_SIZE   500

◆ TEST_WITHIN_X_PERCENT

#define TEST_WITHIN_X_PERCENT (   val1,
  val2,
  pcnt 
)
Value:
((((val1) * 100) < ((val2) * (100 + (pcnt)))) && \
(((val1) * 100) > ((val2) * (100 - (pcnt))))) ? true : false
#define false
Definition: stdbool.h:15

Verify va1 and val2 are within pcnt % of each other.

Function Documentation

◆ busy_loop()

void busy_loop ( uint32_t  ticks)

Busy wait for specified number of ticks.

◆ helper1()

void helper1 ( void *  p1,
void *  p2,
void *  p3 
)

◆ K_THREAD_STACK_DEFINE()

static K_THREAD_STACK_DEFINE ( helper_stack  ,
500   
)
static

◆ resume_main()

void resume_main ( struct k_timer *  timer)

Timer handler to resume the main thread.

◆ test_all_stats_usage()

void test_all_stats_usage ( void  )

Test the k_threads_runtime_stats_all_get() API.

  1. Create a helper thread.
  2. Busy loop for 2 ticks.
    • Idle time should not increase.
  3. Sleep for two ticks. Helper executes and busy loops.
    • Idle time should not increase
  4. Kill helper thread, and sleep for 2 ticks
    • Idle time should increase
  5. Busy loop for 3 ticks
    • Idle time should not increase
    • current, peak and average cycles should be different

◆ test_main()

void test_main ( void  )

  • main entry point for thread runtime statistics (usage) test

test case main entry

◆ test_sys_stats_enable_disable()

void test_sys_stats_enable_disable ( void  )

◆ test_thread_stats_enable_disable()

void test_thread_stats_enable_disable ( void  )

◆ test_thread_stats_usage()

void test_thread_stats_usage ( void  )

Test the k_thread_runtime_stats_get() API.

This routine tests the k_thread_runtime_stats_get() routine. It verifies that the contents of the fields guarded by CONFIG_SCHED_THREAD_USAGE are correct.

Variable Documentation

◆ helper_thread

struct k_thread helper_thread ( void  )
static

◆ main_thread

struct k_thread* main_thread
static