Skip to content

Commit

Permalink
Mock Functions for ReportStatusCodeHandler Library & RegistryNotify ,…
Browse files Browse the repository at this point in the history
… ConnectController in MockUefiBootServicesTableLib (#1122)

## Description

Added Mock Functions for ReportStatusCodeHandler Library &
RegistryNotify , ConnectController in MockUefiBootServicesTableLib

- [ ] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

Unit tests component can call these mock functions success

## Integration Instructions

N/A

---------

Signed-off-by: Vivian Nowka-Keane <[email protected]>
Co-authored-by: Vivian Nowka-Keane <[email protected]>
  • Loading branch information
v-sbolisetti and VivianNK authored Sep 10, 2024
1 parent 5aa1be5 commit a5ba951
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ struct MockUefiBootServicesTableLib {
OUT VOID **Interface)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
gBS_RegisterProtocolNotify,
(IN EFI_GUID *Protocol,
IN EFI_EVENT Event,
OUT VOID **Registration)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
gBS_LocateHandleBuffer,
Expand Down
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_CloseEvent, 1, EFIAP
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_InstallProtocolInterface, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_UninstallProtocolInterface, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_HandleProtocol, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_RegisterProtocolNotify, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_LocateHandleBuffer, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_LocateProtocol, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_CreateEventEx, 6, EFIAPI);
Expand Down Expand Up @@ -120,7 +121,7 @@ static EFI_BOOT_SERVICES LocalBs = {
gBS_UninstallProtocolInterface, // EFI_UNINSTALL_PROTOCOL_INTERFACE
gBS_HandleProtocol, // EFI_HANDLE_PROTOCOL
NULL, // VOID
NULL, // EFI_REGISTER_PROTOCOL_NOTIFY
gBS_RegisterProtocolNotify, // EFI_REGISTER_PROTOCOL_NOTIFY
gBS_LocateHandle, // EFI_LOCATE_HANDLE
gBS_LocateDevicePath, // EFI_LOCATE_DEVICE_PATH
NULL, // EFI_INSTALL_CONFIGURATION_TABLE
Expand Down

0 comments on commit a5ba951

Please sign in to comment.