Skip to content

Commit

Permalink
Add MockDeviceBootManagerLib
Browse files Browse the repository at this point in the history
  • Loading branch information
YiTa-AMI committed Sep 10, 2024
1 parent 602574c commit 4cd4ed0
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
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

0 comments on commit 4cd4ed0

Please sign in to comment.