public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo, Gua" <gua.guo@intel.com>
To: devel@edk2.groups.io
Cc: gua.guo@intel.com, Michael D Kinney <michael.d.kinney@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Zhiguang Liu <zhiguang.liu@intel.com>,
	Chris Johnson <chris.n.johnson@intel.com>
Subject: [PATCH v3 2/2] MdePkg: Add more HobLib/PeiServicesLib gmock support
Date: Tue,  9 May 2023 08:03:40 +0800	[thread overview]
Message-ID: <20230509000340.1722-3-gua.guo@intel.com> (raw)
In-Reply-To: <20230509000340.1722-1-gua.guo@intel.com>

From: Gua Guo <gua.guo@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4443

Add Google Mock Library for HobLib
Add Google Mock Library for PeiServicesLib

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Chris Johnson <chris.n.johnson@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
 MdePkg/Test/MdePkgHostTest.dsc                |   2 +
 .../Include/GoogleTest/Library/MockHobLib.h   | 150 ++++++++++++++
 .../GoogleTest/Library/MockPeiServicesLib.h   | 189 ++++++++++++++++++
 .../GoogleTest/MockHobLib/MockHobLib.cpp      |  30 +++
 .../GoogleTest/MockHobLib/MockHobLib.inf      |  33 +++
 .../MockPeiServicesLib/MockPeiServicesLib.cpp |  36 ++++
 .../MockPeiServicesLib/MockPeiServicesLib.inf |  32 +++
 7 files changed, 472 insertions(+)
 create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockHobLib.h
 create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockPeiServicesLib.h
 create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.cpp
 create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
 create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.cpp
 create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf

diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc
index 35e3ef6d97..529ea69024 100644
--- a/MdePkg/Test/MdePkgHostTest.dsc
+++ b/MdePkg/Test/MdePkgHostTest.dsc
@@ -36,3 +36,5 @@
   MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
   MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf
   MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf
+  MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf
+  MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockHobLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockHobLib.h
new file mode 100644
index 0000000000..994b8133e5
--- /dev/null
+++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockHobLib.h
@@ -0,0 +1,150 @@
+/** @file
+  Google Test mocks for HobLib
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_HOB_LIB_H_
+#define MOCK_HOB_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+#include <Pi/PiMultiPhase.h>
+#include <Uefi.h>
+#include <Library/HobLib.h>
+}
+
+struct MockHobLib {
+  MOCK_INTERFACE_DECLARATION (MockHobLib);
+
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    GetHobList,
+    ()
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    GetNextHob,
+    (IN UINT16      Type,
+     IN CONST VOID  *HobStart)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    GetFirstHob,
+    (IN UINT16      Type)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    GetNextGuidHob,
+    (IN CONST EFI_GUID  *Guid,
+     IN CONST VOID      *HobStart)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    GetFirstGuidHob,
+    (IN CONST EFI_GUID  *Guid)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_BOOT_MODE,
+    GetBootModeHob,
+    ()
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildModuleHob,
+    (IN CONST EFI_GUID        *ModuleName,
+     IN EFI_PHYSICAL_ADDRESS  MemoryAllocationModule,
+     IN UINT64                ModuleLength,
+     IN EFI_PHYSICAL_ADDRESS  EntryPoint)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildResourceDescriptorWithOwnerHob,
+    (IN EFI_RESOURCE_TYPE            ResourceType,
+     IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
+     IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
+     IN UINT64                       NumberOfBytes,
+     IN EFI_GUID                     *OwnerGUID)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildResourceDescriptorHob,
+    (IN EFI_RESOURCE_TYPE            ResourceType,
+     IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
+     IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
+     IN UINT64                       NumberOfBytes)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    BuildGuidHob,
+    (IN CONST EFI_GUID  *Guid,
+     IN UINTN           DataLength)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID *,
+    BuildGuidDataHob,
+    (IN CONST EFI_GUID  *Guid,
+     IN VOID            *Data,
+     IN UINTN           DataLength)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildFvHob,
+    (IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN UINT64                Length)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildFv2Hob,
+    (IN          EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN          UINT64                Length,
+     IN CONST    EFI_GUID              *FvName,
+     IN CONST    EFI_GUID              *FileName)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildFv3Hob,
+    (IN          EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN          UINT64                Length,
+     IN          UINT32                AuthenticationStatus,
+     IN          BOOLEAN               ExtractedFv,
+     IN CONST    EFI_GUID              *FvName  OPTIONAL,
+     IN CONST    EFI_GUID              *FileName OPTIONAL)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildCvHob,
+    (IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN UINT64                Length)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildCpuHob,
+    (IN UINT8  SizeOfMemorySpace,
+     IN UINT8  SizeOfIoSpace)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildStackHob,
+    (IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN UINT64                Length)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildBspStoreHob,
+    (IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN UINT64                Length,
+     IN EFI_MEMORY_TYPE       MemoryType)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    BuildMemoryAllocationHob,
+    (IN EFI_PHYSICAL_ADDRESS  BaseAddress,
+     IN UINT64                Length,
+     IN EFI_MEMORY_TYPE       MemoryType)
+    );
+};
+
+#endif
diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockPeiServicesLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockPeiServicesLib.h
new file mode 100644
index 0000000000..4a99fec539
--- /dev/null
+++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockPeiServicesLib.h
@@ -0,0 +1,189 @@
+/** @file
+  Google Test mocks for PeiServicesLib
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_PEI_SERVICES_LIB_H_
+#define MOCK_PEI_SERVICES_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+#include <PiPei.h>
+#include <Uefi.h>
+#include <Library/PeiServicesLib.h>
+}
+
+struct MockPeiServicesLib {
+  MOCK_INTERFACE_DECLARATION (MockPeiServicesLib);
+
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesInstallPpi,
+    (IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesReInstallPpi,
+    (IN CONST EFI_PEI_PPI_DESCRIPTOR  *OldPpi,
+     IN CONST EFI_PEI_PPI_DESCRIPTOR  *NewPpi)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesLocatePpi,
+    (IN CONST EFI_GUID              *Guid,
+     IN UINTN                       Instance,
+     IN OUT EFI_PEI_PPI_DESCRIPTOR  **PpiDescriptor  OPTIONAL,
+     IN OUT VOID                    **Ppi)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesNotifyPpi,
+    (IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesGetBootMode,
+    (OUT EFI_BOOT_MODE  *BootMode)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesSetBootMode,
+    (IN EFI_BOOT_MODE  BootMode)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesGetHobList,
+    (OUT VOID  **HobList)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesCreateHob,
+    (IN UINT16  Type,
+     IN UINT16  Length,
+     OUT VOID   **Hob)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsFindNextVolume,
+    (IN UINTN                  Instance,
+     IN OUT EFI_PEI_FV_HANDLE  *VolumeHandle)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsFindNextFile,
+    (IN EFI_FV_FILETYPE          SearchType,
+     IN EFI_PEI_FV_HANDLE        VolumeHandle,
+     IN OUT EFI_PEI_FILE_HANDLE  *FileHandle)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsFindSectionData,
+    (IN EFI_SECTION_TYPE     SectionType,
+     IN EFI_PEI_FILE_HANDLE  FileHandle,
+     OUT VOID                **SectionData)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsFindSectionData3,
+    (IN EFI_SECTION_TYPE     SectionType,
+     IN UINTN                SectionInstance,
+     IN EFI_PEI_FILE_HANDLE  FileHandle,
+     OUT VOID                **SectionData,
+     OUT UINT32              *AuthenticationStatus)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesInstallPeiMemory,
+    (IN EFI_PHYSICAL_ADDRESS  MemoryBegin,
+     IN UINT64                MemoryLength)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesAllocatePages,
+    (IN EFI_MEMORY_TYPE        MemoryType,
+     IN UINTN                  Pages,
+     OUT EFI_PHYSICAL_ADDRESS  *Memory)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFreePages,
+    (IN EFI_PHYSICAL_ADDRESS  Memory,
+     IN UINTN                 Pages)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesAllocatePool,
+    (IN UINTN  Size,
+     OUT VOID  **Buffer)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesResetSystem,
+    ()
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsFindFileByName,
+    (IN CONST  EFI_GUID             *FileName,
+     IN CONST  EFI_PEI_FV_HANDLE    VolumeHandle,
+     OUT       EFI_PEI_FILE_HANDLE  *FileHandle)
+    );
+
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsGetFileInfo,
+    (IN CONST  EFI_PEI_FILE_HANDLE  FileHandle,
+     OUT EFI_FV_FILE_INFO           *FileInfo)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsGetFileInfo2,
+    (IN CONST  EFI_PEI_FILE_HANDLE  FileHandle,
+     OUT EFI_FV_FILE_INFO2          *FileInfo)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesFfsGetVolumeInfo,
+    (IN  EFI_PEI_FV_HANDLE  VolumeHandle,
+     OUT EFI_FV_INFO        *VolumeInfo)
+    );
+
+  MOCK_FUNCTION_DECLARATION (
+    EFI_STATUS,
+    PeiServicesRegisterForShadow,
+    (IN  EFI_PEI_FILE_HANDLE  FileHandle)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    PeiServicesInstallFvInfoPpi,
+    (IN CONST EFI_GUID  *FvFormat  OPTIONAL,
+     IN CONST VOID      *FvInfo,
+     IN       UINT32    FvInfoSize,
+     IN CONST EFI_GUID  *ParentFvName  OPTIONAL,
+     IN CONST EFI_GUID  *ParentFileName OPTIONAL)
+    );
+
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    PeiServicesInstallFvInfo2Ppi,
+    (IN CONST EFI_GUID  *FvFormat  OPTIONAL,
+     IN CONST VOID      *FvInfo,
+     IN       UINT32    FvInfoSize,
+     IN CONST EFI_GUID  *ParentFvName  OPTIONAL,
+     IN CONST EFI_GUID  *ParentFileName  OPTIONAL,
+     IN       UINT32    AuthenticationStatus)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    PeiServicesResetSystem2,
+    (IN EFI_RESET_TYPE  ResetType,
+     IN EFI_STATUS      ResetStatus,
+     IN UINTN           DataSize,
+     IN VOID            *ResetData OPTIONAL)
+    );
+};
+
+#endif
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.cpp
new file mode 100644
index 0000000000..5a5a9159fc
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.cpp
@@ -0,0 +1,30 @@
+/** @file
+  Google Test mocks for HobLib
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <GoogleTest/Library/MockHobLib.h>
+
+MOCK_INTERFACE_DEFINITION(MockHobLib);
+
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetHobList, 0, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetNextHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetFirstHob, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetNextGuidHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetFirstGuidHob, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, GetBootModeHob, 0, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildModuleHob, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildResourceDescriptorWithOwnerHob, 5, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildResourceDescriptorHob, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildGuidHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildGuidDataHob, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildFvHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildFv2Hob, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildFv3Hob, 6, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildCvHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildCpuHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildStackHob, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildBspStoreHob, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockHobLib, BuildMemoryAllocationHob, 3, EFIAPI);
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
new file mode 100644
index 0000000000..79e6c8a042
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
@@ -0,0 +1,33 @@
+## @file
+# Google Test mocks for HobLib
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = MockHobLib
+  FILE_GUID                      = 44E3D5AA-7225-4A70-B1B7-0D02C44F0690
+  MODULE_TYPE                    = HOST_APPLICATION
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = HobLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  MockHobLib.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.cpp
new file mode 100644
index 0000000000..9a7ff4bd8f
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.cpp
@@ -0,0 +1,36 @@
+/** @file
+  Google Test mocks for PeiServicesLib
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <GoogleTest/Library/MockPeiServicesLib.h>
+
+MOCK_INTERFACE_DEFINITION(MockPeiServicesLib);
+
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesInstallPpi, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesReInstallPpi, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesLocatePpi, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesNotifyPpi, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesGetBootMode, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesSetBootMode, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesGetHobList, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesCreateHob, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsFindNextVolume, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsFindNextFile, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsFindSectionData, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsFindSectionData3, 5, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesInstallPeiMemory, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesAllocatePages, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFreePages, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesAllocatePool, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesResetSystem, 0, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsFindFileByName, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsGetFileInfo, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsGetFileInfo2, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesFfsGetVolumeInfo, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesRegisterForShadow, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesInstallFvInfoPpi, 5, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesInstallFvInfo2Ppi, 6, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPeiServicesLib, PeiServicesResetSystem2, 4, EFIAPI);
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf
new file mode 100644
index 0000000000..941a4dd4b1
--- /dev/null
+++ b/MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf
@@ -0,0 +1,32 @@
+## @file
+# Mock PEI Services Library implementation.
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = MockPeiServicesLib
+  FILE_GUID                      = FC944493-C0C0-482D-A1CC-72CE12C4BEEA
+  MODULE_TYPE                    = HOST_APPLICATION
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PeiServicesLib
+  PI_SPECIFICATION_VERSION       = 0x0001000A
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  MockPeiServicesLib.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc
-- 
2.39.2.windows.1


  parent reply	other threads:[~2023-05-09  0:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09  0:03 [PATCH v3 0/2] Add more google mock library Guo, Gua
2023-05-09  0:03 ` [PATCH v3 1/2] MdeModulePkg: Add more PciHostBridgeLib gmock support Guo, Gua
2023-05-09  0:03 ` Guo, Gua [this message]
2023-05-09  0:17 ` [edk2-devel] [PATCH v3 0/2] Add more google mock library Michael D Kinney
2023-05-09 22:56   ` Guo, Gua
2023-05-10  0:42     ` Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230509000340.1722-3-gua.guo@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox