From 28cf0adb262da1d7436a238dedcd2b8ad2a22ae3 Mon Sep 17 00:00:00 2001 From: Vivian Nowka-Keane Date: Mon, 9 Sep 2024 16:40:50 -0700 Subject: [PATCH] AdvLoggerPkg: Add mock for AdvancedLoggerHdwPortLib --- .../Library/MockAdvancedLoggerHdwPortLib.h | 37 +++++++++++++++++++ .../MockAdvancedLoggerHdwPortLib.cpp | 13 +++++++ .../MockAdvancedLoggerHdwPortLib.inf | 34 +++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerHdwPortLib.h create mode 100644 AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.cpp create mode 100644 AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.inf diff --git a/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerHdwPortLib.h b/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerHdwPortLib.h new file mode 100644 index 0000000000..67bbcd7971 --- /dev/null +++ b/AdvLoggerPkg/Test/Mock/Include/GoogleTest/Library/MockAdvancedLoggerHdwPortLib.h @@ -0,0 +1,37 @@ +/** @file MockAdvancedLoggerHdwPortLib.h + Google Test mocks for AdvancedLoggerHdwPortLib + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_ADVANCED_LOGGER_HDW_PORT_LIB_H_ +#define MOCK_ADVANCED_LOGGER_HDW_PORT_LIB_H_ + +#include +#include +extern "C" { + #include + #include + #include +} + +struct MockAdvancedLoggerHdwPortLib { + MOCK_INTERFACE_DECLARATION (MockAdvancedLoggerHdwPortLib); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + AdvancedLoggerHdwPortInitialize, + () + ); + + MOCK_FUNCTION_DECLARATION ( + UINTN, + AdvancedLoggerHdwPortWrite, + (IN UINTN DebugLevel, + IN UINT8 *Buffer, + IN UINTN NumberOfBytes) + ); +}; + +#endif diff --git a/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.cpp b/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.cpp new file mode 100644 index 0000000000..c075adc1df --- /dev/null +++ b/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.cpp @@ -0,0 +1,13 @@ +/** @file MockAdvancedLoggerHdwPortLib.cpp + Google Test mocks for AdvancedLoggerHdwPortLib + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +MOCK_INTERFACE_DEFINITION (MockAdvancedLoggerHdwPortLib); + +MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerHdwPortLib, AdvancedLoggerHdwPortInitialize, 0, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockAdvancedLoggerHdwPortLib, AdvancedLoggerHdwPortWrite, 3, EFIAPI); diff --git a/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.inf b/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.inf new file mode 100644 index 0000000000..4d02e08cf7 --- /dev/null +++ b/AdvLoggerPkg/Test/Mock/Library/GoogleTest/MockAdvancedLoggerHdwPortLib/MockAdvancedLoggerHdwPortLib.inf @@ -0,0 +1,34 @@ +## @file MockAdvancedLoggerHdwPortLib.inf +# Google Test mocks for AdvancedLoggerHdwPortLib +# +# Copyright (c) Microsoft Corporation. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MockAdvancedLoggerHdwPortLib + FILE_GUID = 88069e60-ae8b-5d10-a654-9aa6ce8b328c + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + LIBRARY_CLASS = AdvancedLoggerHdwPortLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + MockAdvancedLoggerHdwPortLib.cpp + +[Packages] + AdvLoggerPkg/AdvLoggerPkg.dec + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS = /EHs /bigobj