forked from tianocore/edk2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UefiCpuPkg/Test: develop UEFI App and dynamic cmd for MP services UT
The code changes develop UEFI application and dynamic command for EfiMpServiceProtocol unit tests based on current UnitTestFramework. Signed-off-by: Jason Lou <[email protected]> Reviewed-by: Ray Ni <[email protected]> Cc: Eric Dong <[email protected]> Cc: Laszlo Ersek <[email protected]> Cc: Rahul Kumar <[email protected]> Reviewed-by: Zhiguang Liu <[email protected]> Reviewed-by: Dun Tan <[email protected]>
- Loading branch information
1 parent
cf3d450
commit 2280af5
Showing
4 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/** @file | ||
Produce "MpProtocolUnitTest" shell dynamic command. | ||
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <Library/UefiBootServicesTableLib.h> | ||
#include <Protocol/ShellDynamicCommand.h> | ||
#include "EfiMpServicesUnitTestCommom.h" | ||
|
||
CHAR16 *mMpProtocolUnitTestCommandHelp = L".TH MpProtocolUnitTest 0\r\n.SH NAME\r\nDisplay unit test results of EFI MP services protocol.\r\n"; | ||
|
||
EFI_STATUS | ||
EFIAPI | ||
EfiMpServiceProtocolUnitTest ( | ||
VOID | ||
); | ||
|
||
/** | ||
This is the shell command handler function pointer callback type. This | ||
function handles the command when it is invoked in the shell. | ||
@param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. | ||
@param[in] SystemTable The pointer to the system table. | ||
@param[in] ShellParameters The parameters associated with the command. | ||
@param[in] Shell The instance of the shell protocol used in the context | ||
of processing this command. | ||
@return EFI_SUCCESS the operation was successful | ||
@return other the operation failed. | ||
**/ | ||
SHELL_STATUS | ||
EFIAPI | ||
MpProtocolUnitTestCommandHandler ( | ||
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, | ||
IN EFI_SYSTEM_TABLE *SystemTable, | ||
IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, | ||
IN EFI_SHELL_PROTOCOL *Shell | ||
) | ||
{ | ||
return EfiMpServiceProtocolUnitTest (); | ||
} | ||
|
||
/** | ||
This is the command help handler function pointer callback type. This | ||
function is responsible for displaying help information for the associated | ||
command. | ||
@param[in] This The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL. | ||
@param[in] Language The pointer to the language string to use. | ||
@return string Pool allocated help string, must be freed by caller | ||
**/ | ||
CHAR16 * | ||
EFIAPI | ||
MpProtocolUnitTestCommandGetHelp ( | ||
IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, | ||
IN CONST CHAR8 *Language | ||
) | ||
{ | ||
return AllocateCopyPool (StrSize (mMpProtocolUnitTestCommandHelp), mMpProtocolUnitTestCommandHelp); | ||
} | ||
|
||
EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mMpProtocolUnitTestDynamicCommand = { | ||
L"MpProtocolUnitTest", | ||
MpProtocolUnitTestCommandHandler, | ||
MpProtocolUnitTestCommandGetHelp | ||
}; | ||
|
||
/** | ||
Entry point of MpProtocolUnitTest Dynamic Command. | ||
Produce the DynamicCommand protocol to handle "MpProtocolUnitTest" command. | ||
@param ImageHandle The image handle of the process. | ||
@param SystemTable The EFI System Table pointer. | ||
@retval EFI_SUCCESS Tftp command is executed successfully. | ||
@retval EFI_ABORTED HII package was failed to initialize. | ||
@retval others Other errors when executing MpProtocolUnitTest command. | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MpProtocolUnitTestCommandInitialize ( | ||
IN EFI_HANDLE ImageHandle, | ||
IN EFI_SYSTEM_TABLE *SystemTable | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
|
||
Status = gBS->InstallProtocolInterface ( | ||
&ImageHandle, | ||
&gEfiShellDynamicCommandProtocolGuid, | ||
EFI_NATIVE_INTERFACE, | ||
&mMpProtocolUnitTestDynamicCommand | ||
); | ||
ASSERT_EFI_ERROR (Status); | ||
|
||
return Status; | ||
} | ||
|
||
/** | ||
Driver unload handler. | ||
@param ImageHandle The image handle of the process. | ||
@retval EFI_SUCCESS The image is unloaded. | ||
@retval Others Failed to unload the image. | ||
**/ | ||
EFI_STATUS | ||
EFIAPI | ||
MpProtocolUnitTestUnload ( | ||
IN EFI_HANDLE ImageHandle | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
|
||
Status = gBS->UninstallProtocolInterface ( | ||
ImageHandle, | ||
&gEfiShellDynamicCommandProtocolGuid, | ||
&mMpProtocolUnitTestDynamicCommand | ||
); | ||
ASSERT_EFI_ERROR (Status); | ||
|
||
return Status; | ||
} |
45 changes: 45 additions & 0 deletions
45
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## @file | ||
# DXE driver that provides Shell 'MpProtocolUnitTest' dynamic command to test EfiMpServiceProtocol. | ||
# | ||
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = EfiMpServiceProtocolDynamicCmdUnitTest | ||
FILE_GUID = 8C4624B1-58CC-4DF6-9E6D-09B38D67DFA6 | ||
MODULE_TYPE = DXE_DRIVER | ||
VERSION_STRING = 1.0 | ||
ENTRY_POINT = MpProtocolUnitTestCommandInitialize | ||
UNLOAD_IMAGE = MpProtocolUnitTestUnload | ||
|
||
[Sources] | ||
EfiMpServicesUnitTestCommom.c | ||
EfiMpServicesUnitTestCommom.h | ||
EfiMpServiceProtocolUnitTest.c | ||
EfiMpServiceProtocolDynamicCmdUnitTest.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
UefiCpuPkg/UefiCpuPkg.dec | ||
|
||
[LibraryClasses] | ||
BaseLib | ||
DebugLib | ||
BaseMemoryLib | ||
MemoryAllocationLib | ||
UefiDriverEntryPoint | ||
UefiBootServicesTableLib | ||
UefiLib | ||
UnitTestPersistenceLib | ||
UnitTestLib | ||
|
||
[Protocols] | ||
gEfiMpServiceProtocolGuid ## CONSUMES | ||
gEfiShellDynamicCommandProtocolGuid ## PRODUCES | ||
|
||
[Depex] | ||
TRUE |
43 changes: 43 additions & 0 deletions
43
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShellUnitTest.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## @file | ||
# UEFI application that tests EfiMpServiceProtocol in Shell. | ||
# | ||
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MpProtocolUnitTest | ||
FILE_GUID = 4CEE6399-A22C-4FFD-B148-3A56B1DD83F1 | ||
MODULE_TYPE = UEFI_APPLICATION | ||
VERSION_STRING = 1.0 | ||
ENTRY_POINT = DxeEntryPoint | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
EfiMpServicesUnitTestCommom.c | ||
EfiMpServicesUnitTestCommom.h | ||
EfiMpServiceProtocolUnitTest.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
UefiCpuPkg/UefiCpuPkg.dec | ||
|
||
[LibraryClasses] | ||
BaseLib | ||
DebugLib | ||
BaseMemoryLib | ||
MemoryAllocationLib | ||
UefiApplicationEntryPoint | ||
UefiBootServicesTableLib | ||
UnitTestPersistenceLib | ||
UnitTestLib | ||
|
||
[Protocols] | ||
gEfiMpServiceProtocolGuid ## CONSUMES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters