Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
SMP Tests

Functions

void test_get_cpu (void)
 Test get a pointer of CPU. More...
 

Detailed Description

Function Documentation

◆ test_get_cpu()

void test_get_cpu ( void  )

#include <tests/kernel/smp/src/main.c>

Test get a pointer of CPU.

Test Objective:

  • To verify architecture layer provides a mechanism to return a pointer to the current kernel CPU record of the running CPU. We call arch_curr_cpu() and get it's member, both in main and spwaned thread speratively, and compare them. They shall be different in SMP enviornment.

Testing techniques:

  • Interface testing, function and block box testing, dynamic analysis and testing,

Prerequisite Conditions:

  • CONFIG_SMP=y, and the HW platform must support SMP.

Input Specifications:

  • N/A

Test Procedure:

  1. In main thread, call arch_curr_cpu() to get it's member "id",then store it into a variable thread_id.
  2. Spawn a thread t2, and pass the stored thread_id to it, then call k_busy_wait() 50us to wait for thread run and won't be swapped out.
  3. In thread t2, call arch_curr_cpu() to get pointer of current cpu data. Then check if it not NULL.
  4. Store the member id via accessing pointer of current cpu data to var cpu_id.
  5. Check if cpu_id is not equaled to bsp_id that we pass into thread.
  6. Call k_busy_wait() and loop forever.
  7. In main thread, terminate the thread t2 before exit.

Expected Test Result:

  • The pointer of current cpu data that we got from function call is correct.

Pass/Fail Criteria:

  • Successful if the check of step 3,5 are all passed.
  • Failure if one of the check of step 3,5 is failed.

Assumptions and Constraints:

  • This test using for the platform that support SMP, in our current scenario , only x86_64, arc and xtensa supported.
See also
arch_curr_cpu()