]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/Test: develop UEFI App and dynamic cmd for MP services UT
authorJason Lou <yun.lou@intel.com>
Thu, 24 Nov 2022 12:11:58 +0000 (20:11 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 8 Dec 2022 10:04:24 +0000 (10:04 +0000)
The code changes develop UEFI application and dynamic command for
EfiMpServiceProtocol unit tests based on current UnitTestFramework.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Reviewed-by: Dun Tan <dun.tan@intel.com>
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.c [new file with mode: 0644]
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf [new file with mode: 0644]
UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShellUnitTest.inf [new file with mode: 0644]
UefiCpuPkg/UefiCpuPkg.dsc

diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.c b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.c
new file mode 100644 (file)
index 0000000..be65c3d
--- /dev/null
@@ -0,0 +1,129 @@
+/** @file\r
+  Produce "MpProtocolUnitTest" shell dynamic command.\r
+\r
+  Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Protocol/ShellDynamicCommand.h>\r
+#include "EfiMpServicesUnitTestCommom.h"\r
+\r
+CHAR16  *mMpProtocolUnitTestCommandHelp = L".TH MpProtocolUnitTest 0\r\n.SH NAME\r\nDisplay unit test results of EFI MP services protocol.\r\n";\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMpServiceProtocolUnitTest (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  This is the shell command handler function pointer callback type.  This\r
+  function handles the command when it is invoked in the shell.\r
+\r
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in] SystemTable            The pointer to the system table.\r
+  @param[in] ShellParameters        The parameters associated with the command.\r
+  @param[in] Shell                  The instance of the shell protocol used in the context\r
+                                    of processing this command.\r
+\r
+  @return EFI_SUCCESS               the operation was successful\r
+  @return other                     the operation failed.\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestCommandHandler (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN EFI_SYSTEM_TABLE                    *SystemTable,\r
+  IN EFI_SHELL_PARAMETERS_PROTOCOL       *ShellParameters,\r
+  IN EFI_SHELL_PROTOCOL                  *Shell\r
+  )\r
+{\r
+  return EfiMpServiceProtocolUnitTest ();\r
+}\r
+\r
+/**\r
+  This is the command help handler function pointer callback type.  This\r
+  function is responsible for displaying help information for the associated\r
+  command.\r
+\r
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in] Language               The pointer to the language string to use.\r
+\r
+  @return string                    Pool allocated help string, must be freed by caller\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+MpProtocolUnitTestCommandGetHelp (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  *This,\r
+  IN CONST CHAR8                         *Language\r
+  )\r
+{\r
+  return AllocateCopyPool (StrSize (mMpProtocolUnitTestCommandHelp), mMpProtocolUnitTestCommandHelp);\r
+}\r
+\r
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL  mMpProtocolUnitTestDynamicCommand = {\r
+  L"MpProtocolUnitTest",\r
+  MpProtocolUnitTestCommandHandler,\r
+  MpProtocolUnitTestCommandGetHelp\r
+};\r
+\r
+/**\r
+  Entry point of MpProtocolUnitTest Dynamic Command.\r
+\r
+  Produce the DynamicCommand protocol to handle "MpProtocolUnitTest" command.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
+\r
+  @retval EFI_SUCCESS           Tftp command is executed successfully.\r
+  @retval EFI_ABORTED           HII package was failed to initialize.\r
+  @retval others                Other errors when executing MpProtocolUnitTest command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestCommandInitialize (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &ImageHandle,\r
+                  &gEfiShellDynamicCommandProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mMpProtocolUnitTestDynamicCommand\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Driver unload handler.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+\r
+  @retval EFI_SUCCESS           The image is unloaded.\r
+  @retval Others                Failed to unload the image.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+MpProtocolUnitTestUnload (\r
+  IN EFI_HANDLE  ImageHandle\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  ImageHandle,\r
+                  &gEfiShellDynamicCommandProtocolGuid,\r
+                  &mMpProtocolUnitTestDynamicCommand\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf
new file mode 100644 (file)
index 0000000..3fa287d
--- /dev/null
@@ -0,0 +1,45 @@
+## @file\r
+# DXE driver that provides Shell 'MpProtocolUnitTest' dynamic command to test EfiMpServiceProtocol.\r
+#\r
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION     = 0x00010005\r
+  BASE_NAME       = EfiMpServiceProtocolDynamicCmdUnitTest\r
+  FILE_GUID       = 8C4624B1-58CC-4DF6-9E6D-09B38D67DFA6\r
+  MODULE_TYPE     = DXE_DRIVER\r
+  VERSION_STRING  = 1.0\r
+  ENTRY_POINT     = MpProtocolUnitTestCommandInitialize\r
+  UNLOAD_IMAGE    = MpProtocolUnitTestUnload\r
+\r
+[Sources]\r
+  EfiMpServicesUnitTestCommom.c\r
+  EfiMpServicesUnitTestCommom.h\r
+  EfiMpServiceProtocolUnitTest.c\r
+  EfiMpServiceProtocolDynamicCmdUnitTest.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  UefiDriverEntryPoint\r
+  UefiBootServicesTableLib\r
+  UefiLib\r
+  UnitTestPersistenceLib\r
+  UnitTestLib\r
+\r
+[Protocols]\r
+  gEfiMpServiceProtocolGuid           ## CONSUMES\r
+  gEfiShellDynamicCommandProtocolGuid ## PRODUCES\r
+\r
+[Depex]\r
+  TRUE\r
diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShellUnitTest.inf b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShellUnitTest.inf
new file mode 100644 (file)
index 0000000..34c1ea9
--- /dev/null
@@ -0,0 +1,43 @@
+## @file\r
+# UEFI application that tests EfiMpServiceProtocol in Shell.\r
+#\r
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION     = 0x00010005\r
+  BASE_NAME       = MpProtocolUnitTest\r
+  FILE_GUID       = 4CEE6399-A22C-4FFD-B148-3A56B1DD83F1\r
+  MODULE_TYPE     = UEFI_APPLICATION\r
+  VERSION_STRING  = 1.0\r
+  ENTRY_POINT     = DxeEntryPoint\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  EfiMpServicesUnitTestCommom.c\r
+  EfiMpServicesUnitTestCommom.h\r
+  EfiMpServiceProtocolUnitTest.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  MemoryAllocationLib\r
+  UefiApplicationEntryPoint\r
+  UefiBootServicesTableLib\r
+  UnitTestPersistenceLib\r
+  UnitTestLib\r
+\r
+[Protocols]\r
+  gEfiMpServiceProtocolGuid           ## CONSUMES\r
index 67b0ce46e455a0f4313c8b580b143c7aae48c08c..f9a46089d2c7fb2c8c228cdfa62ec5dbf489da59 100644 (file)
   UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/PeiCpuExceptionHandlerLibUnitTest.inf\r
   UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EdkiiPeiMpServices2PpiPeiUnitTest.inf\r
   UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDxeUnitTest.inf\r
+  UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf {\r
+    <LibraryClasses>\r
+      UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf\r
+  }\r
+  UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShellUnitTest.inf {\r
+    <LibraryClasses>\r
+      UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf\r
+  }\r
 \r
 [Components.X64]\r
   UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf\r