From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id E8B47941956 for ; Wed, 8 May 2024 15:29:43 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=0QcMPRmHklXmG39K5K3QekbPBh51E8VxQ62zBZ9ho5U=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1715182182; v=1; b=wKloFHBtPxj8lnysxXgB2GtQIt42lYkZyti54y//kF/xQSc+kuZ+xSI4Mv1e1TRD6M+LuQhi JHw+L7rxR+zd1v4KqeS5YmrqymEMrD9yjC6D1AEpJryL6kvxWwnlSt3csHH624GuIK1FyNNs2ly rg+poZtIbN9H3VmU0FwVr/90jkkBjTtx+Gt2esQULE48td7ue371h37nNNFW65ABEGQMoWFulDQ GoB3yy9xtbPozpXp8wIhf83yb58Ron50xDpmQzA3Q/ltkUb2Gdt81RYBWdyqyHt0pbqJoetWacK KvIGtZGTZB8L3rqqnIyAjCZRKdm1CpCMJgOwjouq0vH9Q== X-Received: by 127.0.0.2 with SMTP id 2iIzYY7687511xoe0sSOZ3L3; Wed, 08 May 2024 08:29:42 -0700 X-Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mx.groups.io with SMTP id smtpd.web10.15716.1715182178940062898 for ; Wed, 08 May 2024 08:29:38 -0700 X-Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1eeb1a4c10aso8527895ad.3 for ; Wed, 08 May 2024 08:29:38 -0700 (PDT) X-Gm-Message-State: HvkoqI1K1LG0f73t7DFIFgGXx7686176AA= X-Google-Smtp-Source: AGHT+IEn6hNZBr1aOqihDL6wuOGzaC5xC+/9ivEDzGtKqEy5YSpEq4SzWE1KOkj7zSOr/rTLyR+S/A== X-Received: by 2002:a17:902:e48b:b0:1eb:7dc:7097 with SMTP id d9443c01a7336-1eeb0796149mr24585595ad.48.1715182178187; Wed, 08 May 2024 08:29:38 -0700 (PDT) X-Received: from localhost.localdomain (c-67-160-15-86.hsd1.wa.comcast.net. [67.160.15.86]) by smtp.gmail.com with ESMTPSA id kt7-20020a170903088700b001e862f0b319sm12032291plb.264.2024.05.08.08.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 08:29:37 -0700 (PDT) From: "Doug Flick via groups.io" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v1 11/14] MdePkg: : Add MockUefiBootServicesTableLib Date: Wed, 8 May 2024 08:29:22 -0700 Message-Id: <20240508152925.741226-12-doug.edk2@gmail.com> In-Reply-To: <20240508152925.741226-1-doug.edk2@gmail.com> References: <20240508152925.741226-1-doug.edk2@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 08 May 2024 08:29:39 -0700 Resent-From: dougflick@microsoft.com Reply-To: devel@edk2.groups.io,dougflick@microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=wKloFHBt; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io From: Doug Flick This commit adds a mock library for UefiBootServicesTableLib. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Doug Flick [MSFT] --- MdePkg/Test/MdePkgHostTest.dsc = | 1 + MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/MockUefiB= ootServicesTableLib.inf | 32 ++++++++ MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiBootServicesTableLib.h= | 78 ++++++++++++++++++++ MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/MockUefiB= ootServicesTableLib.cpp | 69 +++++++++++++++++ 4 files changed, 180 insertions(+) diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc index e666636b7c55..6a85d02236a0 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -43,6 +43,7 @@ [Components] MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf=0D MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf=0D MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/Mock= UefiRuntimeServicesTableLib.inf=0D + MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/MockUef= iBootServicesTableLib.inf=0D MdePkg/Test/Mock/Library/GoogleTest/MockPeiServicesLib/MockPeiServicesLi= b.inf=0D MdePkg/Test/Mock/Library/GoogleTest/MockHobLib/MockHobLib.inf=0D MdePkg/Test/Mock/Library/GoogleTest/MockFdtLib/MockFdtLib.inf=0D diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableL= ib/MockUefiBootServicesTableLib.inf b/MdePkg/Test/Mock/Library/GoogleTest/M= ockUefiBootServicesTableLib/MockUefiBootServicesTableLib.inf new file mode 100644 index 000000000000..8b64fd195acd --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/Mock= UefiBootServicesTableLib.inf @@ -0,0 +1,32 @@ +## @file=0D +# Mock implementation of the UEFI Boot Services Table Library.=0D +#=0D +# Copyright (c) Microsoft Corporation.=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D MockUefiBootServicesTableLib=0D + FILE_GUID =3D 67EA4614-E276-49EC-9AE6-B97ACCEA676E= =0D + MODULE_TYPE =3D HOST_APPLICATION=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D UefiBootServicesTableLib|HOST_APPLICA= TION=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D +#=0D +=0D +[Sources]=0D + MockUefiBootServicesTableLib.cpp=0D +=0D +[LibraryClasses]=0D + GoogleTestLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec=0D +=0D +[BuildOptions]=0D + MSFT:*_*_*_CC_FLAGS =3D /EHsc=0D diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiBootServic= esTableLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiBootServ= icesTableLib.h new file mode 100644 index 000000000000..d72b941323c1 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiBootServicesTable= Lib.h @@ -0,0 +1,78 @@ +/** @file=0D + Google Test mocks for UefiBootServicesTableLib=0D +=0D + Copyright (c) Microsoft Corporation.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#ifndef MOCK_UEFI_BOOT_SERVICES_TABLE_LIB_H_=0D +#define MOCK_UEFI_BOOT_SERVICES_TABLE_LIB_H_=0D +=0D +#include =0D +#include =0D +extern "C" {=0D + #include =0D + #include =0D +}=0D +=0D +//=0D +// Declarations to handle usage of the UefiBootServiceTableLib by creating= mock=0D +//=0D +struct MockUefiBootServicesTableLib {=0D + MOCK_INTERFACE_DECLARATION (MockUefiBootServicesTableLib);=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_GetMemoryMap,=0D + (IN OUT UINTN *MemoryMapSize,=0D + OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,=0D + OUT UINTN *MapKey,=0D + OUT UINTN *DescriptorSize,=0D + OUT UINT32 *DescriptorVersion)=0D + );=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_CreateEvent,=0D + (IN UINT32 Type,=0D + IN EFI_TPL NotifyTpl,=0D + IN EFI_EVENT_NOTIFY NotifyFunction,=0D + IN VOID *NotifyContext,=0D + OUT EFI_EVENT *Event)=0D + );=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_CloseEvent,=0D + (IN EFI_EVENT Event)=0D + );=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_HandleProtocol,=0D + (IN EFI_HANDLE Handle,=0D + IN EFI_GUID *Protocol,=0D + OUT VOID **Interface)=0D + );=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_LocateProtocol,=0D + (IN EFI_GUID *Protocol,=0D + IN VOID *Registration OPTIONAL,=0D + OUT VOID **Interface)=0D + );=0D +=0D + MOCK_FUNCTION_DECLARATION (=0D + EFI_STATUS,=0D + gBS_CreateEventEx,=0D + (IN UINT32 Type,=0D + IN EFI_TPL NotifyTpl,=0D + IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,=0D + IN CONST VOID *NotifyContext OPTIONAL,=0D + IN CONST EFI_GUID *EventGroup OPTIONAL,=0D + OUT EFI_EVENT *Event)=0D + );=0D +};=0D +=0D +#endif // MOCK_UEFI_BOOT_SERVICES_TABLE_LIB_H_=0D diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableL= ib/MockUefiBootServicesTableLib.cpp b/MdePkg/Test/Mock/Library/GoogleTest/M= ockUefiBootServicesTableLib/MockUefiBootServicesTableLib.cpp new file mode 100644 index 000000000000..ced6255418a2 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/Mock= UefiBootServicesTableLib.cpp @@ -0,0 +1,69 @@ +/** @file=0D + Google Test mocks for UefiBootServicesTableLib=0D +=0D + Copyright (c) Microsoft Corporation.=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +#include =0D +=0D +MOCK_INTERFACE_DEFINITION (MockUefiBootServicesTableLib);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_GetMemoryMap, = 5, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_CreateEvent, 5= , EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_CloseEvent, 1,= EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_HandleProtocol= , 3, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_LocateProtocol= , 3, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockUefiBootServicesTableLib, gBS_CreateEventEx,= 6, EFIAPI);=0D +=0D +static EFI_BOOT_SERVICES LocalBs =3D {=0D + { 0, 0, 0, 0, 0 }, // EFI_TABLE_HEADER=0D + NULL, // EFI_RAISE_TPL=0D + NULL, // EFI_RESTORE_TPL=0D + NULL, // EFI_ALLOCATE_PAGES=0D + NULL, // EFI_FREE_PAGES=0D + gBS_GetMemoryMap, // EFI_GET_MEMORY_MAP=0D + NULL, // EFI_ALLOCATE_POOL=0D + NULL, // EFI_FREE_POOL=0D + gBS_CreateEvent, // EFI_CREATE_EVENT=0D + NULL, // EFI_SET_TIMER=0D + NULL, // EFI_WAIT_FOR_EVENT=0D + NULL, // EFI_SIGNAL_EVENT=0D + gBS_CloseEvent, // EFI_CLOSE_EVENT=0D + NULL, // EFI_CHECK_EVENT=0D + NULL, // EFI_INSTALL_PROTOCOL_INTERFACE=0D + NULL, // EFI_REINSTALL_PROTOCOL_INTERFACE=0D + NULL, // EFI_UNINSTALL_PROTOCOL_INTERFACE=0D + gBS_HandleProtocol, // EFI_HANDLE_PROTOCOL=0D + NULL, // VOID=0D + NULL, // EFI_REGISTER_PROTOCOL_NOTIFY=0D + NULL, // EFI_LOCATE_HANDLE=0D + NULL, // EFI_LOCATE_DEVICE_PATH=0D + NULL, // EFI_INSTALL_CONFIGURATION_TABLE=0D + NULL, // EFI_IMAGE_LOAD=0D + NULL, // EFI_IMAGE_START=0D + NULL, // EFI_EXIT=0D + NULL, // EFI_IMAGE_UNLOAD=0D + NULL, // EFI_EXIT_BOOT_SERVICES=0D + NULL, // EFI_GET_NEXT_MONOTONIC_COUNT=0D + NULL, // EFI_STALL=0D + NULL, // EFI_SET_WATCHDOG_TIMER=0D + NULL, // EFI_CONNECT_CONTROLLER=0D + NULL, // EFI_DISCONNECT_CONTROLLER=0D + NULL, // EFI_OPEN_PROTOCOL=0D + NULL, // EFI_CLOSE_PROTOCOL=0D + NULL, // EFI_OPEN_PROTOCOL_INFORMATION=0D + NULL, // EFI_PROTOCOLS_PER_HANDLE=0D + NULL, // EFI_LOCATE_HANDLE_BUFFER=0D + gBS_LocateProtocol, // EFI_LOCATE_PROTOCOL=0D + NULL, // EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES=0D + NULL, // EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES=0D + NULL, // EFI_CALCULATE_CRC32=0D + NULL, // EFI_COPY_MEM=0D + NULL, // EFI_SET_MEM=0D + gBS_CreateEventEx // EFI_CREATE_EVENT_EX=0D +};=0D +=0D +extern "C" {=0D + EFI_BOOT_SERVICES *gBS =3D &LocalBs;=0D + EFI_HANDLE gImageHandle =3D NULL;=0D + EFI_SYSTEM_TABLE *gST =3D NULL;=0D +}=0D --=20 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118684): https://edk2.groups.io/g/devel/message/118684 Mute This Topic: https://groups.io/mt/105983251/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-