-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create mocks for PlatformHookLib and PciLib (#1094)
Create mocks for PlatformHookLib and PciLib - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [x] Includes tests? - [ ] Includes documentation? Unit tests component can call PlatformHookLib and PciLib mock functions success N/A
- Loading branch information
Showing
8 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPlatformHookLib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** @file MockPlatformHookLib.h | ||
Google Test mocks for PlatformHookLib | ||
Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_PLATFORM_HOOK_LIB_ | ||
#define MOCK_PLATFORM_HOOK_LIB_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/PlatformHookLib.h> | ||
} | ||
|
||
struct MockPlatformHookLib { | ||
MOCK_INTERFACE_DECLARATION (MockPlatformHookLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
RETURN_STATUS, | ||
PlatformHookSerialPortInitialize, | ||
( | ||
|
||
) | ||
); | ||
}; | ||
|
||
#endif |
13 changes: 13 additions & 0 deletions
13
MdeModulePkg/Test/Mock/Library/GoogleTest/MockPlatformHookLib/MockPlatformHookLib.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** @file MockPlatformHookLib.cpp | ||
Mock instance of the PCI Host Bridge Library. | ||
Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockPlatformHookLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockPlatformHookLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockPlatformHookLib, PlatformHookSerialPortInitialize, 0, EFIAPI); |
36 changes: 36 additions & 0 deletions
36
MdeModulePkg/Test/Mock/Library/GoogleTest/MockPlatformHookLib/MockPlatformHookLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## @file MockPlatformHookLib.inf | ||
# Mock instance of the Platform hook library. | ||
# | ||
# Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockPlatformHookLib | ||
FILE_GUID = B7721E18-FC59-4333-AE5E-B07EE71D6737 | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = PlatformHookLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build | ||
# tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockPlatformHookLib.cpp | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
MdePkg/Test/Mock/Include/GoogleTest/Library/MockPciLib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/** @file MockPciLib.h | ||
Google Test mocks for PciLib | ||
Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_PCI_LIB_H_ | ||
#define MOCK_PCI_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/PciLib.h> | ||
} | ||
|
||
struct MockPciLib { | ||
MOCK_INTERFACE_DECLARATION (MockPciLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT8, | ||
PciRead8, | ||
( | ||
IN UINTN Address | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT8, | ||
PciWrite8, | ||
( | ||
IN UINTN Address, | ||
IN UINT8 Value | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT8, | ||
PciOr8, | ||
( | ||
IN UINTN Address, | ||
IN UINT8 OrData | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT8, | ||
PciAnd8, | ||
( | ||
IN UINTN Address, | ||
IN UINT8 AndData | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT16, | ||
PciRead16, | ||
( | ||
IN UINTN Address | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT16, | ||
PciWrite16, | ||
( | ||
IN UINTN Address, | ||
IN UINT16 Value | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT16, | ||
PciOr16, | ||
( | ||
IN UINTN Address, | ||
IN UINT16 OrData | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT16, | ||
PciAnd16, | ||
( | ||
IN UINTN Address, | ||
IN UINT16 AndData | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT32, | ||
PciRead32, | ||
( | ||
IN UINTN Address | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT32, | ||
PciWrite32, | ||
( | ||
IN UINTN Address, | ||
IN UINT32 Value | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT32, | ||
PciOr32, | ||
( | ||
IN UINTN Address, | ||
IN UINT32 OrData | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
UINT32, | ||
PciAnd32, | ||
( | ||
IN UINTN Address, | ||
IN UINT32 AndData | ||
) | ||
); | ||
}; | ||
|
||
#endif |
23 changes: 23 additions & 0 deletions
23
MdePkg/Test/Mock/Library/GoogleTest/MockPciLib/MockPciLib.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** @file MockPciLib.cpp | ||
Google Test mocks for PciLib | ||
Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockPciLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockPciLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciRead8, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciWrite8, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciOr8, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciAnd8, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciRead16, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciWrite16, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciOr16, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciAnd16, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciRead32, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciWrite32, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciOr32, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPciLib, PciAnd32, 2, EFIAPI); |
33 changes: 33 additions & 0 deletions
33
MdePkg/Test/Mock/Library/GoogleTest/MockPciLib/MockPciLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## @file MockPciLib.inf | ||
# Google Test mocks for PciLib | ||
# | ||
# Copyright (c) 2023, Intel Corporation. All rights reserved. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockPciLib | ||
FILE_GUID = B64B61FF-8682-482E-A4DA-2BB8A7FB24AE | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = PciLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockPciLib.cpp | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |