diff options
author | devel@edk2.groups.io <devel@edk2.groups.io> | 2024-01-23 19:08:02 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-01-24 07:58:52 +0000 |
commit | 97e1ef87300cdf01f5b21cd4c5ee1d8df6ae1f39 (patch) | |
tree | 777f7895d859ed5bda349ba6fc97f823e72ec028 /MdePkg | |
parent | d24187a81f724fc2af4f739ad92a9b158c9254df (diff) | |
download | edk2-97e1ef87300cdf01f5b21cd4c5ee1d8df6ae1f39.zip edk2-97e1ef87300cdf01f5b21cd4c5ee1d8df6ae1f39.tar.gz edk2-97e1ef87300cdf01f5b21cd4c5ee1d8df6ae1f39.tar.bz2 |
MdePkg: Add FdtLib gmock support
Add Google Mock Library for FdtLib
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Diffstat (limited to 'MdePkg')
4 files changed, 227 insertions, 0 deletions
diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc index 583f8fc..e666636 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -45,3 +45,4 @@ MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf
MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLib.inf
MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf
+ MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h new file mode 100644 index 0000000..5b21b23 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h @@ -0,0 +1,164 @@ +/** @file
+ Google Test mocks for FdtLib
+
+ 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_FDT_LIB_H_
+#define MOCK_FDT_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+ #include <Base.h>
+ #include <Library/FdtLib.h>
+}
+
+struct MockFdtLib {
+ MOCK_INTERFACE_DECLARATION (MockFdtLib);
+
+ MOCK_FUNCTION_DECLARATION (
+ UINT16,
+ Fdt16ToCpu,
+ (IN UINT16 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ UINT16,
+ CpuToFdt16,
+ (IN UINT16 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ UINT32,
+ Fdt32ToCpu,
+ (IN UINT32 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ UINT32,
+ CpuToFdt32,
+ (IN UINT32 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ UINT64,
+ Fdt64ToCpu,
+ (IN UINT64 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ UINT64,
+ CpuToFdt64,
+ (IN UINT64 Value)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtCheckHeader,
+ (IN CONST VOID *Fdt)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtCreateEmptyTree,
+ (IN VOID *Buffer,
+ IN UINT32 BufferSize)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtNextNode,
+ (IN CONST VOID *Fdt,
+ IN INT32 Offset,
+ IN INT32 *Depth)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtFirstSubnode,
+ (IN CONST VOID *Fdt,
+ IN INT32 Offset)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtNextSubnode,
+ (IN CONST VOID *Fdt,
+ IN INT32 Offset)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtSubnodeOffsetNameLen,
+ (IN CONST VOID *Fdt,
+ IN INT32 ParentOffset,
+ IN CONST CHAR8 *Name,
+ IN INT32 NameLength)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtNodeOffsetByPropValue,
+ (IN CONST VOID *Fdt,
+ IN INT32 StartOffset,
+ IN CONST CHAR8 *PropertyName,
+ IN CONST VOID *PropertyValue,
+ IN INT32 PropertyLength)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ CONST FDT_PROPERTY *,
+ FdtGetProperty,
+ (IN CONST VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN INT32 *Length)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtFirstPropertyOffset,
+ (IN CONST VOID *Fdt,
+ IN INT32 NodeOffset)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtNextPropertyOffset,
+ (IN CONST VOID *Fdt,
+ IN INT32 NodeOffset)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ CONST FDT_PROPERTY *,
+ FdtGetPropertyByOffset,
+ (IN CONST VOID *Fdt,
+ IN INT32 Offset,
+ IN INT32 *Length)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ CONST CHAR8 *,
+ FdtGetString,
+ (IN CONST VOID *Fdt,
+ IN INT32 StrOffset,
+ IN INT32 *Length OPTIONAL)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtAddSubnode,
+ (IN VOID *Fdt,
+ IN INT32 ParentOffset,
+ IN CONST CHAR8 *Name)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtSetProp,
+ (IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN CONST CHAR8 *Name,
+ IN CONST VOID *Value,
+ IN UINT32 Length)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ CONST CHAR8 *,
+ FdtGetName,
+ (IN VOID *Fdt,
+ IN INT32 NodeOffset,
+ IN INT32 *Length)
+ );
+ MOCK_FUNCTION_DECLARATION (
+ INT32,
+ FdtNodeDepth,
+ (IN CONST VOID *Fdt,
+ IN INT32 NodeOffset)
+ );
+};
+
+#endif
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp new file mode 100644 index 0000000..a955780 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp @@ -0,0 +1,34 @@ +/** @file
+ Google Test mocks for FdtLib
+
+ 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 <GoogleTest/Library/MockFdtLib.h>
+
+MOCK_INTERFACE_DEFINITION (MockFdtLib);
+
+MOCK_FUNCTION_DEFINITION (MockFdtLib, Fdt16ToCpu, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, CpuToFdt16, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, Fdt32ToCpu, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, CpuToFdt32, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, Fdt64ToCpu, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, CpuToFdt64, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtCheckHeader, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtCreateEmptyTree, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtNextNode, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtFirstSubnode, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtNextSubnode, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtSubnodeOffsetNameLen, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtNodeOffsetByPropValue, 5, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtGetProperty, 4, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtFirstPropertyOffset, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtNextPropertyOffset, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtGetPropertyByOffset, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtGetString, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtAddSubnode, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtSetProp, 5, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtGetName, 3, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockFdtLib, FdtNodeDepth, 2, EFIAPI);
diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf new file mode 100644 index 0000000..b227bcb --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf @@ -0,0 +1,28 @@ +## @file
+# Google Test mocks for FdtLib
+#
+# 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 = MockFdtLib
+ FILE_GUID = 0f5471bc-fc2c-4cf4-b9f7-c1396d32831c
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = FdtLib
+
+[Sources]
+ MockFdtLib.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+
+[BuildOptions]
+ MSFT:*_*_*_CC_FLAGS = /EHsc /bigobj
|