MdePkg/MockUefiLib: Added new mock functions.

Signed-off-by: v-sbolisetti <v-sbolisetti@microsoft.com>
This commit is contained in:
v-sbolisetti 2024-10-17 17:45:02 -05:00 committed by mergify[bot]
parent 87e2ee60d4
commit ea59e39c85
2 changed files with 382 additions and 4 deletions

View File

@ -2,6 +2,7 @@
Google Test mocks for UefiLib Google Test mocks for UefiLib
Copyright (c) 2022, Intel Corporation. All rights reserved. Copyright (c) 2022, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
@ -18,21 +19,354 @@ extern "C" {
struct MockUefiLib { struct MockUefiLib {
MOCK_INTERFACE_DECLARATION (MockUefiLib); MOCK_INTERFACE_DECLARATION (MockUefiLib);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiGetSystemConfigurationTable,
(IN EFI_GUID *TableGuid,
OUT VOID **Table)
);
MOCK_FUNCTION_DECLARATION (
EFI_EVENT,
EfiCreateProtocolNotifyEvent,
(IN EFI_GUID *ProtocolGuid,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction,
IN VOID *NotifyContext OPTIONAL,
OUT VOID **Registration)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiNamedEventListen,
(IN CONST EFI_GUID *Name,
IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction,
IN CONST VOID *NotifyContext OPTIONAL,
OUT VOID *Registration OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiNamedEventSignal,
(IN CONST EFI_GUID *Name)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiEventGroupSignal,
(IN CONST EFI_GUID *EventGroup)
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiEventEmptyFunction,
(IN EFI_EVENT Event,
IN VOID *Context)
);
MOCK_FUNCTION_DECLARATION (
EFI_TPL,
EfiGetCurrentTpl,
()
);
MOCK_FUNCTION_DECLARATION (
EFI_LOCK *,
EfiInitializeLock,
(IN OUT EFI_LOCK *Lock,
IN EFI_TPL Priority)
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiAcquireLock,
(IN EFI_LOCK *Lock)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiAcquireLockOrFail,
(IN EFI_LOCK *Lock)
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiReleaseLock,
(IN EFI_LOCK *Lock)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiTestManagedDevice,
(IN CONST EFI_HANDLE ControllerHandle,
IN CONST EFI_HANDLE DriverBindingHandle,
IN CONST EFI_GUID *ProtocolGuid)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiTestChildHandle,
(IN CONST EFI_HANDLE ControllerHandle,
IN CONST EFI_HANDLE ChildHandle,
IN CONST EFI_GUID *ProtocolGuid)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
IsLanguageSupported,
(IN CONST CHAR8 *SupportedLanguages,
IN CONST CHAR8 *TargetLanguage)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
LookupUnicodeString,
(IN CONST CHAR8 *Language,
IN CONST CHAR8 *SupportedLanguages,
IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
OUT CHAR16 **UnicodeString)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
LookupUnicodeString2,
(IN CONST CHAR8 *Language,
IN CONST CHAR8 *SupportedLanguages,
IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
OUT CHAR16 **UnicodeString,
IN BOOLEAN Iso639Language)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
AddUnicodeString,
(IN CONST CHAR8 *Language,
IN CONST CHAR8 *SupportedLanguages,
IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
IN CONST CHAR16 *UnicodeString)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
AddUnicodeString2,
(IN CONST CHAR8 *Language,
IN CONST CHAR8 *SupportedLanguages,
IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
IN CONST CHAR16 *UnicodeString,
IN BOOLEAN Iso639Language)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
FreeUnicodeStringTable,
(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
);
MOCK_FUNCTION_DECLARATION ( MOCK_FUNCTION_DECLARATION (
EFI_STATUS, EFI_STATUS,
GetVariable2, GetVariable2,
(IN CONST CHAR16 *Name, (IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid, IN CONST EFI_GUID *Guid,
OUT VOID **Value, OUT VOID **Value,
OUT UINTN *Size OPTIONAL) OUT UINTN *Size OPTIONAL)
); );
MOCK_FUNCTION_DECLARATION ( MOCK_FUNCTION_DECLARATION (
EFI_STATUS, EFI_STATUS,
GetEfiGlobalVariable2, GetEfiGlobalVariable2,
(IN CONST CHAR16 *Name, (IN CONST CHAR16 *Name,
OUT VOID **Value, OUT VOID **Value,
OUT UINTN *Size OPTIONAL) OUT UINTN *Size OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
GetVariable3,
(IN CONST CHAR16 *Name,
IN CONST EFI_GUID *Guid,
OUT VOID **Value,
OUT UINTN *Size OPTIONAL,
OUT UINT32 *Attr OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
UINTN,
GetGlyphWidth,
(IN CHAR16 UnicodeChar)
);
MOCK_FUNCTION_DECLARATION (
UINTN,
UnicodeStringDisplayLength,
(IN CONST CHAR16 *String)
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiSignalEventReadyToBoot,
()
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiSignalEventLegacyBoot,
()
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiCreateEventLegacyBoot,
(OUT EFI_EVENT *LegacyBootEvent)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiCreateEventLegacyBootEx,
(IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN VOID *NotifyContext OPTIONAL,
OUT EFI_EVENT *LegacyBootEvent)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiCreateEventReadyToBoot,
(OUT EFI_EVENT *ReadyToBootEvent)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiCreateEventReadyToBootEx,
(IN EFI_TPL NotifyTpl,
IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
IN VOID *NotifyContext OPTIONAL,
OUT EFI_EVENT *ReadyToBootEvent)
);
MOCK_FUNCTION_DECLARATION (
VOID,
EfiInitializeFwVolDevicepathNode,
(IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
IN CONST EFI_GUID *NameGuid)
);
MOCK_FUNCTION_DECLARATION (
EFI_GUID *,
EfiGetNameGuidFromFwVolDevicePathNode,
(IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibInstallDriverBinding,
(IN CONST EFI_HANDLE ImageHandle,
IN CONST EFI_SYSTEM_TABLE *SystemTable,
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN EFI_HANDLE DriverBindingHandle)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibUninstallDriverBinding,
(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibInstallAllDriverProtocols,
(IN CONST EFI_HANDLE ImageHandle,
IN CONST EFI_SYSTEM_TABLE *SystemTable,
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN EFI_HANDLE DriverBindingHandle,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibUninstallAllDriverProtocols,
(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibInstallDriverBindingComponentName2,
(IN CONST EFI_HANDLE ImageHandle,
IN CONST EFI_SYSTEM_TABLE *SystemTable,
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN EFI_HANDLE DriverBindingHandle,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibUninstallDriverBindingComponentName2,
(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibInstallAllDriverProtocols2,
(IN CONST EFI_HANDLE ImageHandle,
IN CONST EFI_SYSTEM_TABLE *SystemTable,
IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN EFI_HANDLE DriverBindingHandle,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2 OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLibUninstallAllDriverProtocols2,
(IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL,
IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration OPTIONAL,
IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2 OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL,
IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiLocateProtocolBuffer,
(IN EFI_GUID *Protocol,
OUT UINTN *NoProtocols,
OUT VOID ***Buffer)
);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
EfiOpenFileByDevicePath,
(IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
OUT EFI_FILE_PROTOCOL **File,
IN UINT64 OpenMode,
IN UINT64 Attributes)
);
MOCK_FUNCTION_DECLARATION (
EFI_ACPI_COMMON_HEADER *,
EfiLocateNextAcpiTable,
(IN UINT32 Signature,
IN EFI_ACPI_COMMON_HEADER *PreviousTable OPTIONAL)
);
MOCK_FUNCTION_DECLARATION (
EFI_ACPI_COMMON_HEADER *,
EfiLocateFirstAcpiTable,
(IN UINT32 Signature)
); );
}; };

View File

@ -2,11 +2,55 @@
Google Test mocks for UefiLib Google Test mocks for UefiLib
Copyright (c) 2022, Intel Corporation. All rights reserved. Copyright (c) 2022, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include <GoogleTest/Library/MockUefiLib.h> #include <GoogleTest/Library/MockUefiLib.h>
MOCK_INTERFACE_DEFINITION (MockUefiLib); MOCK_INTERFACE_DEFINITION (MockUefiLib);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiGetSystemConfigurationTable, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiCreateProtocolNotifyEvent, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiNamedEventListen, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiNamedEventSignal, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiEventGroupSignal, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiEventEmptyFunction, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiGetCurrentTpl, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiInitializeLock, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiAcquireLock, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiAcquireLockOrFail, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiReleaseLock, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiTestManagedDevice, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiTestChildHandle, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, IsLanguageSupported, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, LookupUnicodeString, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, LookupUnicodeString2, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, AddUnicodeString, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, AddUnicodeString2, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, FreeUnicodeStringTable, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, GetVariable2, 4, EFIAPI); MOCK_FUNCTION_DEFINITION (MockUefiLib, GetVariable2, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, GetEfiGlobalVariable2, 3, EFIAPI); MOCK_FUNCTION_DEFINITION (MockUefiLib, GetEfiGlobalVariable2, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, GetVariable3, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, GetGlyphWidth, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, UnicodeStringDisplayLength, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiSignalEventReadyToBoot, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiSignalEventLegacyBoot, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiCreateEventLegacyBoot, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiCreateEventLegacyBootEx, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiCreateEventReadyToBoot, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiCreateEventReadyToBootEx, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiInitializeFwVolDevicepathNode, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiGetNameGuidFromFwVolDevicePathNode, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibInstallDriverBinding, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibUninstallDriverBinding, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibInstallAllDriverProtocols, 7, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibUninstallAllDriverProtocols, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibInstallDriverBindingComponentName2, 6, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibUninstallDriverBindingComponentName2, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibInstallAllDriverProtocols2, 10, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLibUninstallAllDriverProtocols2, 7, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLocateProtocolBuffer, 3, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiOpenFileByDevicePath, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLocateNextAcpiTable, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockUefiLib, EfiLocateFirstAcpiTable, 1, EFIAPI);