-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MdePkg: Add Google Mock Library for SmmMemLib (#1265)
## Description Added MockSmmMemLib to be used by Googletests - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested Added MockSmmMemLib to GoogleTests and able to successfully include its functions ## Integration Instructions N/A
- Loading branch information
1 parent
dda9d4e
commit 4b45a2b
Showing
4 changed files
with
133 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
83 changes: 83 additions & 0 deletions
83
MdePkg/Test/Mock/Include/GoogleTest/Library/MockSmmMemLib.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,83 @@ | ||
/** @file MockSmmMemLib.h | ||
Google Test mocks for SmmMemLib | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_SMM_MEM_LIB_H_ | ||
#define MOCK_SMM_MEM_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/SmmMemLib.h> | ||
} | ||
|
||
// | ||
// Declarations to handle usage of the SmmMemLib by creating mock | ||
// | ||
struct MockSmmMemLib { | ||
MOCK_INTERFACE_DECLARATION (MockSmmMemLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
BOOLEAN, | ||
SmmIsBufferOutsideSmmValid, | ||
( | ||
IN EFI_PHYSICAL_ADDRESS Buffer, | ||
IN UINT64 Length | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
SmmCopyMemToSmram, | ||
( | ||
OUT VOID *DestinationBuffer, | ||
IN CONST VOID *SourceBuffer, | ||
IN UINTN Length | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
SmmCopyMemFromSmram, | ||
( | ||
OUT VOID *DestinationBuffer, | ||
IN CONST VOID *SourceBuffer, | ||
IN UINTN Length | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
SmmCopyMem, | ||
( | ||
OUT VOID *DestinationBuffer, | ||
IN CONST VOID *SourceBuffer, | ||
IN UINTN Length | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
SmmSetMem, | ||
( | ||
OUT VOID *Buffer, | ||
IN UINTN Length, | ||
IN UINT8 Value | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
BOOLEAN, | ||
SmmCommBufferValid, | ||
( | ||
IN EFI_PHYSICAL_ADDRESS Buffer, | ||
IN UINT64 Length | ||
) | ||
); | ||
}; | ||
|
||
#endif |
16 changes: 16 additions & 0 deletions
16
MdePkg/Test/Mock/Library/GoogleTest/MockSmmMemLib/MockSmmMemLib.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,16 @@ | ||
/** @file MockSmmMemLib.cpp | ||
Google Test mocks for SmmMemLib | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
#include <GoogleTest/Library/MockSmmMemLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockSmmMemLib); | ||
|
||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmIsBufferOutsideSmmValid, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmCopyMemToSmram, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmCopyMemFromSmram, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmCopyMem, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmSetMem, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockSmmMemLib, SmmCommBufferValid, 2, EFIAPI); |
33 changes: 33 additions & 0 deletions
33
MdePkg/Test/Mock/Library/GoogleTest/MockSmmMemLib/MockSmmMemLib.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 MockSmmMemLib.inf | ||
# Google Test mocks for SmmMemLib | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockSmmMemLib | ||
FILE_GUID = FA50DD00-8D5B-437C-91C7-664C55D8C386 | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = SmmMemLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockSmmMemLib.cpp | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |