#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:
Test Procedure:
- In main thread, call arch_curr_cpu() to get it's member "id",then store it into a variable thread_id.
- 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.
- In thread t2, call arch_curr_cpu() to get pointer of current cpu data. Then check if it not NULL.
- Store the member id via accessing pointer of current cpu data to var cpu_id.
- Check if cpu_id is not equaled to bsp_id that we pass into thread.
- Call k_busy_wait() and loop forever.
- 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()