TianoCore EDK2 master
Loading...
Searching...
No Matches
EfiMpServicesUnitTestCommom.c File Reference

Go to the source code of this file.

Functions

UNIT_TEST_STATUS EFIAPI InitUTContext (IN UNIT_TEST_CONTEXT Context)
 
VOID EFIAPI CheckUTContext (IN UNIT_TEST_CONTEXT Context)
 
VOID EFIAPI FreeUTContext (IN UNIT_TEST_CONTEXT Context)
 
VOID StoreCpuNumbers (IN OUT VOID *Buffer)
 
VOID StoreAPsExecutionOrder (IN OUT VOID *Buffer)
 
VOID InfiniteLoopProcedure (IN OUT VOID *Buffer)
 
VOID EmptyProcedure (IN OUT VOID *Buffer)
 
VOID RunMpServiceGetNumberOfProcessorsOnAp (IN OUT VOID *Buffer)
 
VOID RunMpServiceGetProcessorInfoOnAp (IN OUT VOID *Buffer)
 
VOID RunMpServiceEnableDisableAPOnAp (IN OUT VOID *Buffer)
 
VOID RunMpServiceStartupThisAPOnAp (IN OUT VOID *Buffer)
 
VOID RunMpServiceStartupAllAPsOnAp (IN OUT VOID *Buffer)
 
VOID RunMpServiceSwitchBSPOnAp (IN OUT VOID *Buffer)
 
UNIT_TEST_STATUS EFIAPI TestWhoAmI1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors3 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP3 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupThisAP1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupThisAP2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupThisAP3 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupThisAP4 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs3 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs4 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs5 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSwitchBSP1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSwitchBSP2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSwitchBSP3 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestSwitchBSP4 (IN UNIT_TEST_CONTEXT Context)
 
EFI_STATUS AddCommonTestCase (IN UNIT_TEST_FRAMEWORK_HANDLE Framework, IN MP_SERVICE_UT_CONTEXT *Context)
 

Detailed Description

Common code to test EdkiiPeiMpServices2Ppi and EfiMpServiceProtocol.

Copyright (c) 2022, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EfiMpServicesUnitTestCommom.c.

Function Documentation

◆ AddCommonTestCase()

EFI_STATUS AddCommonTestCase ( IN UNIT_TEST_FRAMEWORK_HANDLE  Framework,
IN MP_SERVICE_UT_CONTEXT Context 
)

Create test suite and unit tests for both EdkiiPeiMpServices2Ppi and EfiMpServiceProtocol.

Parameters
[in]FrameworkA pointer to the framework that is being persisted.
[in]ContextA pointer to the private data buffer.
Return values
EFI_SUCCESSCreate test suite and unit tests successfully.
OthersCreate test suite and unit tests unsuccessfully.

Definition at line 1661 of file EfiMpServicesUnitTestCommom.c.

◆ CheckUTContext()

VOID EFIAPI CheckUTContext ( IN UNIT_TEST_CONTEXT  Context)

Cleanup routine for Unit test function. If any processor is disabled unexpectedly then reenable it.

Parameters
[in]ContextContext pointer for this test.

Definition at line 117 of file EfiMpServicesUnitTestCommom.c.

◆ EmptyProcedure()

VOID EmptyProcedure ( IN OUT VOID *  Buffer)

Empty procedure to be run on specified CPU.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 311 of file EfiMpServicesUnitTestCommom.c.

◆ FreeUTContext()

VOID EFIAPI FreeUTContext ( IN UNIT_TEST_CONTEXT  Context)

Cleanup routine for Unit test function. It will be called by the last "AddTestCase" to restore AP state and free pointer.

Parameters
[in]ContextContext pointer for this test.

Definition at line 187 of file EfiMpServicesUnitTestCommom.c.

◆ InfiniteLoopProcedure()

VOID InfiniteLoopProcedure ( IN OUT VOID *  Buffer)

Infinite loop procedure to be run on specified CPU.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 293 of file EfiMpServicesUnitTestCommom.c.

◆ InitUTContext()

UNIT_TEST_STATUS EFIAPI InitUTContext ( IN UNIT_TEST_CONTEXT  Context)

Prep routine for Unit test function. To save the ProcessorNumber of disabled AP and temporarily enable it.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDPrep routine runs successful.
UNIT_TEST_ERROR_TEST_FAILEDPrep routine runs unsuccessful.

Definition at line 23 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceEnableDisableAPOnAp()

VOID RunMpServiceEnableDisableAPOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service EnableDisableAP on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 368 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceGetNumberOfProcessorsOnAp()

VOID RunMpServiceGetNumberOfProcessorsOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service GetNumberOfProcessors on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 323 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceGetProcessorInfoOnAp()

VOID RunMpServiceGetProcessorInfoOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service GetProcessorInfo on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 346 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceStartupAllAPsOnAp()

VOID RunMpServiceStartupAllAPsOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service StartupAllAPs on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 413 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceStartupThisAPOnAp()

VOID RunMpServiceStartupThisAPOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service StartupThisAP on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 390 of file EfiMpServicesUnitTestCommom.c.

◆ RunMpServiceSwitchBSPOnAp()

VOID RunMpServiceSwitchBSPOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service SwitchBSP on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 436 of file EfiMpServicesUnitTestCommom.c.

◆ StoreAPsExecutionOrder()

VOID StoreAPsExecutionOrder ( IN OUT VOID *  Buffer)

Produce to store the ProcessorNumber of AP execution order in CommonBuffer.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 263 of file EfiMpServicesUnitTestCommom.c.

◆ StoreCpuNumbers()

VOID StoreCpuNumbers ( IN OUT VOID *  Buffer)

Produce to store ProcessorNumber in the corresponding location of CommonBuffer.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 234 of file EfiMpServicesUnitTestCommom.c.

◆ TestEnableDisableAP1()

UNIT_TEST_STATUS EFIAPI TestEnableDisableAP1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service EnableDisableAP. When called with BSP number, the return status should be EFI_INVALID_PARAMETER. When called with a nonexistent processor handle, the return status should be EFI_NOT_FOUND. The AP should be really Enable/Disabled.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 774 of file EfiMpServicesUnitTestCommom.c.

◆ TestEnableDisableAP2()

UNIT_TEST_STATUS EFIAPI TestEnableDisableAP2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service EnableDisableAP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 842 of file EfiMpServicesUnitTestCommom.c.

◆ TestEnableDisableAP3()

UNIT_TEST_STATUS EFIAPI TestEnableDisableAP3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service EnableDisableAP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 885 of file EfiMpServicesUnitTestCommom.c.

◆ TestGetNumberOfProcessors1()

UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service GetNumberOfProcessors. NumberOfProcessors should be greater that 0 and not less than NumberOfEnabledProcessors.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 518 of file EfiMpServicesUnitTestCommom.c.

◆ TestGetNumberOfProcessors2()

UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service GetNumberOfProcessors. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 552 of file EfiMpServicesUnitTestCommom.c.

◆ TestGetNumberOfProcessors3()

UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service GetNumberOfProcessors. Call EnableDisableAP() to change the number of enabled AP.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 595 of file EfiMpServicesUnitTestCommom.c.

◆ TestGetProcessorInfo1()

UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service GetProcessorInfo. When all the parameters are valid, all reserved bits of StatusFlag in ProcessorInfoBuffer should be set to zero. When all the parameters are valid, the StatusFlag should not have an invalid value (The BSP can never be in the disabled state.). When called with nonexistent processor handle, the return status should be EFI_NOT_FOUND.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 682 of file EfiMpServicesUnitTestCommom.c.

◆ TestGetProcessorInfo2()

UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service GetProcessorInfo. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 729 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupAllAPs1()

UNIT_TEST_STATUS EFIAPI TestStartupAllAPs1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupAllAPs. All APs should execute the Procedure when called by StartupAllAPs.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1157 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupAllAPs2()

UNIT_TEST_STATUS EFIAPI TestStartupAllAPs2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupAllAPs. When called in single thread, the return status should be EFI_SUCCESS and AP executes in ascending order of processor handle number.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1200 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupAllAPs3()

UNIT_TEST_STATUS EFIAPI TestStartupAllAPs3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupAllAPs. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1246 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupAllAPs4()

UNIT_TEST_STATUS EFIAPI TestStartupAllAPs4 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupAllAPs. When called with all AP timeout, the return status should be EFI_TIMEOUT.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1289 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupAllAPs5()

UNIT_TEST_STATUS EFIAPI TestStartupAllAPs5 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupAllAPs. When called with the empty Procedure on all disabled APs, the return status should be EFI_NOT_STARTED.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1331 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupThisAP1()

UNIT_TEST_STATUS EFIAPI TestStartupThisAP1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupThisAP. When called to startup a BSP, the return status should be EFI_INVALID_PARAMETER. When called with a nonexistent processor handle, the return status should be EFI_NOT_FOUND. The requested AP should execute the Procedure when called by StartupThisAP.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 955 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupThisAP2()

UNIT_TEST_STATUS EFIAPI TestStartupThisAP2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupThisAP. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1007 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupThisAP3()

UNIT_TEST_STATUS EFIAPI TestStartupThisAP3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupThisAP. When timeout expired before the requested AP has finished, the return status should be EFI_TIMEOUT.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1050 of file EfiMpServicesUnitTestCommom.c.

◆ TestStartupThisAP4()

UNIT_TEST_STATUS EFIAPI TestStartupThisAP4 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service StartupThisAP. When called with disabled AP, the return status should be EFI_INVALID_PARAMETER.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1091 of file EfiMpServicesUnitTestCommom.c.

◆ TestSwitchBSP1()

UNIT_TEST_STATUS EFIAPI TestSwitchBSP1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service SwitchBSP. When switch current BSP to be BSP, the return status should be EFI_INVALID_PARAMETER. When switch nonexistent processor to be BSP, the return status should be EFI_NOT_FOUND. After switch BSP, all APs(includes new AP) should execute the Procedure when called by StartupAllAP.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1397 of file EfiMpServicesUnitTestCommom.c.

◆ TestSwitchBSP2()

UNIT_TEST_STATUS EFIAPI TestSwitchBSP2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service SwitchBSP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1463 of file EfiMpServicesUnitTestCommom.c.

◆ TestSwitchBSP3()

UNIT_TEST_STATUS EFIAPI TestSwitchBSP3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service SwitchBSP. When switch a disabled AP to be BSP, the return status should be EFI_INVALID_PARAMETER.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1506 of file EfiMpServicesUnitTestCommom.c.

◆ TestSwitchBSP4()

UNIT_TEST_STATUS EFIAPI TestSwitchBSP4 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service SwitchBSP. When SwitchBSP and EnableOldBSP is TRUE, the new BSP should be in the enabled state and the old BSP should be in the enabled state. When SwitchBSP and EnableOldBSP is False, the new BSP should be in the enabled state and the old BSP should be in the disabled state.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 1564 of file EfiMpServicesUnitTestCommom.c.

◆ TestWhoAmI1()

UNIT_TEST_STATUS EFIAPI TestWhoAmI1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of MP service WhoAmI. The range of ProcessorNumber should be from 0 to NumberOfCPUs minus 1. The ProcessorNumbers of all CPUs are unique.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 464 of file EfiMpServicesUnitTestCommom.c.