From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.22023.1669291933939246591 for ; Thu, 24 Nov 2022 04:12:14 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=AoOY5XVO; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yun.lou@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669291933; x=1700827933; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OUL0Pc9Lj3ohE7g4QmMl9HqcT1RUCPa7g2kB7EQQhzo=; b=AoOY5XVOGh24y4PlxSXh+TJlNToJS+2MyQ25FKMCMmsm/WaCg2Vuv5xN iZv/a3C8rP0HywI5MjDRALlLc9TW0kNHrF2LFkqCG9Gck1GiPE2HJjKE7 IjK3LIRxU6g4PiqRH7Qbu3HMrs7FaeJ1X0L9EFr3fcGWw97e9WXxouO84 oQIYhvNF1dypdFb8lk47SEqxpm/6pJ2lilsMopYYBNxi/2h4Bbtm8pr6j eTTK8AEQTnh6WpaEHhhe6WR+2Lh/Wxj+HkLUhoYoOwxpa5/+rLnevgLor qbroRMbHhprY2NNTtdxuKV/ZLHcKGF2ZGJNuxex3QhwgtjjbUf36XmkGP A==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="315438915" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="315438915" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 04:12:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="767062421" X-IronPort-AV: E=Sophos;i="5.96,190,1665471600"; d="scan'208";a="767062421" Received: from shwdeopenlab102.ccr.corp.intel.com ([10.239.56.236]) by orsmga004.jf.intel.com with ESMTP; 24 Nov 2022 04:12:04 -0800 From: "Jason Lou" To: devel@edk2.groups.io Cc: Jason Lou , Ray Ni , Eric Dong , Laszlo Ersek , Rahul Kumar , Zhiguang Liu , Dun Tan Subject: [PATCH v1 2/2] UefiCpuPkg/Test: develop UEFI App and dynamic cmd for MP services UT Date: Thu, 24 Nov 2022 20:11:58 +0800 Message-Id: <20221124121158.2812-2-yun.lou@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20221124121158.2812-1-yun.lou@intel.com> References: <20221124121158.2812-1-yun.lou@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jason Lou The code changes develop UEFI application and dynamic command for EfiMpServiceProtocol unit tests based on current UnitTestFramework. Signed-off-by: Jason Lou Reviewed-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: Rahul Kumar Cc: Zhiguang Liu Cc: Dun Tan --- UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDyna= micCmdUnitTest.c | 129 ++++++++++++++++++++ UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDyna= micCmdUnitTest.inf | 45 +++++++ UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolShel= lUnitTest.inf | 43 +++++++ UefiCpuPkg/UefiCpuPkg.dsc = | 8 ++ 4 files changed, 225 insertions(+) diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpService= ProtocolDynamicCmdUnitTest.c b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiPro= tocol/EfiMpServiceProtocolDynamicCmdUnitTest.c new file mode 100644 index 0000000000..be65c3d678 --- /dev/null +++ b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtoco= lDynamicCmdUnitTest.c @@ -0,0 +1,129 @@ +/** @file=0D + Produce "MpProtocolUnitTest" shell dynamic command.=0D +=0D + Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include "EfiMpServicesUnitTestCommom.h"=0D +=0D +CHAR16 *mMpProtocolUnitTestCommandHelp =3D L".TH MpProtocolUnitTest 0\r\n= .SH NAME\r\nDisplay unit test results of EFI MP services protocol.\r\n";=0D +=0D +EFI_STATUS=0D +EFIAPI=0D +EfiMpServiceProtocolUnitTest (=0D + VOID=0D + );=0D +=0D +/**=0D + This is the shell command handler function pointer callback type. This= =0D + function handles the command when it is invoked in the shell.=0D +=0D + @param[in] This The instance of the EFI_SHELL_DYNAMIC_= COMMAND_PROTOCOL.=0D + @param[in] SystemTable The pointer to the system table.=0D + @param[in] ShellParameters The parameters associated with the com= mand.=0D + @param[in] Shell The instance of the shell protocol use= d in the context=0D + of processing this command.=0D +=0D + @return EFI_SUCCESS the operation was successful=0D + @return other the operation failed.=0D +**/=0D +SHELL_STATUS=0D +EFIAPI=0D +MpProtocolUnitTestCommandHandler (=0D + IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,=0D + IN EFI_SYSTEM_TABLE *SystemTable,=0D + IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters,=0D + IN EFI_SHELL_PROTOCOL *Shell=0D + )=0D +{=0D + return EfiMpServiceProtocolUnitTest ();=0D +}=0D +=0D +/**=0D + This is the command help handler function pointer callback type. This=0D + function is responsible for displaying help information for the associat= ed=0D + command.=0D +=0D + @param[in] This The instance of the EFI_SHELL_DYNAMIC_= COMMAND_PROTOCOL.=0D + @param[in] Language The pointer to the language string to = use.=0D +=0D + @return string Pool allocated help string, must be fr= eed by caller=0D +**/=0D +CHAR16 *=0D +EFIAPI=0D +MpProtocolUnitTestCommandGetHelp (=0D + IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This,=0D + IN CONST CHAR8 *Language=0D + )=0D +{=0D + return AllocateCopyPool (StrSize (mMpProtocolUnitTestCommandHelp), mMpPr= otocolUnitTestCommandHelp);=0D +}=0D +=0D +EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mMpProtocolUnitTestDynamicCommand =3D = {=0D + L"MpProtocolUnitTest",=0D + MpProtocolUnitTestCommandHandler,=0D + MpProtocolUnitTestCommandGetHelp=0D +};=0D +=0D +/**=0D + Entry point of MpProtocolUnitTest Dynamic Command.=0D +=0D + Produce the DynamicCommand protocol to handle "MpProtocolUnitTest" comma= nd.=0D +=0D + @param ImageHandle The image handle of the process.=0D + @param SystemTable The EFI System Table pointer.=0D +=0D + @retval EFI_SUCCESS Tftp command is executed successfully.=0D + @retval EFI_ABORTED HII package was failed to initialize.=0D + @retval others Other errors when executing MpProtocolUnit= Test command.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MpProtocolUnitTestCommandInitialize (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + Status =3D gBS->InstallProtocolInterface (=0D + &ImageHandle,=0D + &gEfiShellDynamicCommandProtocolGuid,=0D + EFI_NATIVE_INTERFACE,=0D + &mMpProtocolUnitTestDynamicCommand=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Driver unload handler.=0D +=0D + @param ImageHandle The image handle of the process.=0D +=0D + @retval EFI_SUCCESS The image is unloaded.=0D + @retval Others Failed to unload the image.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +MpProtocolUnitTestUnload (=0D + IN EFI_HANDLE ImageHandle=0D + )=0D +{=0D + EFI_STATUS Status;=0D +=0D + Status =3D gBS->UninstallProtocolInterface (=0D + ImageHandle,=0D + &gEfiShellDynamicCommandProtocolGuid,=0D + &mMpProtocolUnitTestDynamicCommand=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D +=0D + return Status;=0D +}=0D diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpService= ProtocolDynamicCmdUnitTest.inf b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiP= rotocol/EfiMpServiceProtocolDynamicCmdUnitTest.inf new file mode 100644 index 0000000000..3fa287d1ae --- /dev/null +++ b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtoco= lDynamicCmdUnitTest.inf @@ -0,0 +1,45 @@ +## @file=0D +# DXE driver that provides Shell 'MpProtocolUnitTest' dynamic command to t= est EfiMpServiceProtocol.=0D +#=0D +# Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D EfiMpServiceProtocolDynamicCmdUnitTest=0D + FILE_GUID =3D 8C4624B1-58CC-4DF6-9E6D-09B38D67DFA6=0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D MpProtocolUnitTestCommandInitialize=0D + UNLOAD_IMAGE =3D MpProtocolUnitTestUnload=0D +=0D +[Sources]=0D + EfiMpServicesUnitTestCommom.c=0D + EfiMpServicesUnitTestCommom.h=0D + EfiMpServiceProtocolUnitTest.c=0D + EfiMpServiceProtocolDynamicCmdUnitTest.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + BaseMemoryLib=0D + MemoryAllocationLib=0D + UefiDriverEntryPoint=0D + UefiBootServicesTableLib=0D + UefiLib=0D + UnitTestPersistenceLib=0D + UnitTestLib=0D +=0D +[Protocols]=0D + gEfiMpServiceProtocolGuid ## CONSUMES=0D + gEfiShellDynamicCommandProtocolGuid ## PRODUCES=0D +=0D +[Depex]=0D + TRUE=0D diff --git a/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpService= ProtocolShellUnitTest.inf b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtoc= ol/EfiMpServiceProtocolShellUnitTest.inf new file mode 100644 index 0000000000..34c1ea96a6 --- /dev/null +++ b/UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtoco= lShellUnitTest.inf @@ -0,0 +1,43 @@ +## @file=0D +# UEFI application that tests EfiMpServiceProtocol in Shell.=0D +#=0D +# Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D MpProtocolUnitTest=0D + FILE_GUID =3D 4CEE6399-A22C-4FFD-B148-3A56B1DD83F1=0D + MODULE_TYPE =3D UEFI_APPLICATION=0D + VERSION_STRING =3D 1.0=0D + ENTRY_POINT =3D DxeEntryPoint=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[Sources]=0D + EfiMpServicesUnitTestCommom.c=0D + EfiMpServicesUnitTestCommom.h=0D + EfiMpServiceProtocolUnitTest.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + BaseMemoryLib=0D + MemoryAllocationLib=0D + UefiApplicationEntryPoint=0D + UefiBootServicesTableLib=0D + UnitTestPersistenceLib=0D + UnitTestLib=0D +=0D +[Protocols]=0D + gEfiMpServiceProtocolGuid ## CONSUMES=0D diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc index 67b0ce46e4..f9a46089d2 100644 --- a/UefiCpuPkg/UefiCpuPkg.dsc +++ b/UefiCpuPkg/UefiCpuPkg.dsc @@ -183,6 +183,14 @@ UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/PeiCpuExceptionHandle= rLibUnitTest.inf=0D UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EdkiiPeiMpServices2Ppi= PeiUnitTest.inf=0D UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDx= eUnitTest.inf=0D + UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolDy= namicCmdUnitTest.inf {=0D + =0D + UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultR= eportLib/UnitTestResultReportLibConOut.inf=0D + }=0D + UefiCpuPkg/Test/UnitTest/EfiMpServicesPpiProtocol/EfiMpServiceProtocolSh= ellUnitTest.inf {=0D + =0D + UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultR= eportLib/UnitTestResultReportLibConOut.inf=0D + }=0D =0D [Components.X64]=0D UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandle= rLibUnitTest.inf=0D --=20 2.28.0.windows.1