public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support
@ 2023-12-11 15:46 Jeff Brasen via groups.io
  2023-12-18  2:25 ` Chang, Abner via groups.io
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Brasen via groups.io @ 2023-12-11 15:46 UTC (permalink / raw)
  To: devel; +Cc: abner.chang, ardb+tianocore, quic_llindhol, Jeff Brasen

Add Google Mock Library for DtPlatformLoaderDtbLib

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
 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..23dab21668
--- /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 <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+#include <Pi/PiMultiPhase.h>
+#include <Uefi.h>
+#include <Library/DtPlatformDtbLoaderLib.h>
+}
+
+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 <GoogleTest/Library/MockDtPlatformDtbLoaderLib.h>
+
+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
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112311): https://edk2.groups.io/g/devel/message/112311
Mute This Topic: https://groups.io/mt/103110931/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] 2+ messages in thread

* Re: [edk2-devel] [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support
  2023-12-11 15:46 [edk2-devel] [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support Jeff Brasen via groups.io
@ 2023-12-18  2:25 ` Chang, Abner via groups.io
  0 siblings, 0 replies; 2+ messages in thread
From: Chang, Abner via groups.io @ 2023-12-18  2:25 UTC (permalink / raw)
  To: Jeff Brasen, devel@edk2.groups.io
  Cc: ardb+tianocore@kernel.org, quic_llindhol@quicinc.com

[AMD Official Use Only - General]

Not familiar with gmock and no idea of adding a cpp source file to edk2 (we done this on edk2 before?). May need someone else to review this change.

Thanks
Abner

> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Monday, December 11, 2023 11:47 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; ardb+tianocore@kernel.org;
> quic_llindhol@quicinc.com; Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Add Google Mock Library for DtPlatformLoaderDtbLib
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
>  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/MockDtPlatformDtbLo
> aderLib.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/MockDtPlatformDtb
> LoaderLib.h
> b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtb
> LoaderLib.h
> new file mode 100644
> index 0000000000..23dab21668
> --- /dev/null
> +++
> b/EmbeddedPkg/Test/Mock/Include/GoogleTest/Library/MockDtPlatformDtb
> LoaderLib.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 <Library/GoogleTestLib.h>
> +#include <Library/FunctionMockLib.h>
> +extern "C" {
> +#include <Pi/PiMultiPhase.h>
> +#include <Uefi.h>
> +#include <Library/DtPlatformDtbLoaderLib.h>
> +}
> +
> +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/MockDtPlatformDtbLoaderLi
> b/MockDtPlatformDtbLoaderLib.cpp
> b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLi
> b/MockDtPlatformDtbLoaderLib.cpp
> new file mode 100644
> index 0000000000..a5db68e59a
> --- /dev/null
> +++
> b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLi
> b/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 <GoogleTest/Library/MockDtPlatformDtbLoaderLib.h>
> +
> +MOCK_INTERFACE_DEFINITION (MockDtPlatformDtbLoaderLib);
> +
> +MOCK_FUNCTION_DEFINITION (MockDtPlatformDtbLoaderLib,
> DtPlatformLoadDtb, 2, EFIAPI);
> diff --git
> a/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLi
> b/MockDtPlatformDtbLoaderLib.inf
> b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLi
> b/MockDtPlatformDtbLoaderLib.inf
> new file mode 100644
> index 0000000000..9618efd864
> --- /dev/null
> +++
> b/EmbeddedPkg/Test/Mock/Library/GoogleTest/MockDtPlatformDtbLoaderLi
> b/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
> --
> 2.34.1



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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-18  2:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 15:46 [edk2-devel] [PATCH] EmbeddedPkg: Add DtPlatformLoaderLib gmock support Jeff Brasen via groups.io
2023-12-18  2:25 ` Chang, Abner via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox