From 7a5823f85be99b9a92751fcf4141f7982fa5cc80 Mon Sep 17 00:00:00 2001 From: "Jeff Brasen via groups.io" Date: Thu, 28 Dec 2023 12:47:08 -0800 Subject: [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support Add Google Mock Library for DtPlatformLoaderDtbLib Signed-off-by: Jeff Brasen --- EmbeddedPkg/EmbeddedPkg.dec | 1 + .../Library/MockDtPlatformDtbLoaderLib.h | 31 +++++++++++++++++++ .../MockDtPlatformDtbLoaderLib.cpp | 13 ++++++++ .../MockDtPlatformDtbLoaderLib.inf | 29 +++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h create mode 100644 EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp create mode 100644 EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 94dc3c9b76..b4834e8b4f 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -28,6 +28,7 @@ ################################################################################ [Includes.common] Include # Root include for the package + Test/Mock/Include [LibraryClasses.common] PrePiLib|Include/Library/PrePiLib.h diff --git a/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h new file mode 100644 index 0000000000..ce0fca2c32 --- /dev/null +++ b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtbLoaderLib.h @@ -0,0 +1,31 @@ +/** @file + Google Test mocks for DtPlatformDtbLoaderLib + + Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_ +#define MOCK_DT_PLATFORM_DTB_LOADER_LIB_H_ + +#include +#include +extern "C" { + #include + #include + #include +} + +struct MockDtPlatformDtbLoaderLib { + MOCK_INTERFACE_DECLARATION (MockDtPlatformDtbLoaderLib); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + DtPlatformLoadDtb, + (OUT VOID **Dtb, + OUT UINTN *DtbSize) + ); +}; + +#endif diff --git a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp new file mode 100644 index 0000000000..a5db68e59a --- /dev/null +++ b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.cpp @@ -0,0 +1,13 @@ +/** @file + Google Test mocks for MockDtPlatformDtbLoaderLib + + Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +MOCK_INTERFACE_DEFINITION (MockDtPlatformDtbLoaderLib); + +MOCK_FUNCTION_DEFINITION (MockDtPlatformDtbLoaderLib, DtPlatformLoadDtb, 2, EFIAPI); diff --git a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf new file mode 100644 index 0000000000..9618efd864 --- /dev/null +++ b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLib/MockDtPlatformDtbLoaderLib.inf @@ -0,0 +1,29 @@ +## @file +# Google Test mocks for MockDtPlatformDtbLoaderLib +# +# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2023, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = MockDtPlatformDtbLoaderLib + FILE_GUID = 34c05e81-3c56-4c78-b4b7-a39be19163a4 + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + LIBRARY_CLASS = DtPlatformDtbLoaderLib + +[Sources] +MockDtPlatformDtbLoaderLib.cpp + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS = /EHsc