Skip to content

Commit

Permalink
MdePkg: Add Google Mock Protocol for SmmCommunication (#1266)
Browse files Browse the repository at this point in the history
## Description

Added MockSmmCommunication to be used by Googletests

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

## How This Was Tested

Added MockSmmCommunication to GoogleTests and able to successfully
include its functions

## Integration Instructions

N/A

---------

Co-authored-by: Aaron <[email protected]>
  • Loading branch information
2 people authored and ProjectMuBot committed Feb 14, 2025
1 parent 0ef515e commit 7a0383c
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @file MockSmmCommunication.h
Declare mock SMM Communication Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_SMM_COMMUNICATION_H_
#define MOCK_SMM_COMMUNICATION_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Pi/PiMultiPhase.h>
#include <Protocol/SmmCommunication.h>
}

struct MockSmmCommunicationProtocol {
MOCK_INTERFACE_DECLARATION (MockSmmCommunicationProtocol);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Communicate,
(
IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This,
IN OUT VOID *CommBuffer,
IN OUT UINTN *CommSize OPTIONAL
)
);
};

MOCK_INTERFACE_DEFINITION (MockSmmCommunicationProtocol);
MOCK_FUNCTION_DEFINITION (MockSmmCommunicationProtocol, Communicate, 3, EFIAPI);

#define MOCK_SMM_COMMUNICATION_PROTOCOL_INSTANCE(NAME) \
EFI_SMM_COMMUNICATION_PROTOCOL NAME##_INSTANCE = { \
Communicate \
}; \
EFI_SMM_COMMUNICATION_PROTOCOL *NAME = &NAME##_INSTANCE;

#endif

0 comments on commit 7a0383c

Please sign in to comment.