Skip to content

Commit

Permalink
Added Mock GoogleTest folder for PolicyLibCommon (microsoft#780)
Browse files Browse the repository at this point in the history
Issue microsoft#867

cherry-pick from c8f9883

Please ensure you have read the [contribution
docs](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md) prior
to submitting the pull request. In particular,
[pull request
guidelines](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md#pull-request-best-practices).

Added Mock GoogleTest folder for PolicyLibCommon

For each item, place an "x" in between `[` and `]` if true. Example:
`[x]`.
_(you can also check items in the GitHub UI)_

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [ ] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [ ] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

Added this mock lib definition and declaration to one of the library
under Gen 11 and made sure local build is successful

N/A
  • Loading branch information
v-bhavanisu authored and cfernald committed Jun 17, 2024
1 parent 17d6442 commit 91008b9
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions PolicyServicePkg/PolicyServicePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

[Includes]
Include
Test/Mock/Include

[LibraryClasses]
PolicyLib|Include/Library/PolicyLib.h
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Library/PolicyLib.h>
}

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @file
Google Test mocks for PolicyLibCommon
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <GoogleTest/Library/MockPolicyLibCommon.h>

MOCK_INTERFACE_DEFINITION (MockPolicyLibCommon);
MOCK_FUNCTION_DEFINITION (MockPolicyLibCommon, GetPolicy, 4, EFIAPI);
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions PolicyServicePkg/Test/PolicyServicePkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 91008b9

Please sign in to comment.