diff --git a/AdvLoggerPkg/Library/AdvancedLoggerLib/Dxe/GoogleTest/AdvancedLoggerDxeLibGoogleTest.inf b/AdvLoggerPkg/Library/AdvancedLoggerLib/Dxe/GoogleTest/AdvancedLoggerDxeLibGoogleTest.inf index faed89677e..ef70596027 100644 --- a/AdvLoggerPkg/Library/AdvancedLoggerLib/Dxe/GoogleTest/AdvancedLoggerDxeLibGoogleTest.inf +++ b/AdvLoggerPkg/Library/AdvancedLoggerLib/Dxe/GoogleTest/AdvancedLoggerDxeLibGoogleTest.inf @@ -23,7 +23,6 @@ VERSION_STRING = 1.0 [Sources] ../AdvancedLoggerLib.c # Source for extern mInitialized AdvancedLoggerDxeLibGoogleTest.cpp - ../../../../Test/Mock/Library/GoogleTest/Protocol/MockAdvancedLogger.cpp # MdePkg/Test/Mock/Library/GoogleTest/Protocol/MockDebugPort.cpp # Waiting on MockDebugPort [Packages] diff --git a/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Protocol/MockAdvancedLogger.h b/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Protocol/MockAdvancedLogger.h index 3634588415..edbd58c137 100644 --- a/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Protocol/MockAdvancedLogger.h +++ b/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Protocol/MockAdvancedLogger.h @@ -33,4 +33,23 @@ extern "C" { extern ADVANCED_LOGGER_PROTOCOL *gALProtocol; } +// +// Mock function definitions in header file to prevent need of cpp file and +// make it easier to consume in tests. +// This is only suitable for protocol mocks. +// + +MOCK_INTERFACE_DEFINITION (MockAdvancedLogger); +MOCK_FUNCTION_DEFINITION (MockAdvancedLogger, gAL_AdvancedLoggerWriteProtocol, 4, EFIAPI); + +static ADVANCED_LOGGER_PROTOCOL advancedLoggerInstance = { + ADVANCED_LOGGER_PROTOCOL_SIGNATURE, // UINT32 + ADVANCED_LOGGER_PROTOCOL_VERSION, // UINT32 + gAL_AdvancedLoggerWriteProtocol // ADVANCED_LOGGER_WRITE_PROTOCOL +}; + +extern "C" { + ADVANCED_LOGGER_PROTOCOL *gALProtocol = &advancedLoggerInstance; +} + #endif // MOCK_ADVANCED_LOGGER_LIB_H_ diff --git a/AdvLoggerPkg/Test/Mock/Library/GoogleTest/Protocol/MockAdvancedLogger.cpp b/AdvLoggerPkg/Test/Mock/Library/GoogleTest/Protocol/MockAdvancedLogger.cpp deleted file mode 100644 index 583b734d38..0000000000 --- a/AdvLoggerPkg/Test/Mock/Library/GoogleTest/Protocol/MockAdvancedLogger.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/** @file MockAdvancedLogger.cpp - Google Test mock for Advanced Logger Protocol. - - Copyright (c) Microsoft Corporation. - SPDX-License-Identifier: BSD-2-Clause-Patent -**/ - -#include - -MOCK_INTERFACE_DEFINITION (MockAdvancedLogger); -MOCK_FUNCTION_DEFINITION (MockAdvancedLogger, gAL_AdvancedLoggerWriteProtocol, 4, EFIAPI); - -static ADVANCED_LOGGER_PROTOCOL advancedLoggerInstance = { - ADVANCED_LOGGER_PROTOCOL_SIGNATURE, // UINT32 - ADVANCED_LOGGER_PROTOCOL_VERSION, // UINT32 - gAL_AdvancedLoggerWriteProtocol // ADVANCED_LOGGER_WRITE_PROTOCOL -}; - -extern "C" { - ADVANCED_LOGGER_PROTOCOL *gALProtocol = &advancedLoggerInstance; -}