Skip to content

Commit

Permalink
Add mock for protocol MockFirmwareVolumeBlock under MdePkg (#1216)
Browse files Browse the repository at this point in the history
## Description

Add Mock for Firmware Volume Block Protocol in MdePkg

Signed-off-by: rasheed yusuf <[email protected]>
Cc: Maintainer Shruti Gupta <[email protected]>
Cc: Reviewer Shruti Gupta <[email protected]>

- [ ] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?
- [x] Backport to release branch?

## How This Was Tested

Consumed in a GoogleTest

## Integration Instructions

N/A

---------

Signed-off-by: Rasheed Yusuf <[email protected]>
Signed-off-by: Rasheed-Yusuf <[email protected]>
Co-authored-by: Michael Kubacki <[email protected]>
Co-authored-by: Vivian Nowka-Keane <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent 465a5f9 commit f72f269
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockFirmwareVolumeBlock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/** @file MockFirmwareVolumeBlock.h
This file declares a mock of Firmware Volume Block Protocol
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_FIRMWARE_VOLUME_BLOCK_H_
#define MOCK_FIRMWARE_VOLUME_BLOCK_H_

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

extern "C" {
#include <Uefi.h>
#include <Protocol/FirmwareVolumeBlock.h>
}

//
// Declarations to handle usage of the FirmwareVolumeBlockProtocol
//
struct MockEfiFirmwareVolumeBlockProtocol {
MOCK_INTERFACE_DECLARATION (MockEfiFirmwareVolumeBlockProtocol);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
GetAttributes,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
OUT EFI_FVB_ATTRIBUTES_2* Attributes)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SetAttributes,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
IN OUT EFI_FVB_ATTRIBUTES_2* Attributes)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
GetPhysicalAddress,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
OUT EFI_PHYSICAL_ADDRESS* Address)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
GetBlockSize,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
IN EFI_LBA Lba,
OUT UINTN* BlockSize,
OUT UINTN* NumberOfBlocks)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Read,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
IN EFI_LBA Lba,
IN UINTN Offset,
IN OUT UINTN* NumBytes,
IN OUT UINT8* Buffer)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Write,
(
IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL* This,
IN EFI_LBA Lba,
IN UINTN Offset,
IN OUT UINTN* NumBytes,
IN UINT8* Buffer)
);
};

MOCK_INTERFACE_DEFINITION (MockEfiFirmwareVolumeBlockProtocol);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, GetAttributes, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, SetAttributes, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, GetPhysicalAddress, 2, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, GetBlockSize, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, Read, 5, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockEfiFirmwareVolumeBlockProtocol, Write, 5, EFIAPI);

#define MOCK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_INSTANCE(NAME) \
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL NAME##_INSTANCE = { \
GetAttributes, \
SetAttributes, \
GetPhysicalAddress, \
GetBlockSize, \
Read, \
Write }; \
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *NAME = &NAME##_INSTANCE;

#endif // MOCK_FIRMWARE_VOLUME_BLOCK_H_

0 comments on commit f72f269

Please sign in to comment.