From 27eb6afca65e6b8304813f6b85935c074460903a Mon Sep 17 00:00:00 2001 From: SeolforHsieh Date: Fri, 14 Feb 2025 08:45:59 +0800 Subject: [PATCH] MdePkg: Add Google Mock Protocol for SmmCommunication (#1266) ## 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 --- .../Protocol/MockSmmCommunication.h | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmCommunication.h diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmCommunication.h b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmCommunication.h new file mode 100644 index 0000000000..18ff65a7d7 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmCommunication.h @@ -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 +#include +extern "C" { + #include + #include + #include +} + +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