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 4547494107B for ; Thu, 9 May 2024 05:56:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UloWw7MbZKpdAr7xpE766dms4KsACJ8KO/N2ln6gnFE=; 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=1715234208; v=1; b=rxCCzZm7niHXUCcr5VOtH1g379dkgj8tNyPEYJftFjU8lRKJ5VrAE1GUu7U4j0JajGLj4w8X pzJDIiTE6dTBvVAXgKJ0Hyvq1Pw9KYofpyQjk31ZVYbDk6Z57tFlR7rfCzRZInC07QwgFLSgz7d f2T5Oorh7HK+wjsHT2vC8TRi1z92w3sSVBIji/us7fFt6joosbzrnRUZ3eETttG95GKR8WMwAjn eBmjbN8r6q4lKt1uTdIQoBpDUm87LVy1zD+B7c8B9NxVRHed2Us7qZI+VFY4ZeNPe02e8arjbVL 1WxHab8LLvcAU3tVwWK5QdAd455P15wPb7Tgg2x6HmNcQ== X-Received: by 127.0.0.2 with SMTP id eC7TYY7687511xaPslSuef2M; Wed, 08 May 2024 22:56:48 -0700 X-Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by mx.groups.io with SMTP id smtpd.web11.3559.1715234205772436340 for ; Wed, 08 May 2024 22:56:45 -0700 X-Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6f04f01f29aso328172a34.0 for ; Wed, 08 May 2024 22:56:45 -0700 (PDT) X-Gm-Message-State: 8q6hXxDYAzHDeWbxbaQetHzMx7686176AA= X-Google-Smtp-Source: AGHT+IGh+0IUaAfDozf+EMEWtZNTjutaXO9UXDLsEC/azNG6PVQHBKQrXB1/4XoHbMh0fGXZafpJag== X-Received: by 2002:a05:6870:d1c2:b0:239:7008:b751 with SMTP id 586e51a60fabf-2409808b4ddmr5116555fac.34.1715234204930; Wed, 08 May 2024 22:56:44 -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 d2e1a72fcca58-6f4d2b26cf5sm525611b3a.195.2024.05.08.22.56.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 22:56:44 -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 v2 10/13] MdePkg: : Add MockUefiBootServicesTableLib Date: Wed, 8 May 2024 22:56:30 -0700 Message-Id: <20240509055633.828642-11-doug.edk2@gmail.com> In-Reply-To: <20240509055633.828642-1-doug.edk2@gmail.com> References: <20240509055633.828642-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 22:56:45 -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=rxCCzZm7; 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 (#118725): https://edk2.groups.io/g/devel/message/118725 Mute This Topic: https://groups.io/mt/105996588/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-