Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MockDeviceBootManagerLib #572

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MsCorePkg/MsCorePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

[Includes]
Include
UnitTests/Mock/Include

[LibraryClasses]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/** @file MockDeviceBootManagerLib.h
Google Test mocks for DeviceBootManagerLib.

Copyright (c) Microsoft Corporation.
Your use of this software is governed by the terms of the Microsoft agreement under which you obtained the software.
**/

#ifndef MOCK_DEVICE_BOOT_MANAGER_LIB_H_
#define MOCK_DEVICE_BOOT_MANAGER_LIB_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>

extern "C" {
#include <Uefi.h>
#include <Library/DeviceBootManagerLib.h>
}

struct MockDeviceBootManagerLib {
MOCK_INTERFACE_DECLARATION (MockDeviceBootManagerLib);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
DeviceBootManagerPriorityBoot,
(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
);

MOCK_FUNCTION_DECLARATION (
VOID,
DeviceBootManagerUnableToBoot,
()
);

MOCK_FUNCTION_DECLARATION (
VOID,
DeviceBootManagerProcessBootCompletion,
(EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
);

MOCK_FUNCTION_DECLARATION (
EFI_DEVICE_PATH_PROTOCOL **,
DeviceBootManagerOnDemandConInConnect,
()
);

MOCK_FUNCTION_DECLARATION (
VOID,
DeviceBootManagerBdsEntry,
()
);

MOCK_FUNCTION_DECLARATION (
EFI_HANDLE,
DeviceBootManagerBeforeConsole,
(EFI_DEVICE_PATH_PROTOCOL **DevicePath,
BDS_CONSOLE_CONNECT_ENTRY **PlatformConsoles)
);

MOCK_FUNCTION_DECLARATION (
EFI_DEVICE_PATH_PROTOCOL **,
DeviceBootManagerAfterConsole,
()
);
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @file MockDeviceBootManagerLib.cpp
Google Test mocks for DeviceBootManagerLib.

Copyright (c) Microsoft Corporation.
Your use of this software is governed by the terms of the Microsoft agreement under which you obtained the software.
**/

#include <GoogleTest/Library/MockDeviceBootManagerLib.h>

MOCK_INTERFACE_DEFINITION (MockDeviceBootManagerLib);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerPriorityBoot, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerUnableToBoot, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerProcessBootCompletion, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerOnDemandConInConnect, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerBdsEntry, 0, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerBeforeConsole, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockDeviceBootManagerLib, DeviceBootManagerAfterConsole, 0, EFIAPI);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## @file MockDeviceBootManagerLib.inf
# Google Test mocks for DeviceBootManagerLib.
#
# Copyright (c) Microsoft Corporation.
# Your use of this software is governed by the terms of the Microsoft agreement under which you obtained the software.
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = MockDeviceBootManagerLib
FILE_GUID = A19D9B27-21EB-4DCF-A084-0326C2EB0E58
MODULE_TYPE = HOST_APPLICATION
VERSION_STRING = 1.0
LIBRARY_CLASS = DeviceBootManagerLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

[Sources]
MockDeviceBootManagerLib.cpp

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
MsCorePkg/MsCorePkg.dec
[LibraryClasses]
GoogleTestLib

[BuildOptions]
MSFT:*_*_*_CC_FLAGS = /EHsc
2 changes: 2 additions & 0 deletions MsCorePkg/UnitTests/MsCorePkgHostTest.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@
[Components]
MsCorePkg/MacAddressEmulationDxe/Test/MacAddressEmulationDxeHostTest.inf

MsCorePkg/UnitTests/Mock/Library/MockDeviceBootManagerLib/MockDeviceBootManagerLib.inf

[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
Loading