* [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
@ 2024-01-23 23:13 Jeff Brasen via groups.io
2024-01-23 23:19 ` Michael D Kinney
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Brasen via groups.io @ 2024-01-23 23:13 UTC (permalink / raw)
To: devel; +Cc: gaoliming, michael.d.kinney, zhiguang.liu, Jeff Brasen
Add Google Mock Library for FdtLib
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
.../GoogleTest/MockFdtLib/MockFdtLib.inf | 28 +++
.../Include/GoogleTest/Library/MockFdtLib.h | 164 ++++++++++++++++++
.../GoogleTest/MockFdtLib/MockFdtLib.cpp | 34 ++++
3 files changed, 226 insertions(+)
create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
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 000000000000..b227bcbae963
--- /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
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 000000000000..73da571910df
--- /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 UINT32 *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 000000000000..a955780d23fe
--- /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);
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114238): https://edk2.groups.io/g/devel/message/114238
Mute This Topic: https://groups.io/mt/103921590/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
2024-01-23 23:13 [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support Jeff Brasen via groups.io
@ 2024-01-23 23:19 ` Michael D Kinney
2024-01-23 23:52 ` Michael D Kinney
2024-01-24 1:25 ` Guo, Gua
0 siblings, 2 replies; 5+ messages in thread
From: Michael D Kinney @ 2024-01-23 23:19 UTC (permalink / raw)
To: Jeff Brasen, devel@edk2.groups.io
Cc: gaoliming@byosoft.com.cn, Liu, Zhiguang, Kinney, Michael D
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Tuesday, January 23, 2024 3:13 PM
> To: devel@edk2.groups.io
> Cc: gaoliming@byosoft.com.cn; Kinney, Michael D
> <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
>
> Add Google Mock Library for FdtLib
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
> .../GoogleTest/MockFdtLib/MockFdtLib.inf | 28 +++
> .../Include/GoogleTest/Library/MockFdtLib.h | 164 ++++++++++++++++++
> .../GoogleTest/MockFdtLib/MockFdtLib.cpp | 34 ++++
> 3 files changed, 226 insertions(+)
> create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> create mode 100644
> MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
>
> 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 000000000000..b227bcbae963
> --- /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
> 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 000000000000..73da571910df
> --- /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 UINT32 *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 000000000000..a955780d23fe
> --- /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);
> --
> 2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114241): https://edk2.groups.io/g/devel/message/114241
Mute This Topic: https://groups.io/mt/103921590/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
2024-01-23 23:19 ` Michael D Kinney
@ 2024-01-23 23:52 ` Michael D Kinney
2024-01-24 3:02 ` Jeff Brasen via groups.io
2024-01-24 1:25 ` Guo, Gua
1 sibling, 1 reply; 5+ messages in thread
From: Michael D Kinney @ 2024-01-23 23:52 UTC (permalink / raw)
To: Jeff Brasen, devel@edk2.groups.io
Cc: gaoliming@byosoft.com.cn, Liu, Zhiguang, Kinney, Michael D
Hi Jeff,
I just noticed that the DSC file in MdePkg/Test has not been updated to
make sure this mock lib always builds. I added as part of PR to run
EDK II CI.
EDK II CI did fail.
https://github.com/tianocore/edk2/pull/5293
https://github.com/tianocore/edk2/pull/5293/checks?check_run_id=20795099585
https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=115123&view=logs&jobId=9701361e-2546-5093-77e5-58c75d95b7ce&j=9701361e-2546-5093-77e5-58c75d95b7ce&t=27131ef8-75e1-57c3-3236-d806181f2f1f
Comment below that details the failure.
Please fix and send V3 with MdePkg/Test DSC update and the
FdtGetName() fix.
Thanks,
Mike
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Tuesday, January 23, 2024 3:19 PM
> To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
> Cc: gaoliming@byosoft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
>
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>
> > -----Original Message-----
> > From: Jeff Brasen <jbrasen@nvidia.com>
> > Sent: Tuesday, January 23, 2024 3:13 PM
> > To: devel@edk2.groups.io
> > Cc: gaoliming@byosoft.com.cn; Kinney, Michael D
> > <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> > Jeff Brasen <jbrasen@nvidia.com>
> > Subject: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> >
> > Add Google Mock Library for FdtLib
> >
> > Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> > ---
> > .../GoogleTest/MockFdtLib/MockFdtLib.inf | 28 +++
> > .../Include/GoogleTest/Library/MockFdtLib.h | 164
> ++++++++++++++++++
> > .../GoogleTest/MockFdtLib/MockFdtLib.cpp | 34 ++++
> > 3 files changed, 226 insertions(+)
> > create mode 100644
> > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > create mode 100644
> > MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > create mode 100644
> > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
> >
> > 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 000000000000..b227bcbae963
> > --- /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
> > 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 000000000000..73da571910df
> > --- /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 UINT32 *Length)
EDK II CI failure building this lib. Mismatch between FdtLib.h and the mock declaration
Length is INT32, not UINT32.
> > + );
> > + 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 000000000000..a955780d23fe
> > --- /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);
> > --
> > 2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114244): https://edk2.groups.io/g/devel/message/114244
Mute This Topic: https://groups.io/mt/103921590/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
2024-01-23 23:19 ` Michael D Kinney
2024-01-23 23:52 ` Michael D Kinney
@ 2024-01-24 1:25 ` Guo, Gua
1 sibling, 0 replies; 5+ messages in thread
From: Guo, Gua @ 2024-01-24 1:25 UTC (permalink / raw)
To: devel@edk2.groups.io, Kinney, Michael D, Jeff Brasen
Cc: gaoliming@byosoft.com.cn, Liu, Zhiguang
Reviewed-by: Gua Guo <gua.guo@intel.com>
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney
Sent: Wednesday, January 24, 2024 7:19 AM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
Cc: gaoliming@byosoft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Tuesday, January 23, 2024 3:13 PM
> To: devel@edk2.groups.io
> Cc: gaoliming@byosoft.com.cn; Kinney, Michael D
> <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
>
> Add Google Mock Library for FdtLib
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
> .../GoogleTest/MockFdtLib/MockFdtLib.inf | 28 +++
> .../Include/GoogleTest/Library/MockFdtLib.h | 164 ++++++++++++++++++
> .../GoogleTest/MockFdtLib/MockFdtLib.cpp | 34 ++++
> 3 files changed, 226 insertions(+)
> create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> create mode 100644
> MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
>
> 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 000000000000..b227bcbae963
> --- /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
> 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 000000000000..73da571910df
> --- /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 UINT32 *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 000000000000..a955780d23fe
> --- /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);
> --
> 2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114246): https://edk2.groups.io/g/devel/message/114246
Mute This Topic: https://groups.io/mt/103921590/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
2024-01-23 23:52 ` Michael D Kinney
@ 2024-01-24 3:02 ` Jeff Brasen via groups.io
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Brasen via groups.io @ 2024-01-24 3:02 UTC (permalink / raw)
To: Kinney, Michael D, devel@edk2.groups.io
Cc: gaoliming@byosoft.com.cn, Liu, Zhiguang
Oops not sure how that happened will fix and push a v3.
-Jeff
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Tuesday, January 23, 2024 4:52 PM
> To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
> Cc: gaoliming@byosoft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
>
> External email: Use caution opening links or attachments
>
>
> Hi Jeff,
>
> I just noticed that the DSC file in MdePkg/Test has not been updated to make
> sure this mock lib always builds. I added as part of PR to run EDK II CI.
>
> EDK II CI did fail.
>
> https://github.com/tianocore/edk2/pull/5293
> https://github.com/tianocore/edk2/pull/5293/checks?check_run_id=207950
> 99585
> https://dev.azure.com/tianocore/edk2-
> ci/_build/results?buildId=115123&view=logs&jobId=9701361e-2546-5093-
> 77e5-58c75d95b7ce&j=9701361e-2546-5093-77e5-
> 58c75d95b7ce&t=27131ef8-75e1-57c3-3236-d806181f2f1f
>
> Comment below that details the failure.
>
> Please fix and send V3 with MdePkg/Test DSC update and the
> FdtGetName() fix.
>
> Thanks,
>
> Mike
>
> > -----Original Message-----
> > From: Kinney, Michael D <michael.d.kinney@intel.com>
> > Sent: Tuesday, January 23, 2024 3:19 PM
> > To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
> > Cc: gaoliming@byosoft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>;
> > Kinney, Michael D <michael.d.kinney@intel.com>
> > Subject: RE: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> >
> > Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> >
> > > -----Original Message-----
> > > From: Jeff Brasen <jbrasen@nvidia.com>
> > > Sent: Tuesday, January 23, 2024 3:13 PM
> > > To: devel@edk2.groups.io
> > > Cc: gaoliming@byosoft.com.cn; Kinney, Michael D
> > > <michael.d.kinney@intel.com>; Liu, Zhiguang
> > > <zhiguang.liu@intel.com>; Jeff Brasen <jbrasen@nvidia.com>
> > > Subject: [PATCH v2 1/1] MdePkg: Add FdtLib gmock support
> > >
> > > Add Google Mock Library for FdtLib
> > >
> > > Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> > > ---
> > > .../GoogleTest/MockFdtLib/MockFdtLib.inf | 28 +++
> > > .../Include/GoogleTest/Library/MockFdtLib.h | 164
> > ++++++++++++++++++
> > > .../GoogleTest/MockFdtLib/MockFdtLib.cpp | 34 ++++
> > > 3 files changed, 226 insertions(+)
> > > create mode 100644
> > > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf
> > > create mode 100644
> > > MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> > > create mode 100644
> > > MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
> > >
> > > 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 000000000000..b227bcbae963
> > > --- /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
> > > 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 000000000000..73da571910df
> > > --- /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 UINT32 *Length)
>
> EDK II CI failure building this lib. Mismatch between FdtLib.h and the mock
> declaration
>
> Length is INT32, not UINT32.
>
> > > + );
> > > + 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 000000000000..a955780d23fe
> > > --- /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);
> > > --
> > > 2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114248): https://edk2.groups.io/g/devel/message/114248
Mute This Topic: https://groups.io/mt/103921590/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-24 3:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 23:13 [edk2-devel] [PATCH v2 1/1] MdePkg: Add FdtLib gmock support Jeff Brasen via groups.io
2024-01-23 23:19 ` Michael D Kinney
2024-01-23 23:52 ` Michael D Kinney
2024-01-24 3:02 ` Jeff Brasen via groups.io
2024-01-24 1:25 ` Guo, Gua
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox