public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Guo, Gua" <gua.guo@intel.com>
To: devel@edk2.groups.io
Cc: gua.guo@intel.com, Michael D Kinney <michael.d.kinney@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>, Ray Ni <ray.ni@intel.com>,
	Chris Johnson <chris.n.johnson@intel.com>
Subject: [PATCH v3 1/2] MdeModulePkg: Add more PciHostBridgeLib gmock support
Date: Tue,  9 May 2023 08:03:39 +0800	[thread overview]
Message-ID: <20230509000340.1722-2-gua.guo@intel.com> (raw)
In-Reply-To: <20230509000340.1722-1-gua.guo@intel.com>

From: Gua Guo <gua.guo@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4443

Add Google Mock Library for PciHostBridgeLib

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chris Johnson <chris.n.johnson@intel.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
---
 MdeModulePkg/MdeModulePkg.dec                 |  1 +
 MdeModulePkg/Test/MdeModulePkgHostTest.dsc    |  5 +++
 .../GoogleTest/Library/MockPciHostBridgeLib.h | 40 +++++++++++++++++++
 .../MockPciHostBridgeLib.cpp                  | 14 +++++++
 .../MockPciHostBridgeLib.inf                  | 35 ++++++++++++++++
 5 files changed, 95 insertions(+)
 create mode 100644 MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostBridgeLib.h
 create mode 100644 MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.cpp
 create mode 100644 MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 3eb4a79bf7..9bb0d3ba2d 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -24,6 +24,7 @@
 
 [Includes]
   Include
+  Test/Mock/Include
 
 [Includes.Common.Private]
   Library/BrotliCustomDecompressLib/brotli/c/include
diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
index a2bbbe8adf..8fb982a270 100644
--- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
+++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc
@@ -53,3 +53,8 @@
       UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
       DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
   }
+
+  #
+  # Build HOST_APPLICATION Libraries
+  #
+  MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf
diff --git a/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostBridgeLib.h b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostBridgeLib.h
new file mode 100644
index 0000000000..a63bed895c
--- /dev/null
+++ b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostBridgeLib.h
@@ -0,0 +1,40 @@
+/** @file
+  Google Test mocks for PciHostBridgeLib
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_PCI_HOST_BRIDGE_LIB_H_
+#define MOCK_PCI_HOST_BRIDGE_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+#include <Uefi.h>
+#include <Library/PciHostBridgeLib.h>
+}
+
+struct MockPciHostBridgeLib {
+  MOCK_INTERFACE_DECLARATION (MockPciHostBridgeLib);
+
+  MOCK_FUNCTION_DECLARATION (
+    PCI_ROOT_BRIDGE *,
+    PciHostBridgeGetRootBridges,
+    (UINTN  *Count)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    PciHostBridgeFreeRootBridges,
+    (PCI_ROOT_BRIDGE  *Bridges,
+     UINTN            Count)
+    );
+  MOCK_FUNCTION_DECLARATION (
+    VOID,
+    PciHostBridgeResourceConflict,
+    (EFI_HANDLE  HostBridgeHandle,
+     VOID        *Configuration)
+    );
+};
+
+#endif
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.cpp b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.cpp
new file mode 100644
index 0000000000..4b15aed169
--- /dev/null
+++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.cpp
@@ -0,0 +1,14 @@
+/** @file
+  Mock instance of the PCI Host Bridge Library.
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <GoogleTest/Library/MockPciHostBridgeLib.h>
+
+MOCK_INTERFACE_DEFINITION(MockPciHostBridgeLib);
+
+MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeGetRootBridges, 1, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeFreeRootBridges, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeResourceConflict, 2, EFIAPI);
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf
new file mode 100644
index 0000000000..89daefb9f0
--- /dev/null
+++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf
@@ -0,0 +1,35 @@
+## @file
+#  Mock instance of the PCI Host Bridge Library.
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = MockPciHostBridgeLib
+  FILE_GUID                      = B51721FE-0BBA-4611-B9A5-ED13C49AC060
+  MODULE_TYPE                    = HOST_APPLICATION
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PciHostBridgeLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  MockPciHostBridgeLib.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS = /EHsc
-- 
2.39.2.windows.1


  reply	other threads:[~2023-05-09  0:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09  0:03 [PATCH v3 0/2] Add more google mock library Guo, Gua
2023-05-09  0:03 ` Guo, Gua [this message]
2023-05-09  0:03 ` [PATCH v3 2/2] MdePkg: Add more HobLib/PeiServicesLib gmock support Guo, Gua
2023-05-09  0:17 ` [edk2-devel] [PATCH v3 0/2] Add more google mock library Michael D Kinney
2023-05-09 22:56   ` Guo, Gua
2023-05-10  0:42     ` 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=20230509000340.1722-2-gua.guo@intel.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