Skip to content

Commit

Permalink
MdeModulePkg: Added MockSmmVarCheck gmock
Browse files Browse the repository at this point in the history
Added a gmock for GoogleTests
  • Loading branch information
v-bhavanisu authored and VivianNK committed Jul 15, 2024
1 parent 68350eb commit 4321868
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** @file MockSmmVarCheck.h
This file declares a mock of Smm Variable check Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_SMM_VAR_CHECK_H
#define MOCK_SMM_VAR_CHECK_H

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

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

struct MockSmmVarCheck {
MOCK_INTERFACE_DECLARATION (MockSmmVarCheck);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
SmmRegisterSetVariableCheckHandler,
(
IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
)
);
};

extern "C" {
extern EDKII_SMM_VAR_CHECK_PROTOCOL *gEdkiiSmmVarCheckProtocol;
}

#endif // MOCK_SMM_VAR_CHECK_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @file MockSmmVarCheck.cpp
Google Test mock for Smm Variable Check Protocol
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <GoogleTest/Protocol/MockSmmVarCheck.h>

MOCK_INTERFACE_DEFINITION (MockSmmVarCheck);
MOCK_FUNCTION_DEFINITION (MockSmmVarCheck, SmmRegisterSetVariableCheckHandler, 1, EFIAPI);

EDKII_SMM_VAR_CHECK_PROTOCOL SMMVARCHECK_PROTOCOL_INSTANCE = {
SmmRegisterSetVariableCheckHandler, // EFI_MM_READ_SAVE_STATE
NULL, // EDKII_VAR_CHECK_VARIABLE_PROPERTY_SET
NULL // EDKII_VAR_CHECK_VARIABLE_PROPERTY_GET
};

extern "C" {
EDKII_SMM_VAR_CHECK_PROTOCOL *gEdkiiSmmVarCheckProtocol = &SMMVARCHECK_PROTOCOL_INSTANCE;
}

0 comments on commit 4321868

Please sign in to comment.