diff --git a/PolicyServicePkg/PolicyServicePkg.dec b/PolicyServicePkg/PolicyServicePkg.dec index 883c9f77a71..cb1201561bd 100644 --- a/PolicyServicePkg/PolicyServicePkg.dec +++ b/PolicyServicePkg/PolicyServicePkg.dec @@ -14,6 +14,7 @@ [Includes] Include + Test/Mock/Include [LibraryClasses] PolicyLib|Include/Library/PolicyLib.h diff --git a/PolicyServicePkg/Test/Mock/Include/GoogleTest/Library/MockPolicyLibCommon.h b/PolicyServicePkg/Test/Mock/Include/GoogleTest/Library/MockPolicyLibCommon.h new file mode 100644 index 00000000000..127ae05465d --- /dev/null +++ b/PolicyServicePkg/Test/Mock/Include/GoogleTest/Library/MockPolicyLibCommon.h @@ -0,0 +1,33 @@ +/** @file + Google Test mocks for PolicyLibCommon + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_POLICY_LIB_COMMON_LIB_H_ +#define MOCK_POLICY_LIB_COMMON_LIB_H_ + +#include +#include +extern "C" { + #include + #include +} + +struct MockPolicyLibCommon { + MOCK_INTERFACE_DECLARATION (MockPolicyLibCommon); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + GetPolicy, + ( + IN CONST EFI_GUID *PolicyGuid, + OUT UINT64 *Attributes OPTIONAL, + OUT VOID *Policy, + IN OUT UINT16 *PolicySize + ) + ); +}; + +#endif diff --git a/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.cpp b/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.cpp new file mode 100644 index 00000000000..4ea6fce871f --- /dev/null +++ b/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.cpp @@ -0,0 +1,11 @@ +/** @file + Google Test mocks for PolicyLibCommon + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +MOCK_INTERFACE_DEFINITION (MockPolicyLibCommon); +MOCK_FUNCTION_DEFINITION (MockPolicyLibCommon, GetPolicy, 4, EFIAPI); diff --git a/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.inf b/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.inf new file mode 100644 index 00000000000..1e498765f27 --- /dev/null +++ b/PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.inf @@ -0,0 +1,33 @@ +## @file +# Google Test mocks for PolicyLibCommon +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MockPolicyLibCommon + FILE_GUID = 65E475F7-FD55-4008-A0E7-F63495C3C5DC + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + LIBRARY_CLASS = PolicyLib + PI_SPECIFICATION_VERSION = 0x0001000A + +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + MockPolicyLibCommon.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + PolicyServicePkg/PolicyServicePkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS = /EHsc diff --git a/PolicyServicePkg/Test/PolicyServicePkgHostTest.dsc b/PolicyServicePkg/Test/PolicyServicePkgHostTest.dsc index 05e6a9d4ede..8191e98b428 100644 --- a/PolicyServicePkg/Test/PolicyServicePkgHostTest.dsc +++ b/PolicyServicePkg/Test/PolicyServicePkgHostTest.dsc @@ -25,3 +25,7 @@ PolicyServicePkg/PolicyService/DxeMm/UnitTest/DxeMmPolicyUnitTest.inf PolicyServicePkg/PolicyService/Pei/UnitTest/PeiPolicyUnitTest.inf + # + # Build HOST_APPLICATION Libraries With GoogleTest + # + PolicyServicePkg/Test/Mock/Library/GoogleTest/MockPolicyLibCommon/MockPolicyLibCommon.inf