-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mock functions under MockUefiLib and Create Mock for AcpiTable, F…
…irmwareVolume2 and AcpiSystemDescriptionTable protocol (#1106) ## Description Add mock functions under MockUefiLib and Create Mock for AcpiTable, FirmwareVolume2 and AcpiSystemDescriptionTable protocol - [ ] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [x] Includes tests? - [ ] Includes documentation? ## How This Was Tested Unit tests component can call these mock functions success ## Integration Instructions N/A --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Ethan Hsu <Eathonhsu@gmail.com> Signed-off-by: Vivian Nowka-Keane <vnowkakeane@microsoft.com> Signed-off-by: TsunFeng <v-tshuang@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Aaron Pop <aaronpop@microsoft.com> Co-authored-by: Michael Kubacki <michael.kubacki@microsoft.com> Co-authored-by: Taylor Beebe <tabeebe@microsoft.com> Co-authored-by: pohanch <125842322+pohanch@users.noreply.github.com> Co-authored-by: kenlautner <85201046+kenlautner@users.noreply.github.com> Co-authored-by: Oliver Smith-Denny <osde@linux.microsoft.com> Co-authored-by: Sean Brogan <sean.brogan@microsoft.com> Co-authored-by: Aaron <105021049+apop5@users.noreply.github.com> Co-authored-by: yhsu3 <yhsu3@lenovo.com> Co-authored-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
1 parent
a952e84
commit 456eada
Showing
21 changed files
with
657 additions
and
5 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
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
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 |
139 changes: 139 additions & 0 deletions
139
MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockAcpiSystemDescriptionTable.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,139 @@ | ||
/** @file MockAcpiSystemDescriptionTable.h | ||
This file declares a mock of ACPI system description tables protocol. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_ACPI_SYSTEM_DESCRIPTION_TABLE_H_ | ||
#define MOCK_ACPI_SYSTEM_DESCRIPTION_TABLE_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
|
||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Protocol/AcpiSystemDescriptionTable.h> | ||
} | ||
|
||
struct MockAcpiSdtProtocol { | ||
MOCK_INTERFACE_DECLARATION (MockAcpiSdtProtocol); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
GetAcpiTable, | ||
( | ||
IN UINTN Index, | ||
OUT EFI_ACPI_SDT_HEADER **Table, | ||
OUT EFI_ACPI_TABLE_VERSION *Version, | ||
OUT UINTN *TableKey | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
RegisterNotify, | ||
( | ||
IN BOOLEAN Register, | ||
IN EFI_ACPI_NOTIFICATION_FN Notification | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Open, | ||
( | ||
IN VOID *Buffer, | ||
OUT EFI_ACPI_HANDLE *Handle | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
OpenSdt, | ||
( | ||
IN UINTN TableKey, | ||
OUT EFI_ACPI_HANDLE *Handle | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
Close, | ||
( | ||
IN EFI_ACPI_HANDLE Handle | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
GetChild, | ||
( | ||
IN EFI_ACPI_HANDLE ParentHandle, | ||
IN OUT EFI_ACPI_HANDLE *Handle | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
GetOption, | ||
( | ||
IN EFI_ACPI_HANDLE Handle, | ||
IN UINTN Index, | ||
OUT EFI_ACPI_DATA_TYPE *DataType, | ||
OUT CONST VOID **Data, | ||
OUT UINTN *DataSize | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
SetOption, | ||
( | ||
IN EFI_ACPI_HANDLE Handle, | ||
IN UINTN Index, | ||
IN CONST VOID *Data, | ||
IN UINTN DataSize | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
FindPath, | ||
( | ||
IN EFI_ACPI_HANDLE HandleIn, | ||
IN VOID *AcpiPath, | ||
OUT EFI_ACPI_HANDLE *HandleOut | ||
) | ||
); | ||
}; | ||
|
||
MOCK_INTERFACE_DEFINITION (MockAcpiSdtProtocol); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, GetAcpiTable, 4, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, RegisterNotify, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, Open, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, OpenSdt, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, Close, 1, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, GetChild, 2, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, GetOption, 5, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, SetOption, 4, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiSdtProtocol, FindPath, 3, EFIAPI); | ||
|
||
EFI_ACPI_SDT_PROTOCOL ACPI_SDT_PROTOCOL_INSTANCE = { | ||
0, | ||
GetAcpiTable, // EFI_ACPI_TABLE_INSTALL_ACPI_TABLE | ||
RegisterNotify, // EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE | ||
Open, | ||
OpenSdt, | ||
Close, | ||
GetChild, | ||
GetOption, | ||
SetOption, | ||
FindPath | ||
}; | ||
|
||
extern "C" { | ||
EFI_ACPI_SDT_PROTOCOL *gAcpiSdtProtocol = &ACPI_SDT_PROTOCOL_INSTANCE; | ||
} | ||
|
||
#endif // MOCK_ACPI_SYSTEM_DESCRIPTION_TABLE_H_ |
56 changes: 56 additions & 0 deletions
56
MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockAcpiTable.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,56 @@ | ||
/** @file MockAcpiTable.h | ||
This file declares a mock of Acpi table protocol. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
|
||
#ifndef MOCK_ACPI_TABLE_H_ | ||
#define MOCK_ACPI_TABLE_H_ | ||
|
||
#include <Library/GoogleTestLib.h> | ||
#include <Library/FunctionMockLib.h> | ||
|
||
extern "C" { | ||
#include <Uefi.h> | ||
#include <Protocol/AcpiTable.h> | ||
} | ||
|
||
struct MockAcpiTableProtocol { | ||
MOCK_INTERFACE_DECLARATION (MockAcpiTableProtocol); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
InstallAcpiTable, | ||
( | ||
IN EFI_ACPI_TABLE_PROTOCOL *This, | ||
IN VOID *AcpiTableBuffer, | ||
IN UINTN AcpiTableBufferSize, | ||
OUT UINTN *TableKey | ||
) | ||
); | ||
|
||
MOCK_FUNCTION_DECLARATION ( | ||
EFI_STATUS, | ||
UninstallAcpiTable, | ||
( | ||
IN EFI_ACPI_TABLE_PROTOCOL *This, | ||
IN UINTN TableKey | ||
) | ||
); | ||
}; | ||
|
||
MOCK_INTERFACE_DEFINITION (MockAcpiTableProtocol); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiTableProtocol, InstallAcpiTable, 4, EFIAPI); | ||
MOCK_FUNCTION_DEFINITION (MockAcpiTableProtocol, UninstallAcpiTable, 2, EFIAPI); | ||
|
||
EFI_ACPI_TABLE_PROTOCOL ACPI_TABLE_PROTOCOL_INSTANCE = { | ||
InstallAcpiTable, // EFI_ACPI_TABLE_INSTALL_ACPI_TABLE | ||
UninstallAcpiTable // EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE | ||
}; | ||
|
||
extern "C" { | ||
EFI_ACPI_TABLE_PROTOCOL *gAcpiTableProtocol = &ACPI_TABLE_PROTOCOL_INSTANCE; | ||
} | ||
|
||
#endif // MOCK_ACPI_TABLE_H_ |
Oops, something went wrong.