From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.17512.1683250695138019411 for ; Thu, 04 May 2023 18:38:15 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=l9K+RoQr; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: gua.guo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683250695; x=1714786695; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SxyZ+JVAEE2XB2tqOBjut7FnYgZQ2GEc5AtOmGBL43w=; b=l9K+RoQrReY04wdEn3vMoyS70cAKTbQcvf9zwY4s8DbiSw2CyExJNNqR 1I+duMFT184Gtcr1UOrD/n+Xip7Y8RJn1Y+4/X34aBAVcvA4nTsFLM/82 XxQcLf9NW/k18p8R6vEhrqYmtQNyyuYk5LJ15tp45kV2/UssyBpqyixBs 62FTRltOg4SHhMmuemuaeKQsxNEUC5Abt3K57tq97+cLFOUaam0N/XJyJ q6GV0p4cDPyqa2Z6S3E6U9LxWnKR0fpVnqDocnJS++X62WzfiO36Fo8P4 TPdIrNMZFV1OfRo1WC8hjYBygEscEgDr5d8SOG22EiBmOprfFoNq9rT5x A==; X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="329464079" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="329464079" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 18:38:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10700"; a="727823292" X-IronPort-AV: E=Sophos;i="5.99,250,1677571200"; d="scan'208";a="727823292" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by orsmga008.jf.intel.com with ESMTP; 04 May 2023 18:37:59 -0700 From: "Guo, Gua" To: devel@edk2.groups.io Cc: gua.guo@intel.com, Michael D Kinney , Hao A Wu , Ray Ni , Chris Johnson Subject: [PATCH v1 1/2] MdeModulePkg: Add more PciHostBridgeLib gmock support Date: Fri, 5 May 2023 09:37:50 +0800 Message-Id: <20230505013751.497-2-gua.guo@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 In-Reply-To: <20230505013751.497-1-gua.guo@intel.com> References: <20230505013751.497-1-gua.guo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Gua Guo REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4443 Add Google Mock Library for PciHostBridgeLib Cc: Michael D Kinney Cc: Hao A Wu Cc: Ray Ni Cc: Chris Johnson Signed-off-by: Gua Guo --- 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/MockP= ciHostBridgeLib.h create mode 100644 MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBr= idgeLib/MockPciHostBridgeLib.cpp create mode 100644 MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBr= idgeLib/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 @@ =0D [Includes]=0D Include=0D + Test/Mock/Include=0D =0D [Includes.Common.Private]=0D Library/BrotliCustomDecompressLib/brotli/c/include=0D 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=0D DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf= =0D }=0D +=0D + #=0D + # Build HOST_APPLICATION Libraries=0D + #=0D + MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHo= stBridgeLib.inf=0D diff --git a/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostB= ridgeLib.h b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostB= ridgeLib.h new file mode 100644 index 0000000000..14e45139af --- /dev/null +++ b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockPciHostBridgeLi= b.h @@ -0,0 +1,40 @@ +/** @file=0D + Google Test mocks for PciHostBridgeLib=0D +=0D + Copyright (c) 2023, Intel Corporation. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#ifndef MOCK_PCI_HOST_BRIDGE_LIB_H_=0D +#define MOCK_PCI_HOST_BRIDGE_LIB_H_=0D +=0D +#include =0D +#include =0D +extern "C" {=0D +#include =0D +#include =0D +}=0D +=0D +struct MockPciHostBridgeLib {=0D + MOCK_INTERFACE_DECLARATION (MockPciHostBridgeLib);=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + PCI_ROOT_BRIDGE *,=0D + PciHostBridgeGetRootBridges,=0D + (UINTN *Count)=0D + );=0D + MOCK_FUNCTION_DECLARATION (=0D + VOID,=0D + PciHostBridgeFreeRootBridges,=0D + (PCI_ROOT_BRIDGE *Bridges,=0D + UINTN Count)=0D + );=0D + MOCK_FUNCTION_DECLARATION (=0D + VOID,=0D + PciHostBridgeResourceConflict,=0D + (EFI_HANDLE HostBridgeHandle,=0D + VOID *Configuration)=0D + );=0D +};=0D +=0D +#endif=0D diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib= /MockPciHostBridgeLib.cpp b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockP= ciHostBridgeLib/MockPciHostBridgeLib.cpp new file mode 100644 index 0000000000..4b15aed169 --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPc= iHostBridgeLib.cpp @@ -0,0 +1,14 @@ +/** @file=0D + Mock instance of the PCI Host Bridge Library.=0D +=0D + Copyright (c) 2023, Intel Corporation. All rights reserved.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +=0D +MOCK_INTERFACE_DEFINITION(MockPciHostBridgeLib);=0D +=0D +MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeGetRootBridges= , 1, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeFreeRootBridge= s, 2, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION(MockPciHostBridgeLib, PciHostBridgeResourceConfli= ct, 2, EFIAPI);=0D diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib= /MockPciHostBridgeLib.inf b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockP= ciHostBridgeLib/MockPciHostBridgeLib.inf new file mode 100644 index 0000000000..d5b4a47abe --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPc= iHostBridgeLib.inf @@ -0,0 +1,35 @@ +## @file=0D +# Mock instance of the PCI Host Bridge Library.=0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D MockPciHostBridgeLib=0D + FILE_GUID =3D B51721FE-0BBA-4611-B9A5-ED13C49AC060= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D PciHostBridgeLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build=0D +# tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + MockPciHostBridgeLib.cpp=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec=0D +=0D +[LibraryClasses]=0D + GoogleTestLib=0D +=0D +[BuildOptions]=0D + MSFT:*_*_*_CC_FLAGS =3D /EHsc=0D --=20 2.39.2.windows.1