Skip to content

Commit

Permalink
Create Mock for IsaHc protocol
Browse files Browse the repository at this point in the history
Signed-off-by: TsunFeng <[email protected]>
  • Loading branch information
TsunFeng authored and VivianNK committed Aug 2, 2024
1 parent ecc19d0 commit 18ab26a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
47 changes: 47 additions & 0 deletions MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockIsaHc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @file MockIsaHc.h
This file declares a mock of Isa Hc Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_ISA_HC_PROTOCOL_H
#define MOCK_ISA_HC_PROTOCOL_H

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

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

struct MockIsaHcProtocol {
MOCK_INTERFACE_DECLARATION (MockIsaHcProtocol);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
OpenIoAperture,
(
IN CONST EFI_ISA_HC_PROTOCOL *This,
IN UINT16 IoAddress,
IN UINT16 IoLength,
OUT UINT64 *IoApertureHandle
)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
CloseIoAperture,
(
IN CONST EFI_ISA_HC_PROTOCOL *This,
IN UINT64 IoApertureHandle
)
);
};

extern "C" {
extern EFI_ISA_HC_PROTOCOL *gIsaHcProtocol;
}

#endif // MOCK_ISA_HC_PROTOCOL_H
22 changes: 22 additions & 0 deletions MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockIsaHc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @file MockIsaHc.cpp
Google Test mock for Service Binding Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <GoogleTest/Protocol/MockIsaHc.h>

MOCK_INTERFACE_DEFINITION (MockIsaHcProtocol);
MOCK_FUNCTION_DEFINITION (MockIsaHcProtocol, OpenIoAperture, 4, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockIsaHcProtocol, CloseIoAperture, 2, EFIAPI);

EFI_ISA_HC_PROTOCOL ISA_HC_PROTOCOL_INSTANCE = {
0, // UINT32 Version;
OpenIoAperture, // EFI_ISA_HC_OPEN_IO OpenIoAperture;
CloseIoAperture // EFI_ISA_HC_CLOSE_IO CloseIoAperture;
};

extern "C" {
EFI_ISA_HC_PROTOCOL *gIsaHcProtocol = &ISA_HC_PROTOCOL_INSTANCE;
}

0 comments on commit 18ab26a

Please sign in to comment.