public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jeff Brasen via groups.io" <jbrasen=nvidia.com@groups.io>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "gaoliming@byosoft.com.cn" <gaoliming@byosoft.com.cn>,
	"michael.d.kinney@intel.com" <michael.d.kinney@intel.com>,
	"zhiguang.liu@intel.com" <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdePkg: Add FdtLib gmock support
Date: Tue, 23 Jan 2024 17:20:59 +0000	[thread overview]
Message-ID: <LV2PR12MB5800B66CEB5D443DBCCFE5D4CB742@LV2PR12MB5800.namprd12.prod.outlook.com> (raw)
In-Reply-To: <551bf2146720d609621b153dca073a1655489524.1702309338.git.jbrasen@nvidia.com>

Any comments on this patch?

Thanks,
Jeff


> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Monday, December 11, 2023 8:43 AM
> To: devel@edk2.groups.io
> Cc: gaoliming@byosoft.com.cn; michael.d.kinney@intel.com;
> zhiguang.liu@intel.com; Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH] MdePkg: Add FdtLib gmock support
> 
> Add Google Mock Library for FdtLib
> 
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
>  .../Include/GoogleTest/Library/MockFdtLib.h   | 165 ++++++++++++++++++
>  .../GoogleTest/MockFdtLib/MockFdtLib.cpp      |  34 ++++
>  .../GoogleTest/MockFdtLib/MockFdtLib.inf      |  28 +++
>  3 files changed, 227 insertions(+)
>  create mode 100644
> MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
>  create mode 100644
> MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.cpp
>  create mode 100644
> 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 0000000000..c0aeaa25c0
> --- /dev/null
> +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockFdtLib.h
> @@ -0,0 +1,165 @@
> +/** @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 <Pi/PiMultiPhase.h>
> +#include <Uefi.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 0000000000..a955780d23
> --- /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 0000000000..cc5311eae4
> --- /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                      = MockHobLib
> +  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
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114224): https://edk2.groups.io/g/devel/message/114224
Mute This Topic: https://groups.io/mt/103110868/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-01-23 17:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 15:43 [edk2-devel] [PATCH] MdePkg: Add FdtLib gmock support Jeff Brasen via groups.io
2024-01-23 17:20 ` Jeff Brasen via groups.io [this message]
2024-01-23 22:14 ` Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=LV2PR12MB5800B66CEB5D443DBCCFE5D4CB742@LV2PR12MB5800.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox