-
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.
Add MockVariablePolicyHelperLib (#1238)
## Description Provide MockVariablePolicyHelperLib for GoogleTest. - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [x] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested Tested in module integrated with this MockVariablePolicyHelperLib and pass ## Integration Instructions N/A --------- Co-authored-by: Aaron <[email protected]>
- Loading branch information
1 parent
3def184
commit 7161cac
Showing
4 changed files
with
129 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
81 changes: 81 additions & 0 deletions
81
MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockVariablePolicyHelperLib.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,81 @@ | ||
/** @file MockVariablePolicyHelper.h | ||
Google Test mocks for VariablePolicyHelper | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_VARIABLE_POLICY_HELPER_LIB_H_ | ||
#define MOCK_VARIABLE_POLICY_HELPER_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Protocol/VariablePolicy.h> | ||
} | ||
|
||
// | ||
// Declarations to handle usage of the VariablePolicyHelperLib by creating mock | ||
// | ||
struct MockVariablePolicyHelperLib { | ||
MOCK_INTERFACE_DECLARATION (MockVariablePolicyHelperLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
CreateBasicVariablePolicy, | ||
(IN CONST EFI_GUID *Namespace, | ||
IN CONST CHAR16 *Name OPTIONAL, | ||
IN UINT32 MinSize, | ||
IN UINT32 MaxSize, | ||
IN UINT32 AttributesMustHave, | ||
IN UINT32 AttributesCantHave, | ||
IN UINT8 LockPolicyType, | ||
OUT VARIABLE_POLICY_ENTRY **NewEntry) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
CreateVarStateVariablePolicy, | ||
(IN CONST EFI_GUID *Namespace, | ||
IN CONST CHAR16 *Name OPTIONAL, | ||
IN UINT32 MinSize, | ||
IN UINT32 MaxSize, | ||
IN UINT32 AttributesMustHave, | ||
IN UINT32 AttributesCantHave, | ||
IN CONST EFI_GUID *VarStateNamespace, | ||
IN UINT8 VarStateValue, | ||
IN CONST CHAR16 *VarStateName, | ||
OUT VARIABLE_POLICY_ENTRY **NewEntry) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
RegisterBasicVariablePolicy, | ||
(IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy, | ||
IN CONST EFI_GUID *Namespace, | ||
IN CONST CHAR16 *Name OPTIONAL, | ||
IN UINT32 MinSize, | ||
IN UINT32 MaxSize, | ||
IN UINT32 AttributesMustHave, | ||
IN UINT32 AttributesCantHave, | ||
IN UINT8 LockPolicyType) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
RegisterVarStateVariablePolicy, | ||
(IN EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy, | ||
IN CONST EFI_GUID *Namespace, | ||
IN CONST CHAR16 *Name OPTIONAL, | ||
IN UINT32 MinSize, | ||
IN UINT32 MaxSize, | ||
IN UINT32 AttributesMustHave, | ||
IN UINT32 AttributesCantHave, | ||
IN CONST EFI_GUID *VarStateNamespace, | ||
IN CONST CHAR16 *VarStateName, | ||
IN UINT8 VarStateValue) | ||
); | ||
}; | ||
|
||
#endif |
14 changes: 14 additions & 0 deletions
14
.../Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.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,14 @@ | ||
/** @file MockVariablePolicyHelperLib.cpp | ||
Google Test mocks for VariablePolicyHelperLib | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#include <GoogleTest/Library/MockVariablePolicyHelperLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockVariablePolicyHelperLib); | ||
MOCK_FUNCTION_DEFINITION (MockVariablePolicyHelperLib, CreateBasicVariablePolicy, 8, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockVariablePolicyHelperLib, CreateVarStateVariablePolicy, 10, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockVariablePolicyHelperLib, RegisterBasicVariablePolicy, 8, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockVariablePolicyHelperLib, RegisterVarStateVariablePolicy, 10, EFIAPI); |
33 changes: 33 additions & 0 deletions
33
.../Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.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 MockVariablePolicyHelperLib.inf | ||
# Mock Variable Policy Library implementation. | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockVariablePolicyHelperLib | ||
FILE_GUID = 251633CE-1FE7-4500-BF0A-CF3B2B52B9EE | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = VariablePolicyHelperLib | ||
PI_SPECIFICATION_VERSION = 0x0001000A | ||
|
||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockVariablePolicyHelperLib.cpp | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |