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 87B61D80D4E for ; Fri, 24 May 2024 05:45:30 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QOvSGCPwhgMIldbdLoQISriCXl4oXi7+BC/++pst2lI=; 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=1716529529; v=1; b=e2FGICg9RnumAcCO+AAfipgtnzKsE69g05pA7h1DgKQcZ5zx1n3uVqbli5HYG4QeFQ+uv2DP 6UeAy0dhvNN0Jcrkw9XnaW4dWLeGIH7LMA2R/Hhuv729YwFPtDufJnk0mUdAd694eOoT+zHq7IJ giNn+uF5WRPqXfzxvX5NXmrzcffo5b/DLqZdJSE32u+sLNWSG1TdXNvCFbrhNQ7fLfYvNHnX3F1 QYDTM/yMWdipIk/HDs0KmIiLveKvhyb+w7HVA+6XKDCyD+hnKp0Ei6ozIjqA2hOT4mk6ilqEC0U OVVAMP7GrEOSC5PG+5mXCAJA1TcXmF7I/FFXAeStEXOlA== X-Received: by 127.0.0.2 with SMTP id DhINYY7687511x2tLv5H1og0; Thu, 23 May 2024 22:45:29 -0700 X-Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) by mx.groups.io with SMTP id smtpd.web11.9354.1716529526342930672 for ; Thu, 23 May 2024 22:45:26 -0700 X-Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-24c91c46d00so555335fac.2 for ; Thu, 23 May 2024 22:45:26 -0700 (PDT) X-Gm-Message-State: 2w2HBIuZp7QorkqRy2tiLy1hx7686176AA= X-Google-Smtp-Source: AGHT+IExkQr7bUHvSDwHT62S+J2n4Q6mAi74+lSLFHeLWcxPjeBCHbbr5PBLCsx7Y7V5kg5LVvni6Q== X-Received: by 2002:a05:6870:420a:b0:23b:f2d0:7b9c with SMTP id 586e51a60fabf-24ca1203867mr1428878fac.24.1716529525428; Thu, 23 May 2024 22:45:25 -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-6f8fcfe64a4sm471919b3a.158.2024.05.23.22.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 22:45:25 -0700 (PDT) From: "Doug Flick via groups.io" X-Google-Original-From: Flickdm To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v3 10/20] MdePkg: : Add MockUefiBootServicesTableLib Date: Thu, 23 May 2024 22:45:02 -0700 Message-Id: <20240524054512.523329-11-douglas.flick@microsoft.com> In-Reply-To: <20240524054512.523329-1-douglas.flick@microsoft.com> References: <20240524054512.523329-1-douglas.flick@microsoft.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: Thu, 23 May 2024 22:45:26 -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=e2FGICg9; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=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 e666636b7c..6a85d02236 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -43,6 +43,7 @@ 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 0000000000..8b64fd195a --- /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 0000000000..d72b941323 --- /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 0000000000..ced6255418 --- /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 (#119237): https://edk2.groups.io/g/devel/message/119237 Mute This Topic: https://groups.io/mt/106276862/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-