forked from microsoft/mu_basecore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHERRY-PICK] MdePkg: Bring in mocks from 2311 (microsoft#1139)
## Description Add mocks from 2311 Cherry picked and squashed the following commits: a5ba951 5aa1be5 - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Tested in 202311 CI ## Integration Instructions N/A Signed-off-by: Vivian Nowka-Keane <vnowkakeane@microsoft.com> Co-authored-by: v-sbolisetti <v-sbolisetti@microsoft.com> Co-authored-by: YiTa-AMI <v-yitawu@microsoft.com>
- Loading branch information
Showing
11 changed files
with
291 additions
and
4 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
MdePkg/Test/Mock/Include/GoogleTest/Library/MockDxeServicesTableLib.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,31 @@ | ||
/** @file MockDxeServicesTableLib.h | ||
Google Test mocks for DxeServicesTableLib | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_DXE_SERVICES_TABLE_LIB_H_ | ||
#define MOCK_DXE_SERVICES_TABLE_LIB_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Pi/PiDxeCis.h> | ||
} | ||
|
||
// | ||
// Declarations to handle usage of the DxeServicesTableLib by creating mock | ||
// | ||
struct MockDxeServicesTableLib { | ||
MOCK_INTERFACE_DECLARATION (MockDxeServicesTableLib); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
gDS_Dispatch, | ||
() | ||
); | ||
}; | ||
|
||
#endif // MOCK_UEFI_DXE_SERVICES_TABLE_LIB_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
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
48 changes: 48 additions & 0 deletions
48
MdePkg/Test/Mock/Include/GoogleTest/Ppi/MockPeiReportStatusCodeHandler.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,48 @@ | ||
/** @file MockPeiReportStatusCodeHandler.h | ||
This file declares a mock of Report Status Code Handler PPI. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_PEI_REPORT_STATUS_CODE_HANDLER_PPI_H | ||
#define MOCK_PEI_REPORT_STATUS_CODE_HANDLER_PPI_H | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Pi/PiPeiCis.h> | ||
#include <Ppi/ReportStatusCodeHandler.h> | ||
} | ||
|
||
struct MockPeiReportStatusCodeHandler { | ||
MOCK_INTERFACE_DECLARATION (MockPeiReportStatusCodeHandler); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Register, | ||
(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Unregister, | ||
(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback) | ||
); | ||
}; | ||
|
||
MOCK_INTERFACE_DEFINITION (MockPeiReportStatusCodeHandler); | ||
MOCK_FUNCTION_DEFINITION (MockPeiReportStatusCodeHandler, Register, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockPeiReportStatusCodeHandler, Unregister, 1, EFIAPI); | ||
|
||
EFI_PEI_RSC_HANDLER_PPI PeiRscHandlerPpi = { | ||
Register, | ||
Unregister | ||
}; | ||
|
||
extern "C" { | ||
EFI_PEI_RSC_HANDLER_PPI *PeiRscHandlerPpiServices = &PeiRscHandlerPpi; | ||
} | ||
|
||
#endif |
51 changes: 51 additions & 0 deletions
51
MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockReportStatusCodeHandler.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,51 @@ | ||
/** @file MockReportStatusCodeHandler.h | ||
This file declares a mock of Report Status Code Handler Protocol. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H | ||
#define MOCK_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
|
||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/ReportStatusCodeLib.h> | ||
#include <Protocol/ReportStatusCodeHandler.h> | ||
} | ||
|
||
struct MockReportStatusCodeHandler { | ||
MOCK_INTERFACE_DECLARATION (MockReportStatusCodeHandler); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Register, | ||
( | ||
IN EFI_RSC_HANDLER_CALLBACK Callback, | ||
IN EFI_TPL Tpl) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Unregister, | ||
(IN EFI_RSC_HANDLER_CALLBACK Callback) | ||
); | ||
}; | ||
|
||
MOCK_INTERFACE_DEFINITION (MockReportStatusCodeHandler); | ||
MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Register, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Unregister, 1, EFIAPI); | ||
|
||
EFI_RSC_HANDLER_PROTOCOL RscHandlerProtocol = { | ||
Register, | ||
Unregister | ||
}; | ||
|
||
extern "C" { | ||
EFI_RSC_HANDLER_PROTOCOL *RscHandlerProtocolServices = &RscHandlerProtocol; | ||
} | ||
|
||
#endif |
50 changes: 50 additions & 0 deletions
50
MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmReportStatusCodeHandler.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,50 @@ | ||
/** @file MockSmmReportStatusCodeHandler.h | ||
This file declares a mock of SMM Report Status Code Handler Protocol. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_SMM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H | ||
#define MOCK_SMM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
|
||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Library/ReportStatusCodeLib.h> | ||
#include <Protocol/SmmReportStatusCodeHandler.h> | ||
} | ||
|
||
struct MockReportStatusCodeHandler { | ||
MOCK_INTERFACE_DECLARATION (MockReportStatusCodeHandler); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Register, | ||
( | ||
IN EFI_SMM_RSC_HANDLER_CALLBACK Callback) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Unregister, | ||
(IN EFI_SMM_RSC_HANDLER_CALLBACK Callback) | ||
); | ||
}; | ||
|
||
MOCK_INTERFACE_DEFINITION (MockReportStatusCodeHandler); | ||
MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Register, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Unregister, 1, EFIAPI); | ||
|
||
EFI_SMM_RSC_HANDLER_PROTOCOL SmmRscHandlerProtocol = { | ||
Register, | ||
Unregister | ||
}; | ||
|
||
extern "C" { | ||
EFI_SMM_RSC_HANDLER_PROTOCOL *SmmRscHandlerProtocolServices = &SmmRscHandlerProtocol; | ||
} | ||
|
||
#endif |
36 changes: 36 additions & 0 deletions
36
MdePkg/Test/Mock/Library/GoogleTest/MockDxeServicesTableLib/MockDxeServicesTableLib.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,36 @@ | ||
/** @file MockDxeServicesTableLib.cpp | ||
Google Test mocks for DxeServicesTableLib | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
#include <GoogleTest/Library/MockDxeServicesTableLib.h> | ||
|
||
MOCK_INTERFACE_DEFINITION (MockDxeServicesTableLib); | ||
MOCK_FUNCTION_DEFINITION (MockDxeServicesTableLib, gDS_Dispatch, 0, EFIAPI); | ||
|
||
static EFI_DXE_SERVICES LocalDs = { | ||
{ 0, 0, 0, 0, 0 }, // EFI_TABLE_HEADER | ||
NULL, // EFI_ADD_MEMORY_SPACE | ||
NULL, // EFI_ALLOCATE_MEMORY_SPACE | ||
NULL, // EFI_FREE_MEMORY_SPACE | ||
NULL, // EFI_REMOVE_MEMORY_SPACE | ||
NULL, // EFI_GET_MEMORY_SPACE_DESCRIPTOR | ||
NULL, // EFI_SET_MEMORY_SPACE_ATTRIBUTES | ||
NULL, // EFI_GET_MEMORY_SPACE_MAP | ||
NULL, // EFI_ADD_IO_SPACE | ||
NULL, // EFI_ALLOCATE_IO_SPACE | ||
NULL, // EFI_FREE_IO_SPACE | ||
NULL, // EFI_REMOVE_IO_SPACE | ||
NULL, // EFI_GET_IO_SPACE_DESCRIPTOR | ||
NULL, // EFI_GET_IO_SPACE_MAP | ||
gDS_Dispatch, // EFI_DISPATCH | ||
NULL, // EFI_SCHEDULE | ||
NULL, // EFI_TRUST | ||
NULL, // EFI_PROCESS_FIRMWARE_VOLUME | ||
NULL // EFI_SET_MEMORY_SPACE_CAPABILITIES | ||
}; | ||
|
||
extern "C" { | ||
EFI_DXE_SERVICES *gDS = &LocalDs; | ||
} |
32 changes: 32 additions & 0 deletions
32
MdePkg/Test/Mock/Library/GoogleTest/MockDxeServicesTableLib/MockDxeServicesTableLib.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,32 @@ | ||
## @file MockDxeServicesTableLib.inf | ||
# Mock implementation of the DXE Services Table Library. | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010005 | ||
BASE_NAME = MockDxeServicesTableLib | ||
FILE_GUID = 8d9ce22b-2cf3-4646-ad0b-ce3cf1aea84d | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
LIBRARY_CLASS = DxeServicesTableLib | ||
|
||
# | ||
# VALID_ARCHITECTURES = IA32 X64 EBC | ||
# | ||
|
||
[Sources] | ||
MockDxeServicesTableLib.cpp | ||
|
||
[LibraryClasses] | ||
GoogleTestLib | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
|
||
[BuildOptions] | ||
MSFT:*_*_*_CC_FLAGS = /EHsc |
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
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