Skip to content

Commit

Permalink
Added mock functions for PciExpressLib
Browse files Browse the repository at this point in the history
  • Loading branch information
v-bhavanisu authored and os-d committed Aug 24, 2024
1 parent c321f8c commit 0182bec
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions MdePkg/Test/MdePkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@
MdePkg/Test/Mock/Library/Cmocka/MockUefiBootServicesTableLib/MockUefiBootServicesTableLib.inf
MdePkg/Test/Mock/Library/Stub/StubHobLib/StubHobLib.inf
MdePkg/Test/Mock/Library/Stub/StubUefiLib/StubUefiLib.inf
MdePkg/Test/Mock/Library/GoogleTest/MockPciExpressLib/MockPciExpressLib.inf
# MU_CHANGE [END]
45 changes: 45 additions & 0 deletions MdePkg/Test/Mock/Include/GoogleTest/Library/MockPciExpressLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/** @file MockPciExpressLib.h
Google Test mocks for PciExpressLib
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_PCI_EXPRESS_LIB_H_
#define MOCK_PCI_EXPRESS_LIB_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Library/PciExpressLib.h>
}

struct MockPciExpressLib {
MOCK_INTERFACE_DECLARATION (MockPciExpressLib);

MOCK_FUNCTION_DECLARATION (
UINT8,
PciExpressRead8,
(
IN UINTN Address
)
);
MOCK_FUNCTION_DECLARATION (
UINT16,
PciExpressRead16,
(
IN UINTN Address
)
);

MOCK_FUNCTION_DECLARATION (
UINT32,
PciExpressRead32,
(
IN UINTN Address
)
);
};

#endif //MOCK_PCI_EXPRESS_LIB_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @file MockPciExpressLib.cpp
Google Test mocks for PciExpressLib
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <GoogleTest/Library/MockPciExpressLib.h>

MOCK_INTERFACE_DEFINITION (MockPciExpressLib);
MOCK_FUNCTION_DEFINITION (MockPciExpressLib, PciExpressRead8, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockPciExpressLib, PciExpressRead16, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockPciExpressLib, PciExpressRead32, 1, EFIAPI);
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## @file MockPciExpressLib.inf
# Google Test mocks for PciExpressLib
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MockPciExpressLib
FILE_GUID = EB17BE3C-2B3E-4B40-8C71-0EA4EF294EFA
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = PciExpressLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

[Sources]
MockPciExpressLib.cpp

[Packages]
MdePkg/MdePkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec

[LibraryClasses]
GoogleTestLib

[BuildOptions]
MSFT:*_*_*_CC_FLAGS = /EHsc

0 comments on commit 0182bec

Please sign in to comment.