From e289b893a158d1421bfff6b2cd3528c2f1efa1c7 Mon Sep 17 00:00:00 2001 From: Kane Chen Date: Thu, 5 Dec 2024 15:46:21 +0800 Subject: [PATCH] Add MockVariablePolicyHelperLib --- MdePkg/Test/MdePkgHostTest.dsc | 1 + .../Library/MockVariablePolicyHelperLib.h | 38 +++++++++++++++++++ .../MockVariablePolicyHelperLib.cpp | 11 ++++++ .../MockVariablePolicyHelperLib.inf | 32 ++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockVariablePolicyHelperLib.h create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.cpp create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc index 4e25b36fb4..cbc615e335 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -71,4 +71,5 @@ MdePkg/Test/Mock/Library/GoogleTest/MockPciSegmentLib/MockPciSegmentLib.inf MdePkg/Test/Mock/Library/GoogleTest/MockReportStatusCodeLib/MockReportStatusCodeLib.inf MdePkg/Test/Mock/Library/GoogleTest/MockPostCodeLib/MockPostCodeLib.inf + MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf # MU_CHANGE [END] diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockVariablePolicyHelperLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockVariablePolicyHelperLib.h new file mode 100644 index 0000000000..57721f3e84 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockVariablePolicyHelperLib.h @@ -0,0 +1,38 @@ +/** @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 +#include +extern "C" { + #include + #include +} + +// +// Declarations to handle usage of the VariablePolicyHelperLib by creating mock +// +struct MockVariablePolicyHelperLib { + MOCK_INTERFACE_DECLARATION (MockVariablePolicyHelperLib); + + 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) + ); +}; + +#endif diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.cpp new file mode 100644 index 0000000000..9844175256 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.cpp @@ -0,0 +1,11 @@ +/** @file + Google Test mocks for VariablePolicyHelperLib + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +MOCK_INTERFACE_DEFINITION (MockVariablePolicyHelperLib); +MOCK_FUNCTION_DEFINITION (MockVariablePolicyHelperLib, RegisterBasicVariablePolicy, 8, EFIAPI); diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf new file mode 100644 index 0000000000..3e7ee4030d --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf @@ -0,0 +1,32 @@ +## @file +# 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 + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS = /EHsc