-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MdePkg: Test: Add Mock interface for MmServices Table
Add the initial Mock interface for the MmServices Table. Currently Only the MmLocateProtocol has been mocked. Signed-off-by: Girish Mahadevan <[email protected]> Reviewed-by: Jeff Brasen <[email protected]>
- Loading branch information
1 parent
9cc98f1
commit 741afa7
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
MdePkg/Test/Mock/Include/GoogleTest/Library/MockMmStTableLib.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef MOCK_MMST_TABLE_LIB_H | ||
#define MOCK_MMST_TABLE_LIB_H | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/MmServicesTableLib.h> | ||
} | ||
|
||
struct MockMmStTableLib { | ||
MOCK_INTERFACE_DECLARATION (MockMmStTableLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
gMmst_MmLocateProtocol, | ||
(IN EFI_GUID *Protocol, | ||
IN VOID *Registration OPTIONAL, | ||
OUT VOID **Interface) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
gMmst_MmInstallProtocolInterface, | ||
(IN OUT EFI_HANDLE *UserHandle, | ||
IN EFI_GUID *Protocol, | ||
IN EFI_INTERFACE_TYPE InterfaceType, | ||
IN VOID *Interface) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
gMmst_MmRegisterProtocolNotify, | ||
(IN CONST EFI_GUID *Protocol, | ||
IN EFI_MM_NOTIFY_FN Function, | ||
OUT VOID **Registration) | ||
); | ||
}; | ||
|
||
#endif // MOCK_MMST_TABLE_LIB_H |
49 changes: 49 additions & 0 deletions
49
MdePkg/Test/Mock/Library/GoogleTest/MockMmStTableLib/MockMmStTableLib.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** @file | ||
Google Test mocks for Mm Services Table | ||
SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
#include <GoogleTest/Library/MockMmStTableLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION(MockMmStTableLib); | ||
|
||
MOCK_FUNCTION_DEFINITION(MockMmStTableLib, gMmst_MmLocateProtocol, 3, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION(MockMmStTableLib, gMmst_MmInstallProtocolInterface, 4, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION(MockMmStTableLib, gMmst_MmRegisterProtocolNotify, 3, EFIAPI); | ||
|
||
static EFI_MM_SYSTEM_TABLE localMmSt = { | ||
{0}, // EFI_TABLE_HEADER | ||
|
||
NULL, // MmFirmwareVendor | ||
0, // MmFirmwareRevision | ||
NULL, // MmInstallConfigurationTable | ||
{ // MmIo | ||
NULL, | ||
NULL | ||
}, | ||
NULL, // MmAllocatePool | ||
NULL, // MmFreePool | ||
NULL, // MmAllocatePages | ||
NULL, // MmFreePages | ||
NULL, // MmStartupThisAp | ||
0, // CurrentlyExecutingCpu | ||
0, // NumberOfCpus | ||
NULL, // CpuSaveStateSize | ||
NULL, // CpuSaveState | ||
0, // NumberOfTableEntries | ||
NULL, // MmConfigurationTable | ||
gMmst_MmInstallProtocolInterface, // MmInstallProtocolInterface | ||
NULL, // MmUninstallProtocolInterface | ||
NULL, // MmHandleProtocol | ||
gMmst_MmRegisterProtocolNotify, // MmRegisterProtocolNotify | ||
NULL, // MmLocateHandle | ||
gMmst_MmLocateProtocol, // MmLocateProtocol | ||
NULL, // MmiManage | ||
NULL, // MmiHandlerRegister | ||
NULL, // MmiHandlerUnRegister | ||
}; | ||
|
||
extern "C" { | ||
EFI_MM_SYSTEM_TABLE* gMmst = &localMmSt; | ||
} |
33 changes: 33 additions & 0 deletions
33
MdePkg/Test/Mock/Library/GoogleTest/MockMmStTableLib/MockMmStTableLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## @file | ||
#Google Test mocks for Mm Services Table | ||
# | ||
# SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockMmStTableLib | ||
FILE_GUID = 9d5acf7f-64cd-44b3-a0f6-99e6c30dd6ae | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = MmServicesTableLib | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 | ||
# | ||
|
||
[Sources] | ||
MockMmStTableLib.cpp | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |