MdeModulePkg: Add more PciHostBridgeLib gmock support

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

Add Google Mock Library for PciHostBridgeLib

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chris Johnson <chris.n.johnson@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Gua Guo 2023-05-05 09:16:56 +08:00 committed by mergify[bot]
parent bee67e0c14
commit 25c9d44315
5 changed files with 95 additions and 0 deletions

View File

@ -24,6 +24,7 @@
[Includes] [Includes]
Include Include
Test/Mock/Include
[Includes.Common.Private] [Includes.Common.Private]
Library/BrotliCustomDecompressLib/brotli/c/include Library/BrotliCustomDecompressLib/brotli/c/include

View File

@ -53,3 +53,8 @@
UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
} }
#
# Build HOST_APPLICATION Libraries
#
MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf

View File

@ -0,0 +1,40 @@
/** @file
Google Test mocks for PciHostBridgeLib
Copyright (c) 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef MOCK_PCI_HOST_BRIDGE_LIB_H_
#define MOCK_PCI_HOST_BRIDGE_LIB_H_
#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Library/PciHostBridgeLib.h>
}
struct MockPciHostBridgeLib {
MOCK_INTERFACE_DECLARATION (MockPciHostBridgeLib);
MOCK_FUNCTION_DECLARATION (
PCI_ROOT_BRIDGE *,
PciHostBridgeGetRootBridges,
(UINTN *Count)
);
MOCK_FUNCTION_DECLARATION (
VOID,
PciHostBridgeFreeRootBridges,
(PCI_ROOT_BRIDGE *Bridges,
UINTN Count)
);
MOCK_FUNCTION_DECLARATION (
VOID,
PciHostBridgeResourceConflict,
(EFI_HANDLE HostBridgeHandle,
VOID *Configuration)
);
};
#endif

View File

@ -0,0 +1,14 @@
/** @file
Mock instance of the PCI Host Bridge Library.
Copyright (c) 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <GoogleTest/Library/MockPciHostBridgeLib.h>
MOCK_INTERFACE_DEFINITION(MockPciHostBridgeLib);
MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeGetRootBridges, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeFreeRootBridges, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeResourceConflict, 2, EFIAPI);

View File

@ -0,0 +1,35 @@
## @file
# Mock instance of the PCI Host Bridge Library.
#
# Copyright (c) 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MockPciHostBridgeLib
FILE_GUID = B51721FE-0BBA-4611-B9A5-ED13C49AC060
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = PciHostBridgeLib
#
# The following information is for reference only and not required by the build
# tools.
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
MockPciHostBridgeLib.cpp
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
[LibraryClasses]
GoogleTestLib
[BuildOptions]
MSFT:*_*_*_CC_FLAGS = /EHsc