Skip to content

Commit 8fa7e0b

Browse files
VivianNKv-bhavanisu
authored andcommitted
[CHERRY-PICK] BoardModulePkg: Added Mock library for BiosIdLib (#301)
## Description Added a gmock for GoogleTests that pull in BiosIdLib. Cherry picked from edk2_platforms [c53db4dc8bbc6cec6016792b9e08b1f0630498ae](tianocore/edk2-platforms@c53db4d) Amended to add newline in header file description. - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Consumed mock in GoogleTest ## Integration Instructions N/A Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com> Co-authored-by: Bhavani Subramanian <v-bhavanisu@microsoft.com>
1 parent 7de15a2 commit 8fa7e0b

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

BoardModulePkg/BoardModulePkg.dec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
[Includes]
2424
Include
25+
Test/Mock/Include
2526

2627
[LibraryClasses]
2728
## @libraryclass Provide services to access CMOS area.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## @file BoardModulePkgHostTest.dsc
2+
#
3+
# BoardModulePkg DSC file used to build host-based unit tests.
4+
#
5+
# Copyright (c) Microsoft Corporation.
6+
# SPDX-License-Identifier: BSD-2-Clause-Patent
7+
#
8+
##
9+
10+
[Defines]
11+
PLATFORM_NAME = BoardModulePkgHostTest
12+
PLATFORM_GUID = 67275336-A324-4F69-BD38-70A4C7898F06
13+
PLATFORM_VERSION = 0.1
14+
DSC_SPECIFICATION = 0x00010005
15+
OUTPUT_DIRECTORY = Build/BoardModulePkg/HostTest
16+
SUPPORTED_ARCHITECTURES = IA32|X64
17+
BUILD_TARGETS = NOOPT
18+
SKUID_IDENTIFIER = DEFAULT
19+
20+
!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
21+
22+
[LibraryClasses]
23+
24+
[Components]
25+
#
26+
# Build HOST_APPLICATIONs that test the BoardModulePkg
27+
#
28+
29+
#
30+
# Build HOST_APPLICATION Libraries With GoogleTest
31+
#
32+
BoardModulePkg/Test/Mock/Library/GoogleTest/MockBiosIdLib/MockBiosIdLib.inf
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/** @file MockBiosIdLib.h
2+
Google Test mocks for BiosIdLib
3+
4+
Copyright (c) Microsoft Corporation.
5+
SPDX-License-Identifier: BSD-2-Clause-Patent
6+
**/
7+
8+
#ifndef MOCK_BIOS_ID_LIB_H_
9+
#define MOCK_BIOS_ID_LIB_H_
10+
11+
#include <Library/GoogleTestLib.h>
12+
#include <Library/FunctionMockLib.h>
13+
extern "C" {
14+
#include <Uefi.h>
15+
#include <Pi/PiBootMode.h>
16+
#include <Library/BiosIdLib.h>
17+
}
18+
19+
struct MockBiosIdLib {
20+
MOCK_INTERFACE_DECLARATION (MockBiosIdLib);
21+
22+
MOCK_FUNCTION_DECLARATION (
23+
EFI_STATUS,
24+
GetBiosId,
25+
(
26+
OUT BIOS_ID_IMAGE *BiosIdImage OPTIONAL
27+
)
28+
);
29+
30+
MOCK_FUNCTION_DECLARATION (
31+
EFI_STATUS,
32+
GetBiosVersionDateTime,
33+
(
34+
OUT CHAR16 *BiosVersion, OPTIONAL
35+
OUT CHAR16 *BiosReleaseDate, OPTIONAL
36+
OUT CHAR16 *BiosReleaseTime OPTIONAL
37+
)
38+
);
39+
};
40+
41+
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/** @file MockBiosIdLib.cpp
2+
Google Test mocks for BiosIdLib
3+
4+
Copyright (c) Microsoft Corporation.
5+
SPDX-License-Identifier: BSD-2-Clause-Patent
6+
**/
7+
8+
#include <GoogleTest/Library/MockBiosIdLib.h>
9+
10+
MOCK_INTERFACE_DEFINITION (MockBiosIdLib);
11+
MOCK_FUNCTION_DEFINITION (MockBiosIdLib, GetBiosId, 1, EFIAPI);
12+
MOCK_FUNCTION_DEFINITION (MockBiosIdLib, GetBiosVersionDateTime, 3, EFIAPI);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## @file MockBiosIdLib.inf
2+
# Google Test mock for BiosIdLib
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 = MockBiosIdLib
11+
FILE_GUID = FD03FA6D-7447-499C-B3AF-D89450F7739A
12+
MODULE_TYPE = HOST_APPLICATION
13+
VERSION_STRING = 1.0
14+
LIBRARY_CLASS = BiosIdLib
15+
PI_SPECIFICATION_VERSION = 0x0001000A
16+
17+
#
18+
# VALID_ARCHITECTURES = IA32 X64
19+
#
20+
21+
[Sources]
22+
MockBiosIdLib.cpp
23+
24+
[Packages]
25+
MdePkg/MdePkg.dec
26+
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
27+
BoardModulePkg/BoardModulePkg.dec
28+
29+
[LibraryClasses]
30+
GoogleTestLib
31+
32+
[BuildOptions]
33+
MSFT:*_*_*_CC_FLAGS = /EHsc

0 commit comments

Comments
 (0)