Skip to content

Commit a46d41a

Browse files
authored
Create Mock for PostCodeLib (#1168)
## Description Create Mock for PostCodeLib For details on how to complete these options and their meaning refer to [CONTRIBUTING.md](https://github.com/microsoft/mu/blob/HEAD/CONTRIBUTING.md). - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested Unit tests component can call these mock functions success ## Integration Instructions N/A
1 parent a3e1348 commit a46d41a

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

MdePkg/Test/MdePkgHostTest.dsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@
7070
MdePkg/Test/Mock/Library/GoogleTest/MockCpuLib/MockCpuLib.inf
7171
MdePkg/Test/Mock/Library/GoogleTest/MockPciSegmentLib/MockPciSegmentLib.inf
7272
MdePkg/Test/Mock/Library/GoogleTest/MockReportStatusCodeLib/MockReportStatusCodeLib.inf
73+
MdePkg/Test/Mock/Library/GoogleTest/MockPostCodeLib/MockPostCodeLib.inf
7374
# MU_CHANGE [END]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/** @file MockPostCodeLib.h
2+
Google Test mocks for PostCodeLib
3+
4+
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
5+
Copyright (c) Microsoft Corporation.
6+
SPDX-License-Identifier: BSD-2-Clause-Patent
7+
**/
8+
9+
#ifndef MOCK_POST_CODE_LIB_H_
10+
#define MOCK_POST_CODE_LIB_H_
11+
12+
#include <Library/GoogleTestLib.h>
13+
#include <Library/FunctionMockLib.h>
14+
extern "C" {
15+
#include <Uefi.h>
16+
#include <Library/PostCodeLib.h>
17+
}
18+
19+
struct MockPostCodeLib {
20+
MOCK_INTERFACE_DECLARATION (MockPostCodeLib);
21+
22+
MOCK_FUNCTION_DECLARATION (
23+
UINT32,
24+
PostCode,
25+
(
26+
IN UINT32 Value
27+
)
28+
);
29+
MOCK_FUNCTION_DECLARATION (
30+
UINT32,
31+
PostCodeWithDescription,
32+
(
33+
IN UINT32 Value,
34+
IN CONST CHAR8 *Description OPTIONAL
35+
)
36+
);
37+
38+
MOCK_FUNCTION_DECLARATION (
39+
BOOLEAN,
40+
PostCodeEnabled,
41+
(
42+
43+
)
44+
);
45+
46+
MOCK_FUNCTION_DECLARATION (
47+
BOOLEAN,
48+
PostCodeDescriptionEnabled,
49+
(
50+
51+
)
52+
);
53+
};
54+
55+
#endif //MOCK_PCI_EXPRESS_LIB_H_
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** @file MockPostCodeLib.cpp
2+
Google Test mocks for PostCodeLib
3+
4+
Copyright (c) Microsoft Corporation.
5+
SPDX-License-Identifier: BSD-2-Clause-Patent
6+
**/
7+
8+
#include <GoogleTest/Library/MockPostCodeLib.h>
9+
10+
MOCK_INTERFACE_DEFINITION (MockPostCodeLib);
11+
MOCK_FUNCTION_DEFINITION (MockPostCodeLib, PostCode, 1, EFIAPI);
12+
MOCK_FUNCTION_DEFINITION (MockPostCodeLib, PostCodeWithDescription, 2, EFIAPI);
13+
MOCK_FUNCTION_DEFINITION (MockPostCodeLib, PostCodeEnabled, 0, EFIAPI);
14+
MOCK_FUNCTION_DEFINITION (MockPostCodeLib, PostCodeDescriptionEnabled, 0, EFIAPI);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## @file MockPostCodeLib.inf
2+
# Google Test mocks for PostCodeLib
3+
#
4+
# Copyright (c) Microsoft Corporation.
5+
# SPDX-License-Identifier: BSD-2-Clause-Patent
6+
##
7+
8+
[Defines]
9+
INF_VERSION = 0x00010005
10+
BASE_NAME = MockPostCodeLib
11+
FILE_GUID = 25BF192B-A519-4997-823A-AFEC2C953627
12+
MODULE_TYPE = HOST_APPLICATION
13+
VERSION_STRING = 1.0
14+
LIBRARY_CLASS = PostCodeLib
15+
16+
#
17+
# The following information is for reference only and not required by the build tools.
18+
#
19+
# VALID_ARCHITECTURES = IA32 X64
20+
#
21+
22+
[Sources]
23+
MockPostCodeLib.cpp
24+
25+
[Packages]
26+
MdePkg/MdePkg.dec
27+
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
28+
29+
[LibraryClasses]
30+
GoogleTestLib
31+
32+
[BuildOptions]
33+
MSFT:*_*_*_CC_FLAGS = /EHsc

0 commit comments

Comments
 (0)