From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web11.101096.1683526674075852574 for ; Sun, 07 May 2023 23:17:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=fqMiZN3v; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: victorx.hsu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683526675; x=1715062675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hm8+vru2syP+8ME2Fc9O+a1rI7rLStkPOL34UDeqKeI=; b=fqMiZN3veZ/59EEU/WWbgoPEglEH0E0l14m2og3gRzINBLqkh1/aDi9u ZZSMYSYGI96g0j3wAG+p30ahJnFlvGd6HPudLFI45YJAaBmAwX8rSB10/ McEROw7uxUm/ol0j5I35Vo6U8KLOObmYRD8jecRTRomA1z0uiTpk8/jkI SO81nZ58Wncf1pSDkSCYEbb/a1tPmVsO2TFSdLu4svLMUc9p7UCQZoHlx 3KtBIjojIoEpTI+0PcsoAFDwvx7KcC8kS6NFDvyRNzam96B23riFYL2Ll Mw4OG7x/BJYqFFg423CvZ3h5T8qSXiE38h0OvMDV/9yzTYmUIDNd+NZT/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="349600341" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="349600341" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2023 23:17:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="1028303215" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="1028303215" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by fmsmga005.fm.intel.com with ESMTP; 07 May 2023 23:17:53 -0700 From: victorx.hsu@intel.com To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, Gua Guo , Hao A Wu , Ray Ni , Chris Johnson Subject: [PATCH v2 1/2] MdeModulePkg: Add more PciHostBridgeLib gmock support Date: Mon, 8 May 2023 14:17:47 +0800 Message-Id: <20230508061748.104-2-victorx.hsu@intel.com> X-Mailer: git-send-email 2.39.2.windows.1 In-Reply-To: <20230508061748.104-1-victorx.hsu@intel.com> References: <20230508061748.104-1-victorx.hsu@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..a63bed895c --- /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..ad4edec73e --- /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 HOST_APPLICATION=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