From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101872+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101872+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769952; cv=none; d=zohomail.com; s=zohoarc; b=LAAjjKTM4en7JjyHvqqJ8kwqM8uHRlMaThhNv8JjySofRYJnm8RkmMPmL1snp9bMq+K7ANxORC40f87tEJvDm/9n/Tze6jwwy0oOtujbfVRnJZ2gLpTZDXA3EoQr2vr4wB0OE3wBtLjtxMoYiLnTkeCFg/1S8LrTb+82a91wXMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769952; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=sx6kobwQtxWwsQwJC0W4ChAEnCrBMJZO+ogMwwnNJY4=; b=LjOwzCSlsrcRdVKyg2OjavwGW/yfnyT1beSA1jbSfwwEn3F5lffVsTH4Gl+1smBNgkmINWMT1lfqn6rnyjHhu67067sCmFThoRzrjTrlsWRyrsIH2AxIb0emUVzgMOtjcTQnl40kpMFBMf+83o8PPgTctpMMQ1pqfXhs8T/qpTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101872+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769952953584.2418566485933; Sat, 25 Mar 2023 11:45:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EoEMYY1788612xMaNSEJniZ2; Sat, 25 Mar 2023 11:45:52 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28284.1679769950911591616 for ; Sat, 25 Mar 2023 11:45:51 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655064" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655064" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541392" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541392" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:50 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Andrew Fish , Leif Lindholm , Michael Kubacki , Sean Brogan Subject: [edk2-devel] [Patch 01/12] UnitTestFrameworkPkg: Add subhook submodule required for gmock Date: Sat, 25 Mar 2023 11:45:29 -0700 Message-Id: <20230325184541.596-2-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: 7JVkyd0rcHnCeHFIUj5Mm0Xzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769952; bh=qhK2qhLKZF97lIwfb1Q+jfltVIpXdyrruvjeFdNYRQo=; h=Cc:Date:From:Reply-To:Subject:To; b=k7caFQgtgUtBEzR4+4TLkAEVeEhvglj/MKkznA45MQcr0X3nEAvs/APLb0NlnlXJEtu pTJ8YL/5YNoS9MwS8u1/qJ1csegUlrx42aYX83S4P3eeLOciFDm1btdzzV4y2aKReYJET OHoCVrnZj9cX5wVIEfDqaMJp958+hSvrlYk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769953759100002 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Add subhook submodule that is required to hook internal functions when using gmock. https://github.com/Zeex/subhook Add SubhookLib library class and SubhookLib library instance. Include the SUBHOOK_STATIC define in the SubhookLib INF file so it builds as a static library. Also include the SUBHOOK_STATIC define in SubhookLib.h so all modules using SubhookLib properly link SubhookLib as a static library. Cc: Andrew Fish Cc: Leif Lindholm Cc: Michael D Kinney Cc: Michael Kubacki Cc: Sean Brogan Signed-off-by: Chris Johnson --- .gitmodules | 3 ++ ReadMe.rst | 1 + .../Include/Library/SubhookLib.h | 15 ++++++++ .../Library/SubhookLib/SubhookLib.inf | 36 +++++++++++++++++++ .../Library/SubhookLib/SubhookLib.uni | 11 ++++++ .../Library/SubhookLib/subhook | 1 + .../Test/UnitTestFrameworkPkgHostTest.dsc | 1 + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | 2 ++ .../UnitTestFrameworkPkgHost.dsc.inc | 1 + 9 files changed, 71 insertions(+) create mode 100644 UnitTestFrameworkPkg/Include/Library/SubhookLib.h create mode 100644 UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf create mode 100644 UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni create mode 160000 UnitTestFrameworkPkg/Library/SubhookLib/subhook diff --git a/.gitmodules b/.gitmodules index 8011a88d9d25..fe8a43be93ba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ [submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"] path =3D UnitTestFrameworkPkg/Library/GoogleTestLib/googletest url =3D https://github.com/google/googletest.git +[submodule "UnitTestFrameworkPkg/Library/SubhookLib/subhook"] + path =3D UnitTestFrameworkPkg/Library/SubhookLib/subhook + url =3D https://github.com/Zeex/subhook.git diff --git a/ReadMe.rst b/ReadMe.rst index 497d96355908..91b9cf3c5e50 100644 --- a/ReadMe.rst +++ b/ReadMe.rst @@ -94,6 +94,7 @@ that are covered by additional licenses. - `MdeModulePkg/Universal/RegularExpressionDxe/oniguruma `__ - `UnitTestFrameworkPkg/Library/CmockaLib/cmocka `__ - `UnitTestFrameworkPkg/Library/GoogleTestLib/googletest `__ +- `UnitTestFrameworkPkg/Library/SubhookLib/subhook `__ - `RedfishPkg/Library/JsonLib/jansson `__ =20 The EDK II Project is composed of packages. The maintainers for each packa= ge diff --git a/UnitTestFrameworkPkg/Include/Library/SubhookLib.h b/UnitTestFr= ameworkPkg/Include/Library/SubhookLib.h new file mode 100644 index 000000000000..46783adfccfb --- /dev/null +++ b/UnitTestFrameworkPkg/Include/Library/SubhookLib.h @@ -0,0 +1,15 @@ +/** @file + SubhookLib class with APIs from the subhook project + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SUBHOOK_LIB_H_ +#define SUBHOOK_LIB_H_ + +#define SUBHOOK_STATIC +#include + +#endif diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf b/UnitT= estFrameworkPkg/Library/SubhookLib/SubhookLib.inf new file mode 100644 index 000000000000..e8e8ffb90750 --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf @@ -0,0 +1,36 @@ +## @file +# This module provides Subhook Library implementation. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SubhookLib + MODULE_UNI_FILE =3D SubhookLib.uni + FILE_GUID =3D 70E03378-E140-46A8-8E65-7719DA14A240 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 0.1 + LIBRARY_CLASS =3D SubhookLib|HOST_APPLICATION + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + subhook/subhook.c + +[Packages] + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS =3D=3D /c /EHsc /Zi /DSUBHOOK_STATIC + MSFT:NOOPT_*_*_CC_FLAGS =3D /Od + + GCC:*_*_*_CC_FLAGS =3D=3D -g -c + + GCC:NOOPT_*_*_CC_FLAGS =3D -O0 + GCC:*_*_IA32_CC_FLAGS =3D -m32 + GCC:*_*_X64_CC_FLAGS =3D -m64 diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni b/UnitT= estFrameworkPkg/Library/SubhookLib/SubhookLib.uni new file mode 100644 index 000000000000..eb61f034047e --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.uni @@ -0,0 +1,11 @@ +// /** @file +// This module provides Subhook Library implementation. +// +// Copyright (c) 2022, Intel Corporation. All rights reserved.
+// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "Subhook Library i= mplementation" + +#string STR_MODULE_DESCRIPTION #language en-US "This module provi= des Subhook Library implementation." diff --git a/UnitTestFrameworkPkg/Library/SubhookLib/subhook b/UnitTestFram= eworkPkg/Library/SubhookLib/subhook new file mode 160000 index 000000000000..83d4e1ebef35 --- /dev/null +++ b/UnitTestFrameworkPkg/Library/SubhookLib/subhook @@ -0,0 +1 @@ +Subproject commit 83d4e1ebef3588fae48b69a7352cc21801cb70bc diff --git a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc b/U= nitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc index 708ef7f9ab35..722509c8f26f 100644 --- a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc +++ b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc @@ -33,6 +33,7 @@ [Components] # UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf + UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAlloca= tionLibPosix.inf UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec b/UnitTestFramew= orkPkg/UnitTestFrameworkPkg.dec index 14e387d63a0f..30b489915d4a 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec @@ -20,6 +20,7 @@ [Includes] Library/CmockaLib/cmocka/include Library/GoogleTestLib/googletest/googletest/include Library/GoogleTestLib/googletest/googlemock/include + Library/SubhookLib/subhook =20 [Includes.Common.Private] PrivateInclude @@ -34,6 +35,7 @@ [LibraryClasses] ## @libraryclass GoogleTest infrastructure # GoogleTestLib|Include/Library/GoogleTestLib.h + SubhookLib|Include/Library/SubhookLib.h =20 [LibraryClasses.Common.Private] ## @libraryclass Provides a unit test result report diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTe= stFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc index 7f5dfa30ed60..e77897bd326f 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc @@ -15,6 +15,7 @@ [LibraryClasses.common.HOST_APPLICATION] CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLibNull/BaseCache= MaintenanceLibNull.inf CmockaLib|UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf GoogleTestLib|UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.i= nf + SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.i= nf DebugLib|UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.= inf MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationL= ibPosix/MemoryAllocationLibPosix.inf --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101872): https://edk2.groups.io/g/devel/message/101872 Mute This Topic: https://groups.io/mt/97848870/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101873+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101873+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769954; cv=none; d=zohomail.com; s=zohoarc; b=QsaRuOtg16meN6sWWIZ6wwHKP3xl6s/SmlT84XeuRqcjT8gIFi11y9M4jyTliOVSKX0MLSsaJnacdektasHmWbR64RKXuuoyNRZwIUKhx0KEBCpQr9on10hXjUOhztJ6eJLrpSuY+iC7YS+eoy+wIF8F/3RScsEuN7XWwxAr92k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769954; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=BE/Vc8hMnY2MEiNonnKrYgOCtw3DppBsrWYV2Gj46Rg=; b=Lq18HGIrGr+ZS4b2bGflrUZwKwdHfk2NXuEa4UoWINAFhCdE/0EASTfgUYx0/gI9ASDCAH0A3lMd++R/LSKBYxMp27j/7zCTj+0SIh8RQFpFyu4IBJrOMF3dlV9Y4LD87R4skQoa6hyHg1Mo6QYp9jL4gWj2oYkKEcNoegyvwcc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101873+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769954368841.1182502944589; Sat, 25 Mar 2023 11:45:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tT4TYY1788612xuE57G4DGgk; Sat, 25 Mar 2023 11:45:53 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.28398.1679769951862510087 for ; Sat, 25 Mar 2023 11:45:52 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655069" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655069" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541395" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541395" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:50 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Sean Brogan , Michael Kubacki , Liming Gao Subject: [edk2-devel] [Patch 02/12] .pytool/CISettings.py: Add subhook submodule Date: Sat, 25 Mar 2023 11:45:30 -0700 Message-Id: <20230325184541.596-3-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: WBkQSYa318AAQ0Ea09LZPUPpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769953; bh=s4DhzWR5nqzQ4IZ93TsMooDTGbsqCDHaROZIUM31BjE=; h=Cc:Date:From:Reply-To:Subject:To; b=WHv4QK2xAePeQxcZf1jUk8hMhdcIUwAMkPTj2dxIw43Tk6lvKqPLnkFFzIVzHCgpghm h4PzL6Y2I/PKulLci0+L6+JwhplnwSbQUf1LAbp03fqjSdMJNKqd6n7Hw80zG3Ow+0/xy ewvQwebgske8W985jmGRQP5IvhwvDxeGemU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769955745100006 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Add submodule for https://github.com/Zeex/subhook This submodule is required to hook internal functions when using gmock. Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Chris Johnson --- .pytool/CISettings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py index d87c8e838e61..e3f44add5834 100644 --- a/.pytool/CISettings.py +++ b/.pytool/CISettings.py @@ -193,6 +193,8 @@ class Settings(CiBuildSettingsManager, UpdateSettingsMa= nager, SetupSettingsManag "BaseTools/Source/C/BrotliCompress/brotli", False)) rs.append(RequiredSubmodule( "RedfishPkg/Library/JsonLib/jansson", False)) + rs.append(RequiredSubmodule( + "UnitTestFrameworkPkg/Library/SubhookLib/subhook", False)) return rs =20 def GetName(self): --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101873): https://edk2.groups.io/g/devel/message/101873 Mute This Topic: https://groups.io/mt/97848871/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101874+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101874+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769955; cv=none; d=zohomail.com; s=zohoarc; b=X9uBVteXscCx3qSlIZ6KUe1LNedMOH0y/fRTNMbKPTjFMyjT36vsV1b2cegXoHRPznZWCZ+vWAnZOp7T1KJGNFtR1XWJtNJzZ9Y+QYW8eD1z+1CYo8ZAc6nC2wky9kjbBOsfjl4mwf1yQ9yielZ417lp26aaAskRX2M8hLz0o9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769955; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=iuR2IhumcB2kjBAkahUnV2/1TypNROuGFmET60XOmS0=; b=SBArdA341Fy3gCIKldvSiMjypzeDV+AnbTOLXpVtKBcOXSKNKeUYfP9Rc/sQ4kv8wojI5YlMXRpKZhsIMVWx5nE/u50xCHx67LEkhpWO7+HEjJNtNhj4Iolu9i6AQQEibxVGfMIX48KK2yZu06QjU8Y2ct3YpZQUcUu+HtjQWLA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101874+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769955966353.78057056296655; Sat, 25 Mar 2023 11:45:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xcsHYY1788612xensdHSXasM; Sat, 25 Mar 2023 11:45:55 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28284.1679769950911591616 for ; Sat, 25 Mar 2023 11:45:52 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655072" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655072" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541400" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541400" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Sean Brogan , Michael Kubacki Subject: [edk2-devel] [Patch 03/12] UnitTestFrameworkPkg: Add gmock support to GoogleTestLib Date: Sat, 25 Mar 2023 11:45:31 -0700 Message-Id: <20230325184541.596-4-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: zTmVsfbZbB3OhYZKFQnKn6g6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769955; bh=2qiLcOH8HJy+Lq7SxqFyDoYo5U0iONfREfc7hW5HKxg=; h=Cc:Date:From:Reply-To:Subject:To; b=sx639Wjgt7sxDX4LqZCKBLKVaINxMTlJYOxZE1KFCRIYV7ih0LdO7L8IeaZlgeqNjU5 Guk0QpXPuOei1KGTc/RjFnXYJLxHOTRRwRknp3SB9JEMyvJlBneS0H3/iCKjjuVAHapN5 ZxloCqAVPVtskIr0Fmvrwuo8wcqLw1RFW7Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769957804100020 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 * Add gmock support to GoogleTestLib * Add FunctionMockLib library class and library instance * Add GoogleTest extension to GoogleTestLib.h for CHAR16 type * Add GoogleTest extension to GoogleTestLib.h for buffer types * HOST_APPLICATION only supports IA32/X64 Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Signed-off-by: Chris Johnson --- .../Include/Library/FunctionMockLib.h | 131 ++++++++++++++++++ .../Include/Library/GoogleTestLib.h | 96 +++++++++++++ .../Library/CmockaLib/CmockaLib.inf | 2 +- .../Library/FunctionMockLib/FunctionMockLib.c | 7 + .../FunctionMockLib/FunctionMockLib.inf | 31 +++++ .../FunctionMockLib/FunctionMockLib.uni | 11 ++ .../Library/GoogleTestLib/GoogleTestLib.inf | 6 +- .../Library/GoogleTestLib/GoogleTestLib.uni | 3 - .../Test/UnitTestFrameworkPkgHostTest.dsc | 1 + .../UnitTestFrameworkPkg.ci.yaml | 7 +- UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | 2 + .../UnitTestFrameworkPkgHost.dsc.inc | 1 + 12 files changed, 291 insertions(+), 7 deletions(-) create mode 100644 UnitTestFrameworkPkg/Include/Library/FunctionMockLib.h create mode 100644 UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMo= ckLib.c create mode 100644 UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMo= ckLib.inf create mode 100644 UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMo= ckLib.uni diff --git a/UnitTestFrameworkPkg/Include/Library/FunctionMockLib.h b/UnitT= estFrameworkPkg/Include/Library/FunctionMockLib.h new file mode 100644 index 000000000000..bf7a7066560a --- /dev/null +++ b/UnitTestFrameworkPkg/Include/Library/FunctionMockLib.h @@ -0,0 +1,131 @@ +/** @file + This header allows the mocking of free (C style) functions using gmock. + + Copyright (c) 2023, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef FUNCTION_MOCK_LIB_H_ +#define FUNCTION_MOCK_LIB_H_ + +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////= //// +// The below macros are the public function mock interface that are intend= ed +// to be used outside this file. + +#define MOCK_INTERFACE_DECLARATION(MOCK) \ + static MOCK * Instance; \ + MOCK (); \ + ~MOCK (); + +#define MOCK_INTERFACE_DEFINITION(MOCK) \ + MOCK_STATIC_INSTANCE_DEFINITION (MOCK) \ + MOCK_INTERFACE_CONSTRUCTOR (MOCK) \ + MOCK_INTERFACE_DECONSTRUCTOR (MOCK) + +// Mock function declaration for external functions (i.e. functions to +// mock that do not exist in the compilation unit). +#define MOCK_FUNCTION_DECLARATION(RET_TYPE, FUNC, ARGS) \ + MOCK_FUNCTION_TYPE_DEFINITIONS(RET_TYPE, FUNC, ARGS) \ + MOCK_METHOD (RET_TYPE, FUNC, ARGS); + +// Mock function definition for external functions (i.e. functions to +// mock that do not exist in the compilation unit). +#define MOCK_FUNCTION_DEFINITION(MOCK, FUNC, NUM_ARGS, CALL_TYPE) \ + FUNCTION_DEFINITION_TO_CALL_MOCK(MOCK, FUNC, FUNC, NUM_ARGS, CALL_TYPE) + +// Mock function declaration for internal functions (i.e. functions to +// mock that already exist in the compilation unit). +#define MOCK_FUNCTION_INTERNAL_DECLARATION(RET_TYPE, FUNC, ARGS) \ + MOCK_FUNCTION_DECLARATION(RET_TYPE, FUNC, ARGS) \ + MOCK_FUNCTION_HOOK_DECLARATIONS(FUNC) + +// Mock function definition for internal functions (i.e. functions to +// mock that already exist in the compilation unit). This definition also +// implements MOCK_FUNC() which is later hooked as FUNC(). +#define MOCK_FUNCTION_INTERNAL_DEFINITION(MOCK, FUNC, NUM_ARGS, CALL_TYPE)= \ + FUNCTION_DEFINITION_TO_CALL_MOCK(MOCK, FUNC, MOCK##_##FUNC, NUM_ARGS, CA= LL_TYPE) \ + MOCK_FUNCTION_HOOK_DEFINITIONS(MOCK, FUNC) + +//////////////////////////////////////////////////////////////////////////= //// +// The below macros are private and should not be used outside this file. + +#define MOCK_FUNCTION_HOOK_DECLARATIONS(FUNC) \ + static subhook::Hook Hook##FUNC; \ + struct MockContainer_##FUNC { \ + MockContainer_##FUNC (); \ + ~MockContainer_##FUNC (); \ + }; \ + MockContainer_##FUNC MockContainerInst_##FUNC; + +// This definition implements a constructor and destructor inside a nested +// class to enable automatic installation of the hooks to the associated +// MOCK_FUNC() when the mock object is instantiated in scope and automatic +// removal when the instantiated mock object goes out of scope. +#define MOCK_FUNCTION_HOOK_DEFINITIONS(MOCK, FUNC) \ + subhook :: Hook MOCK :: Hook##FUNC; \ + MOCK :: MockContainer_##FUNC :: MockContainer_##FUNC () { \ + if (MOCK :: Instance =3D=3D NULL) = \ + MOCK :: Hook##FUNC .Install( \ + (FUNC##_ret_type *) ::FUNC, \ + (FUNC##_ret_type *) MOCK##_##FUNC); \ + } \ + MOCK :: MockContainer_##FUNC :: ~MockContainer_##FUNC () { \ + MOCK :: Hook##FUNC .Remove(); \ + } \ + static_assert( \ + std::is_same::value, \ + "Function signature from 'MOCK_FUNCTION_INTERNAL_DEFINITION' macro " \ + "invocation for '" #FUNC "' does not match the function signature " \ + "of '" #FUNC "' function it is mocking. Mismatch could be due to " \ + "different return type, arguments, or calling convention. See " \ + "associated 'MOCK_FUNCTION_INTERNAL_DECLARATION' macro invocation " \ + "for more details."); + +#define MOCK_FUNCTION_TYPE_DEFINITIONS(RET_TYPE, FUNC, ARGS) \ + using FUNC##_ret_type =3D RET_TYPE; \ + using FUNC##_type =3D FUNC##_ret_type ARGS; + +// This function definition simply calls MOCK::Instance->FUNC() which is t= he +// mocked counterpart of the original function. This allows using gmock wi= th +// C free functions (since by default gmock only works with object methods= ). +#define FUNCTION_DEFINITION_TO_CALL_MOCK(MOCK, FUNC, FUNC_DEF_NAME, NUM_AR= GS, CALL_TYPE) \ + extern "C" { = \ + typename MOCK :: FUNC##_ret_type CALL_TYPE FUNC_DEF_NAME( = \ + GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, = \ + (MOCK :: FUNC##_type), = \ + NUM_ARGS)) = \ + { = \ + EXPECT_TRUE(MOCK :: Instance !=3D NULL) = \ + << "Called '" #FUNC "' in '" #MOCK "' function mock object before = " \ + << "an instance of '" #MOCK "' was created in test '" = \ + << ::testing::UnitTest::GetInstance()->current_test_info()->name()= \ + << "'."; = \ + return MOCK :: Instance->FUNC( = \ + GMOCK_PP_REPEAT(GMOCK_INTERNAL_FORWARD_ARG, = \ + (MOCK :: FUNC##_type), = \ + NUM_ARGS)); = \ + } = \ + } + +#define MOCK_STATIC_INSTANCE_DEFINITION(MOCK) MOCK * MOCK :: Instance =3D= NULL; + +#define MOCK_INTERFACE_CONSTRUCTOR(MOCK) = \ + MOCK :: MOCK () { = \ + EXPECT_TRUE(MOCK :: Instance =3D=3D NULL) = \ + << "Multiple instances of '" #MOCK "' function mock object were " = \ + << "created and only one instance is allowed in test '" = \ + << ::testing::UnitTest::GetInstance()->current_test_info()->name() = \ + << "'."; = \ + MOCK :: Instance =3D this; = \ + } + +#define MOCK_INTERFACE_DECONSTRUCTOR(MOCK) \ + MOCK :: ~ MOCK () { \ + MOCK :: Instance =3D NULL; \ + } + +#endif // FUNCTION_MOCK_LIB_H_ diff --git a/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h b/UnitTes= tFrameworkPkg/Include/Library/GoogleTestLib.h index ebec766d4cf7..c0a3d8e66011 100644 --- a/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h +++ b/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h @@ -10,5 +10,101 @@ #define GOOGLE_TEST_LIB_H_ =20 #include +#include +#include + +extern "C" { +#include +} + +//////////////////////////////////////////////////////////////////////////= //// +// Below are the action extensions to GoogleTest and gmock for EDK2 types. +// These actions are intended to be used in EXPECT_CALL (and related gmock +// macros) to support assignments to output arguments in the expected call. +// + +// Action to support pointer types to a buffer (such as UINT8* or VOID*) +ACTION_TEMPLATE ( + SetArgBuffer, + HAS_1_TEMPLATE_PARAMS (size_t, ArgNum), + AND_2_VALUE_PARAMS (Buffer, ByteSize) + ) { + auto ArgBuffer =3D std::get(args); + + std::memcpy (ArgBuffer, Buffer, ByteSize); +} + +//////////////////////////////////////////////////////////////////////////= //// +// Below are the matcher extensions to GoogleTest and gmock for EDK2 types. +// These matchers are intended to be used in EXPECT_CALL (and related gmock +// macros) to support comparisons to input arguments in the expected call. +// +// Note that these matchers can also be used in the EXPECT_THAT or ASSERT_= THAT +// macros to compare whether two values are equal. +// + +// Matcher to support pointer types to a buffer (such as UINT8* or VOID* or +// any structure pointer) +MATCHER_P2 ( + BufferEq, + Buffer, + ByteSize, + std::string ("buffer data to ") + (negation ? "not " : "") + "be the sam= e" + ) { + UINT8 *Actual =3D (UINT8 *)arg; + UINT8 *Expected =3D (UINT8 *)Buffer; + + for (size_t i =3D 0; i < ByteSize; i++) { + if (Actual[i] !=3D Expected[i]) { + *result_listener << "byte at offset " << i + << " does not match expected. [" << std::hex + << "Actual: 0x" << std::setw (2) << std::setfill ('0') + << (unsigned int)Actual[i] << ", " + << "Expected: 0x" << std::setw (2) << std::setfill ('0') + << (unsigned int)Expected[i] << "]"; + return false; + } + } + + *result_listener << "all bytes match"; + return true; +} + +// Matcher to support CHAR16* type +MATCHER_P ( + Char16StrEq, + String, + std::string ("strings to ") + (negation ? "not " : "") + "be the same" + ) { + CHAR16 *Actual =3D (CHAR16 *)arg; + CHAR16 *Expected =3D (CHAR16 *)String; + + for (size_t i =3D 0; Actual[i] !=3D 0; i++) { + if (Actual[i] !=3D Expected[i]) { + *result_listener << "character at offset " << i + << " does not match expected. [" << std::hex + << "Actual: 0x" << std::setw (4) << std::setfill ('0') + << Actual[i]; + + if (std::isprint (Actual[i])) { + *result_listener << " ('" << (char)Actual[i] << "')"; + } + + *result_listener << ", Expected: 0x" << std::setw (4) << std::setfil= l ('0') + << Expected[i]; + + if (std::isprint (Expected[i])) { + *result_listener << " ('" << (char)Expected[i] << "')"; + } + + *result_listener << "]"; + + return false; + } + } + + *result_listener << "strings match"; + return true; +} =20 #endif diff --git a/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf b/UnitTes= tFrameworkPkg/Library/CmockaLib/CmockaLib.inf index 052c7f557210..eeee6bc2b3f5 100644 --- a/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf +++ b/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf @@ -16,7 +16,7 @@ [Defines] LIBRARY_CLASS =3D CmockaLib|HOST_APPLICATION =20 # -# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] diff --git a/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.c= b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.c new file mode 100644 index 000000000000..b7bb23f1868b --- /dev/null +++ b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.c @@ -0,0 +1,7 @@ +/** @file + Macro-only FunctionMockLib library instance with no services. + + Copyright (c) 2023, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ diff --git a/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.i= nf b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf new file mode 100644 index 000000000000..4b0662a8b96d --- /dev/null +++ b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf @@ -0,0 +1,31 @@ +## @file +# This module provides FunctionMockLib Library implementation. +# +# Copyright (c) 2023, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D FunctionMockLib + MODULE_UNI_FILE =3D FunctionMockLib.uni + FILE_GUID =3D DF1CAF2F-D584-4EC1-9ABF-07E8B10AD560 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 0.1 + LIBRARY_CLASS =3D FunctionMockLib|HOST_APPLICATION + +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + FunctionMockLib.c + +[LibraryClasses] + GoogleTestLib + SubhookLib + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec diff --git a/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.u= ni b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.uni new file mode 100644 index 000000000000..13e5308ce0e7 --- /dev/null +++ b/UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.uni @@ -0,0 +1,11 @@ +// /** @file +// This module provides FunctionMockLib Library implementation. +// +// Copyright (c) 2023, Intel Corporation. All rights reserved.
+// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + +#string STR_MODULE_ABSTRACT #language en-US "FunctionMockLib L= ibrary implementation" + +#string STR_MODULE_DESCRIPTION #language en-US "This module provi= des FunctionMockLib Library implementation." diff --git a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf b= /UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf index 68db75d7023f..1203a0e6eccd 100644 --- a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf +++ b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf @@ -16,20 +16,22 @@ [Defines] LIBRARY_CLASS =3D GoogleTestLib|HOST_APPLICATION =20 # -# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] googletest/googletest/src/gtest-all.cc + googletest/googlemock/src/gmock-all.cc =20 [Packages] + MdePkg/MdePkg.dec UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec =20 [BuildOptions] MSFT:*_*_*_CC_FLAGS =3D=3D /c /EHsc /Zi MSFT:NOOPT_*_*_CC_FLAGS =3D /Od =20 - GCC:*_*_*_CC_FLAGS =3D=3D -g -c + GCC:*_*_*_CC_FLAGS =3D=3D -g -c -fshort-wchar =20 GCC:NOOPT_*_*_CC_FLAGS =3D -O0 GCC:*_*_IA32_CC_FLAGS =3D -m32 diff --git a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni b= /UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni index 14c862a23744..695588ce3f46 100644 --- a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni +++ b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni @@ -1,10 +1,7 @@ // /** @file // This module provides GoogleTest Library implementation. // -// This module provides GoogleTest Library implementation. -// // Copyright (c) 2022, Intel Corporation. All rights reserved.
-// // SPDX-License-Identifier: BSD-2-Clause-Patent // // **/ diff --git a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc b/U= nitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc index 722509c8f26f..f14961ad86d0 100644 --- a/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc +++ b/UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc @@ -34,6 +34,7 @@ [Components] UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf + UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMockLib.inf UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.inf UnitTestFrameworkPkg/Library/Posix/MemoryAllocationLibPosix/MemoryAlloca= tionLibPosix.inf UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.inf diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml b/UnitTestFr= ameworkPkg/UnitTestFrameworkPkg.ci.yaml index d8f8e024c476..be839d1af0a7 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml @@ -79,9 +79,14 @@ "AuditOnly": False, # Fails test but run in AuditOnly mo= de to collect log "IgnoreFiles": [ # use gitignore syntax to ignore erro= rs in matching files "Library/CmockaLib/cmocka/**/*.*", # not going to spell check= a submodule - "Library/GoogleTestLib/googletest/**/*.*" # not going to spel= l check a submodule + "Library/GoogleTestLib/googletest/**/*.*", # not going to spe= ll check a submodule + "Library/SubhookLib/subhook/**/*.*" # not going to spell chec= k a submodule ], "ExtendWords": [ # words to extend to the dictionary f= or this package + "Pointee", + "gmock", + "GMOCK", + "DSUBHOOK", "testcase", "testsuites", "cmocka", diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec b/UnitTestFramew= orkPkg/UnitTestFrameworkPkg.dec index 30b489915d4a..ef0a148d4876 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec @@ -26,6 +26,7 @@ [Includes.Common.Private] PrivateInclude Library/CmockaLib/cmocka/include/cmockery Library/GoogleTestLib/googletest/googletest + Library/GoogleTestLib/googletest/googlemock =20 [LibraryClasses] ## @libraryclass Allows save and restore unit test internal state @@ -36,6 +37,7 @@ [LibraryClasses] # GoogleTestLib|Include/Library/GoogleTestLib.h SubhookLib|Include/Library/SubhookLib.h + FunctionMockLib|Include/Library/FunctionMockLib.h =20 [LibraryClasses.Common.Private] ## @libraryclass Provides a unit test result report diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc b/UnitTe= stFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc index e77897bd326f..7866c36e6693 100644 --- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc @@ -16,6 +16,7 @@ [LibraryClasses.common.HOST_APPLICATION] CmockaLib|UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf GoogleTestLib|UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.i= nf SubhookLib|UnitTestFrameworkPkg/Library/SubhookLib/SubhookLib.inf + FunctionMockLib|UnitTestFrameworkPkg/Library/FunctionMockLib/FunctionMoc= kLib.inf UnitTestLib|UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLibCmocka.i= nf DebugLib|UnitTestFrameworkPkg/Library/Posix/DebugLibPosix/DebugLibPosix.= inf MemoryAllocationLib|UnitTestFrameworkPkg/Library/Posix/MemoryAllocationL= ibPosix/MemoryAllocationLibPosix.inf --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101874): https://edk2.groups.io/g/devel/message/101874 Mute This Topic: https://groups.io/mt/97848873/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101875+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101875+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769955; cv=none; d=zohomail.com; s=zohoarc; b=PixN/351AknuOPW6uxU6blHg1L62fIdgwOe8xcmYX/g2P7coNelJH6Rv++kApY144tUKJOTBjBuaiGUhooBYNcMIopXEWs2iZhGy3bTUsLW8b09J4xm+DdZno4usA32b6+PiAqSon4Y1dpS/zlrwy/iyD2+C0au5u5gy6DqLQ8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769955; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=lkWwnYDeSJabu/Yw47a927RYrNHoZBCyo+/aT9RCpDM=; b=M8rY0bN8tjTiVuQ50dm8jMqTPNqfPtF1i/lMVXBTZ+ekIX6MSZBFJ6G1MTQSljtsAJpFX179gci/VjJqoqZBfm7zBDw/EKf3os4Vy7BuVV7j79/7uy1U/unJdq3032VZoZ4u4iOxM1L9tEW2ocHFMjI9wPSU41bImL3HDo1qHr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101875+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769955447685.8558211802871; Sat, 25 Mar 2023 11:45:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rTfrYY1788612xko8lMS8H80; Sat, 25 Mar 2023 11:45:55 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.28398.1679769951862510087 for ; Sat, 25 Mar 2023 11:45:52 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655075" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655075" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541403" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541403" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Sean Brogan , Michael Kubacki Subject: [edk2-devel] [Patch 04/12] UnitTestFrameworkPkg/ReadMe.md: Add gmock documentation Date: Sat, 25 Mar 2023 11:45:32 -0700 Message-Id: <20230325184541.596-5-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: L1hVETPnnXtXk3znWA8wtr8Tx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769955; bh=EL7t9nomMkzU61YBlW1WFd0oGiU2vKDVtuFqxpw825w=; h=Cc:Date:From:Reply-To:Subject:To; b=BMihktDVEtGEQnIzqgHlLHwVS437EbiGFDVMDKiQlCI3I4AKa9zhcIOyWVvSIOxK4fA neIK80C325wu0drNAdxODuIKIiKTrndUR7dscLbTTvbY05HqyTxeOswpsMjteve7uXFxQ TfjR54zpfJwRc0oSe7pya99bvaRw+uLCXVk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769955825100012 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Cc: Sean Brogan Cc: Michael Kubacki Cc: Michael D Kinney Signed-off-by: Chris Johnson --- UnitTestFrameworkPkg/ReadMe.md | 999 +++++++++++++++++++++++++++++++-- 1 file changed, 958 insertions(+), 41 deletions(-) diff --git a/UnitTestFrameworkPkg/ReadMe.md b/UnitTestFrameworkPkg/ReadMe.md index 3fa4e1910f71..ddbdd14bee33 100644 --- a/UnitTestFrameworkPkg/ReadMe.md +++ b/UnitTestFrameworkPkg/ReadMe.md @@ -20,12 +20,15 @@ that require mocked interfaces can use the mocking infr= astructure provided by ### GoogleTest =20 The second unit test framework supported by the UnitTestFrameworkPkg is -[GoogleTest](http://google.github.io/googletest/) that can be used to impl= ement host-based unit tests. -Use of GoogleTest for target-based unit tests of EDK II components is not = supported. If a -host-based unit test requires mocked interfaces, then the Framework with c= mocka support should be -used instead. Enabling support for mocked interfaces with GoogleTest is be= ing actively investigated. +[GoogleTest](http://google.github.io/googletest/) and can be used to imple= ment host-based unit tests. [GoogleTest on GitHub](https://github.com/google/googletest) is included i= n the UnitTestFrameworkPkg -as a submodule. +as a submodule. Use of GoogleTest for target-based unit tests of EDK II co= mponents is not supported. +Host-based unit tests that require mocked interfaces can use the mocking i= nfrastructure included with +GoogleTest called [gMock](https://github.com/google/googletest/tree/main/g= ooglemock). Note that the +gMock framework does not directly support mocking of free (C style) functi= ons, so the FunctionMockLib +(containing a set of macros that wrap gMock's MOCK_METHOD macro) was creat= ed within the +UnitTestFrameworkPkg to enable this support. The details and usage of thes= e macros in the +FunctionMockLib are described later. =20 GoogleTest requires less overhead to register test suites and test cases c= ompared to the Framework. There are also a number of tools that layer on top of GoogleTest that impr= ove developer productivity. @@ -33,13 +36,19 @@ One example is the VS Code extension [C++ TestMate](https://marketplace.visualstudio.com/items?itemName=3Dmatep= ek.vscode-catch2-test-adapter) that may be used to implement, run, and debug unit tests implemented using= GoogleTest. =20 -If a component can be tested with host-based unit tests without support fo= r mocked interfaces, -then GoogleTest is recommended. The MdePkg contains a port of the BaseSafe= IntLib unit tests in -the GoogleTest style so the differences between GoogleTest and Framework u= nit tests can be reviewed. -The paths to the BaseSafeIntLib unit tests are: +If a component can be tested with host-based unit tests, then GoogleTest i= s recommended. The MdePkg +contains a port of the BaseSafeIntLib unit tests in the GoogleTest style s= o the differences between +GoogleTest and Framework unit tests can be reviewed. The paths to the Base= SafeIntLib unit tests are: =20 -* MdePkg\Test\UnitTest\Library\BaseSafeIntLib -* MdePkg\Test\GoogleTest\Library\BaseSafeIntLib +* `MdePkg/Test/UnitTest/Library/BaseSafeIntLib` +* `MdePkg/Test/GoogleTest/Library/BaseSafeIntLib` + +Furthermore, the SecurityPkg contains unit tests for the SecureBootVariabl= eLib using mocks in both +the Framework/cmocka and GoogleTest/gMock style so the differences between= cmocka and gMock can be +reviewed. The paths to the SecureBootVariableLib unit tests are: + +* `SecurityPkg/Library/SecureBootVariableLib/UnitTest` +* `SecurityPkg/Library/SecureBootVariableLib/GoogleTest` =20 ## Framework and GoogleTest Feature Comparison =20 @@ -56,7 +65,7 @@ The paths to the BaseSafeIntLib unit tests are: | Typed Tests | NO | YES | | Type-Parameterized Tests | NO | YES | | Timeout Support | NO | YES | -| Mocking Support | Cmocka | NO | +| Mocking Support | Cmocka | gMock | | JUNIT XML Reports | YES | YES | | Execute subset of tests | NO | YES | | VS Code Extensions | NO | YES | @@ -104,7 +113,7 @@ This section is built a lot like a "Getting Started". W= e'll go through some of t when constructing a unit test and some of the decisions that are made by t= he test writer. We'll also describe how to check for expected conditions in test cases and a bit of the loggin= g characteristics. =20 -Most of these examples will refer to the SampleUnitTestUefiShell app found= in this package. +Most of these examples will refer to the `SampleUnitTestUefiShell` app fou= nd in this package. =20 ### Framework Requirements - INF =20 @@ -113,7 +122,7 @@ header for the `UnitTestLib` is located in `MdePkg`, so= you shouldn't need to de packages. As long as your DSC file knows where to find the lib implementat= ion that you want to use, you should be good to go. =20 -See this example in 'SampleUnitTestUefiShell.inf'... +See this example in `SampleUnitTestUefiShell.inf`... =20 ``` [Packages] @@ -127,7 +136,7 @@ See this example in 'SampleUnitTestUefiShell.inf'... PrintLib ``` =20 -Also, if you want you test to automatically be picked up by the Test Runne= r plugin, you will need +Also, if you want your test to automatically be picked up by the Test Runn= er plugin, you will need to make sure that the module `BASE_NAME` contains the word `Test`... =20 ``` @@ -135,6 +144,43 @@ to make sure that the module `BASE_NAME` contains the = word `Test`... BASE_NAME =3D SampleUnitTestUefiShell ``` =20 +### Framework Requirements - DSC + +In our DSC file, we'll need to bring in the INF file that was just created= into the `[Components]` +section so that the unit tests will be built. + +See this example in `UnitTestFrameworkPkg.dsc`... + +``` +[Components] + UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestU= efiShell.inf +``` + +Also, based on the type of tests that are being created, the associated DS= C include file from the +UnitTestFrameworkPkg for Host or Target based tests should also be include= d at the top of the DSC +file. + +``` +!include UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc +``` + +Lastly, in the case that the test build has specific dependent libraries a= ssociated with it, +they should be added in the \ sub-section for the INF fil= e in the +`[Components]` section of the DSC file. + +See this example in `SecurityPkgHostTest.dsc`... + +``` +[Components] + SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariableLib= UnitTest.inf { + + SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/Secu= reBootVariableLib.inf + UefiRuntimeServicesTableLib|SecurityPkg/Library/SecureBootVariableLi= b/UnitTest/MockUefiRuntimeServicesTableLib.inf + PlatformPKProtectionLib|SecurityPkg/Library/SecureBootVariableLib/Un= itTest/MockPlatformPKProtectionLib.inf + UefiLib|SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiL= ib.inf + } +``` + ### Framework Requirements - Code =20 Not to state the obvious, but let's make sure we have the following includ= e before getting too far along... @@ -143,7 +189,7 @@ Not to state the obvious, but let's make sure we have t= he following include befo #include ``` =20 -Now that we've got that squared away, let's look at our 'Main()'' routine = (or DriverEntryPoint() or whatever). +Now that we've got that squared away, let's look at our 'Main()' routine (= or DriverEntryPoint() or whatever). =20 ### Framework Configuration =20 @@ -157,7 +203,7 @@ The long name and version strings are just for user pre= sentation and relatively will be used to name any cache files and/or test results, so should be a n= ame that makes sense in that context. These strings are copied internally to the Framework, so using stack-alloc= ated or literal strings is fine. =20 -In the 'SampleUnitTestUefiShell' app, the module name is used as the short= name, so the initialization looks like this. +In the `SampleUnitTestUefiShell` app, the module name is used as the short= name, so the initialization looks like this. =20 ```c DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION = )); @@ -184,7 +230,7 @@ called once at the start of the suite (before _any_ tes= ts have run) and once at tests have run), respectively. If either or both of these are unneeded, pa= ss `NULL`. The function prototypes are `UNIT_TEST_SUITE_SETUP` and `UNIT_TEST_SUITE_TEARDOWN`. =20 -Looking at 'SampleUnitTestUefiShell' app, you can see that the first test = suite is created as below... +Looking at `SampleUnitTestUefiShell` app, you can see that the first test = suite is created as below... =20 ```c // @@ -218,7 +264,7 @@ of the context pointer is to allow test case reuse with= different input data. (A around a system reboot, but that's beyond the scope of this guide.) The te= st case must know how to interpret the context pointer, so it could be a simple value, or it could be a complex structure= . If unneeded, pass `NULL`. =20 -In 'SampleUnitTestUefiShell' app, the first test case is added using the c= ode below... +In `SampleUnitTestUefiShell` app, the first test case is added using the c= ode below... =20 ```c AddTestCase( SimpleMathTests, "Adding 1 to 1 should produce 2", "Addition"= , OnePlusOneShouldEqualTwo, NULL, NULL, NULL ); @@ -282,6 +328,607 @@ leverage the `cmocka.h` interface and write tests wit= h all the features of the C Documentation for Cmocka can be found here: https://api.cmocka.org/ =20 +## GoogleTest Libraries + +### GoogleTestLib + +GoogleTestLib is the core library used for GoogleTest in EDK II. This libr= ary is mainly a wrapper +around the GoogleTest and gMock header and source files. So all the standa= rd +[GoogleTest](http://google.github.io/googletest/) and +[gMock](https://github.com/google/googletest/tree/main/googlemock) documen= tation for writing tests +and using mocks applies. + +Additionally, to support the use of some primitive types that are not dire= ctly supported by +GoogleTest and gMock (but are needed to allow gMock to be used in EDK II),= some custom gMock +actions and matchers were added to GoogleTestLib. These customizations are= briefly described in +the following tables. + +#### Custom Actions + +| Action Name | Similar gMock Generic Action | Usage | +|:--- |:--- |:--- | +| `SetArgBuffer()` | `SetArgPointee()` | Used to set a buffer output argum= ent (such as UINT8*, VOID*, a structure pointer, etc.) with data in an expe= ct call. Can be used in an `EXPECT_CALL()` | + +#### Custom Matchers + +| Matcher Name | Similar gMock Generic Matcher | Usage | +|:--- |:--- |:--- | +| `BufferEq()` | `Pointee(Eq())` | Used to compare two buffer pointer type= s (such as UINT8*, VOID*, a structure pointer, etc.). Can be used in an `EX= PECT_CALL()`, `EXPECT_THAT()`, or anywhere else a matcher to compare two bu= ffers is needed. | +| `Char16StrEq()` | `Pointee(Eq())` | Used to compare two CHAR16* strings.= Can be used in an `EXPECT_CALL()`, `EXPECT_THAT()`, or anywhere else a mat= cher to compare two CHAR16* strings is needed. | + +### FunctionMockLib + +FunctionMockLib is the library that allows gMock to be used with free (C s= tyle) functions. This +library contains a set of macros that wrap gMock's MOCK_METHOD macro to en= able the standard gMock +capabilities to be used with free functions. The details of how this is im= plemented is outside the +scope of this document, but a brief description of each of the public macr= os in FunctionMockLib is +described below. A full example of how to use these macros to create a moc= k is described in a +later section. + +In total there are six public macros in FunctionMockLib. Four of the macro= s are related to creating +the mock functions, and the other two macros are related to creating an in= terface that is necessary +to contain the mock functions and connect them into the gMock framework. + +The macros used to create the interface are... +1. `MOCK_INTERFACE_DECLARATION(MOCK)` +2. `MOCK_INTERFACE_DEFINITION(MOCK)` + +These macros both take one argument which is the name of the interface for= the mock. The +`MOCK_INTERFACE_DECLARATION` macro is used to declare the interface in the= `.h` file and the +`MOCK_INTERFACE_DEFINITION` macro is used to define the interface in the `= .cpp` file. For +example, to create a mock for the `UefiLib`, a `MockUefiLib.h` file would = be created and the +below code would be added to it. + +```cpp +struct MockUefiLib { + MOCK_INTERFACE_DECLARATION(MockUefiLib); +}; +``` + +Additionally, the below code would be written into a `MockUefiLib.cpp` fil= e. + +```cpp +MOCK_INTERFACE_DEFINITION(MockUefiLib); +``` + +The macros used to create the mock functions are... +1. `MOCK_FUNCTION_DECLARATION(RET_TYPE, FUNC, ARGS)` +2. `MOCK_FUNCTION_DEFINITION(MOCK, FUNC, NUM_ARGS, CALL_TYPE)` +3. `MOCK_FUNCTION_INTERNAL_DECLARATION(RET_TYPE, FUNC, ARGS)` +4. `MOCK_FUNCTION_INTERNAL_DEFINITION(MOCK, FUNC, NUM_ARGS, CALL_TYPE)` + +You will notice that there are two sets of macros: one to mock external fu= nctions and +another to mock internal functions. Each set of macros has the exact same = arguments, but +they are used for slightly different use cases. The details of these diffe= rent use cases +is described in detail in a later section. For now, we will focus on the u= sage of the macro +arguments since that is common between them. + +The `MOCK_FUNCTION_DECLARATION` macro is used to declare the mock function= in the `.h` file, +and it takes three arguments: return type, function name, and argument lis= t. The +`MOCK_FUNCTION_DEFINITION` macro is used to define the mock function in th= e `.cpp` file, +and it takes four arguments: name of the interface for the mock, function = name, number of +arguments the function takes, and calling convention type of the function.= For example, to +continue with the `UefiLib` mock example above, the `GetVariable2` and `Ge= tEfiGlobalVariable2` +functions are declared in `UefiLib.h` as shown below. + +```cpp +EFI_STATUS +EFIAPI +GetVariable2 ( + IN CONST CHAR16 *Name, + IN CONST EFI_GUID *Guid, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL + ); + +EFI_STATUS +EFIAPI +GetEfiGlobalVariable2 ( + IN CONST CHAR16 *Name, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL + ); +``` + +To declare mocks for these functions within the previously created `MockUe= fiLib` interface, +the below code would be added to the `MockUefiLib.h` file. Note that the p= reviously added +interface declaration is also included in the code below for context. + +```cpp +struct MockUefiLib { + MOCK_INTERFACE_DECLARATION(MockUefiLib); + + MOCK_FUNCTION_DECLARATION(EFI_STATUS, GetVariable2, + (IN CONST CHAR16 *Name, + IN CONST EFI_GUID *Guid, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL)); + + MOCK_FUNCTION_DECLARATION(EFI_STATUS, GetEfiGlobalVariable2, + (IN CONST CHAR16 *Name, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL)); +}; +``` + +Additionally, the below code would be added into the `MockUefiLib.cpp` fil= e to provide +the definitions for these mock functions. Again, the previously added inte= rface +definition is also included in the code below for context. + +```cpp +MOCK_INTERFACE_DEFINITION(MockUefiLib); + +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetVariable2, 4, EFIAPI); +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetEfiGlobalVariable2, 3, EFIAPI); +``` + +That concludes the basic overview on how to use the macros, but a more det= ailed +description on how to name the mocks, where to put the files, how to build= the +mocks, and how to use the mocks is described in detail later. + +### SubhookLib + +SubhookLib is the library used by FunctionMockLib to implement the macros = to +mock internal functions: `MOCK_FUNCTION_INTERNAL_DECLARATION` and +`MOCK_FUNCTION_INTERNAL_DEFINITION`. These macros require the additional +functionality provided by SubhookLib because they create mock functions +for functions that are already defined and compiled within the module being +tested. More detail on this is provided in a later section, but for now it= is +sufficient to know that the SubhookLib allows a second definition of the +function to be compiled into the test application and then hooked to durin= g a +test. + +This library is mainly a wrapper around the +[subhook](https://github.com/Zeex/subhook) header and source files. It is +important to note that the use of the mock function macros and the creation +of mock functions requires no knowledge about the SubhookLib. The SubhookL= ib +library is entirely hidden and encapsulated within FunctionMockLib, and it +is only mentioned here to provide a complete explanation on all the librar= ies +used in the implementation. + +## FunctionMockLib Mocks + +This section describes the details on how to use the mock function macros = in +FunctionMockLib to create mock functions, name them, organize their files, +and build them so that they can be used within GoogleTest tests. The usage +of the mock functions is detailed in a later section while this section +simply details how to create them, build them, and where to put them. + +### FunctionMockLib Mocks - External vs. Internal + +The first question to ask when creating a mock function is if the function= being +mocked is external or internal to the module being tested. This is very im= portant +because the macros in FunctionMockLib used to create the mock function are= named +differently for these two use cases. Fortunately, the arguments to these m= acros +and the usage of the mock functions within the tests are exactly the same. +However, because of the different underlying implementations, two differen= t sets +of macros are used. + +A more detailed description of when to use the external vs. internal mock = function +macros is in the following sections, but the quick summary is as follows. + +* External mock function macros are used to mock functions that are outsid= e the +module being tested and use link-time replacement. +* Internal mock function macros are used to mock functions that are inside= the +module being tested and use run-time replacement. + +The below table shows which macros to use in these two use cases. However,= note that +for the creation of the interface, the same macros are used in both cases. + +| Mock Function Use Case | Mock Interface Macros | Mock Function Macros | +|:--- |:--- |:--- | +| External mock functions | `MOCK_INTERFACE_DECLARATION`
`MOCK_INTERFA= CE_DEFINITION` | `MOCK_FUNCTION_DECLARATION`
`MOCK_FUNCTION_DEFINITION`= | +| Internal mock functions | `MOCK_INTERFACE_DECLARATION`
`MOCK_INTERFA= CE_DEFINITION` | `MOCK_FUNCTION_INTERNAL_DECLARATION`
`MOCK_FUNCTION_IN= TERNAL_DEFINITION` | + +#### FunctionMockLib Mocks - External mock function + +The external mock function macros are used to create mock function definit= ions +for a library, global service, or protocol that is defined outside of the = module +being tested. These mock function definitions are linked into the test app= lication +instead of linking in the design function definitions. In other words, the +external mock function macros use link-time replacement of the design func= tions. + +The `.h/.cpp` files for these mock functions are created within the package +directory where the library, global table, or protocol that is being mocke= d is +declared. These files are compiled into their own separate library (using +an INF file) that can be shared and linked into many test applications, bu= t more +on that later. + +#### FunctionMockLib Mocks - Internal mock function + +The internal mock function macros are used to create mock function definit= ions +for functions that are defined within the module being tested. These mock +function definitions are compiled into the test application along with the= design +function definitions. This is possible because the mock functions are give= n a +slightly different name during compilation. Then during test execution, the +design function is hooked and replaced with the mock function. In other wo= rds, +the internal mock function macros use run-time replacement of the design +functions. + +The `.h/.cpp` files for these mock functions are created within the Google= Test +directory containing the specific tests that are using them. These files a= re +compiled directly in the GoogleTest INF file that builds the test applicat= ion, +and they are not shared outside of that GoogleTest directory, but more on = that +later. + +### FunctionMockLib Mocks - Declaration + +The declaration of mock functions using the FunctionMockLib macros are done +in header files. The name of the header file is determined by the interface +(such as a library or a protocol) that is being created for the mock funct= ions. +The rules for naming the file are shown in the table below. + +| Interface Type | Header File Name | +| :--- | :--- | +| Library | Mock\Lib.h | +| Global Table (e.g. gRT, gBS, etc.) | Mock\Lib.h= | +| Protocol | Mock\Protocol.h | + +The below table shows examples for file names with each of the above cases. + +| Interface Type | Interface Name | Header File Name | +| :--- | :--- | :--- | +| Library | UefiLib | MockUefiLib.h | +| Global Table (e.g. gRT, gBS, etc.) | UefiRuntimeServicesTableLib | MockU= efiRuntimeServicesTableLib.h | +| Protocol | EFI_USB_IO_PROTOCOL | MockEfiUsbIoProtocol.h | + +Once the header file name is known, the file needs to be created in the pr= oper +location. For internal mock functions, the location is simply the same +GoogleTest directory that contains the INF file that builds the test appli= cation. +For external mock functions, the location is within the `Test` directory u= nder the +package where the library, global table, or protocol that is being mocked = is +declared. The exact location depends on the interface type and is shown in= the +below table. + +| Interface Type | Header File Location | +| :--- | :--- | +| Library | \/Test/Mock/Include/Library/GoogleTest | +| Global Table (e.g. gRT, gBS, etc.) | \/Test/Mock/Include/L= ibrary/GoogleTest | +| Protocol | \/Test/Mock/Include/Protocol/GoogleTest | + +The below table shows examples for file locations with each of the above c= ases. + +| Interface Type | Interface Name | Header File Location | +| :--- | :--- | :--- | +| Library | UefiLib | MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefi= Lib.h | +| Global Table (e.g. gRT, gBS, etc.) | UefiRuntimeServicesTableLib | MdePk= g/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTableLib.h | +| Protocol | EFI_USB_IO_PROTOCOL | MdePkg/Test/Mock/Include/Protocol/Googl= eTest/MockEfiUsbIoProtocol.h | + +Now that the file location is known, the contents can be added to it. At t= he top +of the file, the `GoogleTestLib.h` and `FunctionMockLib.h` files are alway= s added. +Following these includes other EDK II related include files are added and = must be +wrapped in `extern "C" {}` because they are C include files. Failure to do= this +will cause link errors to occur. Note that a `#include` of the interface b= eing +mocked must also be added. This causes the declarations of the functions b= eing +mocked to be included in the compilation and allows the compilation to ver= ify +that the function signatures of the mock and design functions are identica= l. + +After the standard `#ifndef` for a header file is added, a `struct` is dec= lared +using the same name as the header file (which was determined using the rul= es +above). Within this structure declaration a `MOCK_INTERFACE_DECLARATION` is +added along with a `MOCK_FUNCTION_DECLARATION` (or a +`MOCK_FUNCTION_INTERNAL_DECLARATION` if this interface is for internal mock +functions) for each function in the interface. To build on the examples ab= ove, +the complete `MockUefiLib.h` file would be as shown below. Note that for b= revity +only the `GetVariable2` and `GetEfiGlobalVariable2` declarations are inclu= ded in +the example. + +```cpp +#include +#include +extern "C" { + #include + #include +} + +#ifndef MOCK_UEFI_LIB_H +#define MOCK_UEFI_LIB_H + +struct MockUefiLib { + MOCK_INTERFACE_DECLARATION(MockUefiLib); + + MOCK_FUNCTION_DECLARATION(EFI_STATUS, GetVariable2, + (IN CONST CHAR16 *Name, + IN CONST EFI_GUID *Guid, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL)); + + MOCK_FUNCTION_DECLARATION(EFI_STATUS, GetEfiGlobalVariable2, + (IN CONST CHAR16 *Name, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL)); +}; + +#endif +``` + +In the case of libraries, the function names in the mock declarations +align exactly with the function names in the design. However, in the +case of global tables and protocols, to eliminate possible function +name collisions, the names are adjusted slightly in the mock +declarations as shown in the below table. + +| Mock Function Use Case | Design Function Name | Mock Function Name | +| :--- | :--- | :--- | +| Library | GetVariable2 | GetVariable2 | +| Global Table (e.g. gRT, gBS, etc.) | gRT->GetVariable | gRT_GetVariable | +| Protocol | UsbIoProtocol->UsbPortReset | UsbIoProtocol_UsbPortReset | + +Lastly, when creating mock functions, there are two limitations to be +aware of in gMock that extend into FunctionMockLib. + +1. gMock does not support mocking functions that have more than 15 argumen= ts. +2. gMock does not support mocking variadic functions. + +With those limitations in mind, that completes the mock function +declarations, and now the mock function definitions for those declarations +can be created. + +### FunctionMockLib Mocks - Definition + +The definition of mock functions using the FunctionMockLib macros are done +in source files. The name of the source file is determined by the interface +(such as a library or a protocol) that is being created for the mock funct= ions. +The rules for naming the file align with the naming of the file for declar= ations +and are shown in the table below. + +| Interface Type | Source File Name | +| :--- | :--- | +| Library | Mock\Lib.cpp | +| Global Table (e.g. gRT, gBS, etc.) | Mock\Lib.c= pp | +| Protocol | Mock\Protocol.cpp | + +The below table shows examples for file names with each of the above cases. + +| Interface Type | Interface Name | Source File Name | +| :--- | :--- | :--- | +| Library | UefiLib | MockUefiLib.cpp | +| Global Table (e.g. gRT, gBS, etc.) | UefiRuntimeServicesTableLib | MockU= efiRuntimeServicesTableLib.cpp | +| Protocol | EFI_USB_IO_PROTOCOL | MockEfiUsbIoProtocol.cpp | + +Once the source file name is known, the file needs to be created in the pr= oper +location. The location of the source file is aligned with the location for= the +header file. For internal mock functions, the location is simply the same +GoogleTest directory that contains the INF file that builds the test appli= cation. +For external mock functions, the location is within the `Test` directory u= nder the +package where the library, global table, or protocol that is being mocked = is +declared. The exact location depends on the interface type and is shown in= the +below table. + +| Interface Type | Source File Location | +| :--- | :--- | +| Library | \/Test/Mock/Library/GoogleTest/Mock\Lib | +| Global Table (e.g. gRT, gBS, etc.) | \/Test/Mock/Library/G= oogleTest/Mock\Lib | +| Protocol | \/Test/Mock/Library/GoogleTest/Mock\Protocol | + +The below table shows examples for file locations with each of the above c= ases. + +| Interface Type | Interface Name | Source File Location | +| :--- | :--- | :--- | +| Library | UefiLib | MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/Mock= UefiLib.cpp | +| Global Table (e.g. gRT, gBS, etc.) | UefiRuntimeServicesTableLib | MdePk= g/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/MockUefiRunt= imeServicesTableLib.cpp | +| Protocol | EFI_USB_IO_PROTOCOL | MdePkg/Test/Mock/Library/GoogleTest/Moc= kEfiUsbIoProtocol/MockEfiUsbIoProtocol.cpp | + +Now that the file location is known, the contents can be added to it. At t= he top +of the file, the header file containing the mock function declarations is = always +added. After this `#include`, the interface definition is created using +`MOCK_INTERFACE_DEFINITION` with the interface name that was used in the m= ock +function declaration header file. A `MOCK_FUNCTION_DEFINITION` is then add= ed (or +a `MOCK_FUNCTION_INTERNAL_DEFINITION` if this interface is for internal mo= ck +functions) for each function that was declared in the interface. To build = on the +prior declaration examples, the complete `MockUefiLib.cpp` file would be a= s shown +below. Note that for brevity only the `GetVariable2` and `GetEfiGlobalVari= able2` +definitions are included in the example. + +```cpp +#include + +MOCK_INTERFACE_DEFINITION(MockUefiLib); + +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetVariable2, 4, EFIAPI); +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetEfiGlobalVariable2, 3, EFIAPI); +``` + +When creating the defintions, there are a few things to keep in mind. + +First, when using `MOCK_FUNCTION_DEFINITION`, some functions being mocked = do +not specify a calling convention. In this case, it is fine to leave the la= st +argument of `MOCK_FUNCTION_DEFINITION` empty. For example, if `GetVariable= 2` +did not specify the `EFIAPI` calling convention in its declaration, then t= he +below code would be used for the mock function definition. + +```cpp +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetVariable2, 4, ); +``` + +Second, the function name used in `MOCK_FUNCTION_DEFINITION` must align wi= th +the function name used in the associated `MOCK_FUNCTION_DECLARATION` in the +header file. + +Last, if the interface is mocking a global table or protocol, then the str= ucture +of function pointers for that interface must also be defined within the so= urce +file as a `static` structure with the mock function definitions being assi= gned +to the associated entries in the structure. The address of this `static` +structure is then assigned to the global table or protocol pointer. Note t= hat +this pointer must be wrapped in `extern "C" {}` because it needs C style +linkage. Failure to do this will cause link errors to occur. For example, = when +creating the definition of the mock for the global runtime services table,= the +complete `MockUefiRuntimeServicesTableLib.cpp` file would be as shown belo= w. +Note that for brevity only the `GetVariable` and `SetVariable` definitions= are +included in the example. + +```cpp +#include + +MOCK_INTERFACE_DEFINITION(MockUefiRuntimeServicesTableLib); + +MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_GetVariable,= 5, EFIAPI); +MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_SetVariable,= 5, EFIAPI); + +static EFI_RUNTIME_SERVICES localRt =3D { + {0}, // EFI_TABLE_HEADER + + NULL, // EFI_GET_TIME + NULL, // EFI_SET_TIME + NULL, // EFI_GET_WAKEUP_TIME + NULL, // EFI_SET_WAKEUP_TIME + + NULL, // EFI_SET_VIRTUAL_ADDRESS_MAP + NULL, // EFI_CONVERT_POINTER + + gRT_GetVariable, // EFI_GET_VARIABLE + NULL, // EFI_GET_NEXT_VARIABLE_NAME + gRT_SetVariable, // EFI_SET_VARIABLE + + NULL, // EFI_GET_NEXT_HIGH_MONO_COUNT + NULL, // EFI_RESET_SYSTEM + + NULL, // EFI_UPDATE_CAPSULE + NULL, // EFI_QUERY_CAPSULE_CAPABILITIES + + NULL, // EFI_QUERY_VARIABLE_INFO +}; + +extern "C" { + EFI_RUNTIME_SERVICES* gRT =3D &localRt; +} +``` + +That completes the mock function definitions. So now these mock function +definitions can be compiled. + +### FunctionMockLib Mocks - Build + +The building of mock functions using FunctionMockLib is done slightly +differently for external and internal function mocks. External mock +functions are built using their own separate INF file and internal mock +functions are built as source files directly referenced in the GoogleTest +INF file that builds the test application. + +#### FunctionMockLib Mocks - Build External Mock Functions + +The building of external mock functions is done using their own separate I= NF +file which is placed in the same location as the associated source file +containing the mock function definitions. The name of the INF file is exac= tly +the same as the mock function definitions file, but uses the `.inf` extens= ion +rather than `.cpp`. + +Within the `.inf` file the `BASE_NAME` should be set to the same name as t= he +file (minus the extension), the `MODULE_TYPE` should be set to `BASE`, and= the +`LIBRARY_CLASS` should be the same as the `BASE_NAME` but without the `Moc= k` +prefix. Additionally, the `LIBRARY_CLASS` should be specified to only supp= ort +the `HOST_APPLICATION` module type since these mock function definitions w= ill +only be compiled into host application test applications. + +The `[Sources]` section will contain the single mock function definition +source file, the `[Packages]` section will contain all the necessary DEC +files to compile the mock functions (which at a minimum will include the +`UnitTestFrameworkPkg.dec` file, the `[LibraryClasses]` section will conta= in +the `GoogleTestLib`, and the `[BuildOptions]` will need to append the `/EH= sc` +compilation flag to all MSFT builds to enable proper use of the C++ except= ion +handler. Below is the complete `MockUefiLib.inf` as an example. + +``` +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MockUefiLib + FILE_GUID =3D 47211F7A-6D90-4DFB-BDF9-610B69197C2E + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D UefiLib|HOST_APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MockUefiLib.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS =3D /EHsc + +``` + +To ensure that this specific set of mock functions are always buildable ev= en +if no test uses it yet, this created INF file needs to be added into the +`[Components]` section of the associated `Test` DSC file for the package in +which this INF file resides. For example, the above `MockUefiLib.inf` would +need to be added to the `MdePkg/Test/MdePkgHostTest.dsc` file as shown bel= ow. + +``` +[Components] + MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf +``` + +This created INF file will also be referenced within the necessary `Test` = DSC +files in order to include the mock function definitions in the test +applications which use this set of mock functions, but more on that later. + +One small additional requirement is that if this INF file is added into a +package that does not yet have any other external mock functions in it, th= en +that package's DEC file will need to have the mock include directory (more +specifically the `Test/Mock/Include` directory) added to its `[Includes]` +section so that test files who want to use the mock functions will be able= to +locate the mock function header file. For example, if `MockUefiLib.inf` we= re +the first mock added to the `MdePkg`, then the below snippet would need to= be +added to the `MdePkg.dec` file. + +``` +[Includes] + Test/Mock/Include +``` + +#### FunctionMockLib Mocks - Build Internal Mock Functions + +The building of internal mock functions is done using the GoogleTest INF f= ile +that already needs to exist to build the test application. This is easy to +manage since the source and header files for the internal mock functions a= re +also located in the same GoogleTest directory as the GoogleTest INF file t= hat +will reference them. + +The only additions that are required to the GoogleTest INF file are that t= he +mock function definitions file be added to the `[Sources]` section, the +`UnitTestFrameworkPkg.dec` file be added to the `[Packages]` section, and = the +`GoogleTestLib` and `SubhookLib` be added to the `[LibraryClasses]` sectio= n. +Below is a minimal contrived example for a `MyModuleGoogleTest.inf` that u= ses a +`MockMyModuleInternalFunctions.cpp` source file for its internal mock func= tions. + +``` +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D MyModuleGoogleTest + FILE_GUID =3D 814B09B9-2D51-4786-8A77-2E10CD1C55F3 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D HOST_APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MyModuleGoogleTest.cpp + MockMyModuleInternalFunctions.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + SubhookLib +``` + ## GoogleTest Samples =20 There is a sample unit test provided as both an example of how to write a = unit test and leverage @@ -291,22 +938,31 @@ directory. The sample is provided for the HOST_APPLICATION build type, which can be r= un on a host system without needing a target. =20 +There is also a sample unit test provided as both an example of how to wri= te a unit test with +mock functions and leverage some of the gMock features. This sample can be= found in the +`SecurityPkg/Library/SecureBootVariableLib/GoogleTest` directory. + +It too is provided for the HOST_APPLICATION build type, which can be run o= n a host system without +needing a target. + ## GoogleTest Usage =20 This section is built a lot like a "Getting Started". We'll go through som= e of the components that are needed when constructing a unit test and some of the decisions that are made by t= he test writer. We'll also describe how to check for expected conditions in test cases and a bit of the loggin= g characteristics. =20 -Most of these examples will refer to the SampleGoogleTestHost app found in= this package. +Most of these examples will refer to the `SampleGoogleTestHost` app found = in this package, but +the examples related to mock functions will refer to the `SecureBootVariab= leLibGoogleTest` app +found in the `SecurityPkg`. =20 ### GoogleTest Requirements - INF =20 -In our INF file, we'll need to bring in the `GoogleTest` library. Convenie= ntly, the interface -header for the `GoogleTest` is in `UnitTestFrameworkPkg`, so you shouldn't= need to depend on any other +In our INF file, we'll need to bring in the `GoogleTestLib` library. Conve= niently, the interface +header for the `GoogleTestLib` is in `UnitTestFrameworkPkg`, so you should= n't need to depend on any other packages. As long as your DSC file knows where to find the lib implementat= ion that you want to use, you should be good to go. =20 -See this example in 'SampleGoogleTestHost.inf'... +See this example in `SampleGoogleTestHost.inf`... =20 ``` [Packages] @@ -319,7 +975,7 @@ See this example in 'SampleGoogleTestHost.inf'... DebugLib ``` =20 -Also, if you want you test to automatically be picked up by the Test Runne= r plugin, you will need +Also, if you want your test to automatically be picked up by the Test Runn= er plugin, you will need to make sure that the module `BASE_NAME` contains the word `Test`... =20 ``` @@ -327,12 +983,54 @@ to make sure that the module `BASE_NAME` contains the= word `Test`... BASE_NAME =3D SampleGoogleTestHost ``` =20 +### GoogleTest Requirements - DSC + +In our DSC file, we'll need to bring in the INF file that was just created= into the `[Components]` +section so that the unit tests will be built. + +See this example in `UnitTestFrameworkPkgHostTest.dsc`... + +``` +[Components] + UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogl= eTestHost.inf +``` + +Also, based on the type of tests that are being created, the associated DS= C include file from the +UnitTestFrameworkPkg for Host or Target based tests should also be include= d at the top of the DSC +file. + +``` +!include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc +``` + +Lastly, in the case that the test build has specific dependent libraries a= ssociated with it, +they should be added in the \ sub-section for the INF fil= e in the +`[Components]` section of the DSC file. Note that it is within this sub-se= ction where you can +control whether the design or mock version of a component is linked into t= he test exectuable. + +See this example in `SecurityPkgHostTest.dsc` where the `SecureBootVariabl= eLib` design is +being tested using mock versions of `UefiRuntimeServicesTableLib`, `Platfo= rmPKProtectionLib`, +and `UefiLib`... + +``` +[Components] + SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableL= ibGoogleTest.inf { + + SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/Secu= reBootVariableLib.inf + UefiRuntimeServicesTableLib|MdePkg/Test/Mock/Library/GoogleTest/Mock= UefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf + PlatformPKProtectionLib|SecurityPkg/Test/Mock/Library/GoogleTest/Moc= kPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf + UefiLib|MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.= inf + } +``` + ### GoogleTest Requirements - Code =20 -Not to state the obvious, but let's make sure we have the following includ= e before getting too far along... +GoogleTest applications are implemented in C++, so make sure that your tes= t file has +a `.cpp` extension. With that behind us, not to state the obvious, but let= 's make sure +we have the following includes before getting too far along in the file... =20 -``` -#include +```cpp +#include extern "C" { #include #include @@ -340,33 +1038,75 @@ extern "C" { } ``` =20 -GoogleTest applications are implemented in C++. The first include brings i= n the -GoogleTest definitions. Other EDK II related include files must be wrapped= in -`extern "C" {}` because they are C include files. Link failures will occur= if -this is not done. +The first include brings in the GoogleTest definitions. Other EDK II relat= ed include +files must be wrapped in `extern "C" {}` because they are C include files.= Link +failures will occur if this is not done. =20 -Now that we've got that squared away, let's look at our 'Main()'' routine = (or DriverEntryPoint() or whatever). +Also, when using GoogleTest it is helpful to add a `using` declaration for= its +`testing` namespace. This `using` statement greatly reduces the amount of = code you +need to write in the tests when referencing the utilities within the `test= ing` +namespace. For example, instead of writing `::testing::Return` or `::testi= ng::Test`, +you can just write `Return` or `Test` respectively, and these types of ref= erences +occur numerous times within the tests. + +Lastly, in the case that tests within a GoogleTest application require the= usage of +mock functions, it is also necessary to include the header files for those= interfaces +as well. As an example, the `SecureBootVariableLibGoogleTest` uses the moc= k versions +of `UefiLib` and `UefiRuntimeServicesTableLib`. So its test file contains = the below +includes. Note that the `using` declaration mentioned above is also shown = in the code +below for completeness of the example. + +```cpp +#include +#include +#include + +extern "C" { + #include + ... +} + +using namespace testing; +``` + +Now that we've got that squared away, let's look at our 'Main()' routine (= or DriverEntryPoint() or whatever). =20 ### GoogleTest Configuration =20 Unlike the Framework, GoogleTest does not require test suites or test case= s to be registered. Instead, the test cases declare the test suite name and test case name as part of their implementation. The only requirement for Google= Test -is to have a `main()` function that initialize the GoogleTest infrastructu= re and -call the service `RUN_ALL_TESTS()` to run all the unit tests. +is to have a `main()` function that initializes the GoogleTest infrastruct= ure +and calls the service `RUN_ALL_TESTS()` to run all the unit tests. =20 -```c +```cpp int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } ``` =20 +However, while GoogleTest does not require test suites or test cases to be +registered, there is still one rule within EDK II that currently needs to = be +followed. This rule is that all tests for a given GoogleTest application m= ust +be contained within the same source file that contains the `main()` functi= on +shown above. These tests can be written directly in the file or a `#includ= e` +can be used to add them into the file indirectly. + +The reason for this is due to EDK II taking the host application INF file = and +first compiling all of its source files into a static library. This static +library is then linked into the final host application. The problem with t= his +method is that only the tests in the object file containing the `main()` +function are linked into the final host application. This is because the o= ther +tests are contained in their own object files within the static library and +they have no symbols in them that the final host application depends on, so +those object files are not linked into the final host application. + ### GoogleTest - A Simple Test Case =20 -We'll look at the below test case from 'SampleGoogleTestHost'... +Below is a sample test case from `SampleGoogleTestHost`. =20 -```c +```cpp TEST(SimpleMathTests, OnePlusOneShouldEqualTwo) { UINTN A; UINTN B; @@ -393,9 +1133,175 @@ detailed logs. When in doubt, there are always `ASSE= RT_TRUE` and `ASSERT_FALSE`. test criterium will immediately return from the test case with a failed st= atus and log an error string. _Note_ that this early return can have implications for memory leakage. =20 -There is no return status from a GooglTest unit test. If no assertions are +For most `ASSERT` macros in GoogleTest there is also an equivalent `EXPECT= ` macro. Both macro versions +will ultimately cause the `TEST` to fail if the check fails. However, the = difference between the two +macro versions is that when the check fails, the `ASSERT` version immediat= ely returns from the `TEST` +while the `EXPECT` version continues running the `TEST`. + +There is no return status from a GooglTest unit test. If no assertions (or= expectations) are triggered then the unit test has a passing status. =20 +### GoogleTest - A gMock Test Case + +Below is a sample test case from `SecureBootVariableLibGoogleTest`. Althou= gh +actually, the test case is not written exactly like this in the test file,= but +more on that in a bit. + +```cpp +TEST(SetSecureBootModeTest, SetVarError) { + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SecureBootMode; + EFI_STATUS Status; + + // Any random magic number can be used for these tests + SecureBootMode =3D 0xAB; + + EXPECT_CALL(RtServicesMock, gRT_SetVariable) + .WillOnce(Return(EFI_INVALID_PARAMETER)); + + Status =3D SetSecureBootMode(SecureBootMode); + EXPECT_EQ(Status, EFI_INVALID_PARAMETER); +} +``` + +Keep in mind that this test is written to verify that `SetSecureBootMode()= ` will +return `EFI_INVALID_PARAMETER` when the call to `gRT->SetVariable()` withi= n the +implementation of `SetSecureBootMode()` returns `EFI_INVALID_PARAMETER`. W= ith that +in mind, let's discuss how a mock function is used to accomplish this in t= he test. + +In this test case, the `MockUefiRuntimeServicesTableLib` interface is inst= antiated as +`RtServicesMock` which enables its associated mock functions. These interf= ace +instantiations that contain the mock functions are very important for mock= function +based unit tests because without these instantiations, the mock functions = within that +interface will not exist and can not be used. + +The next line of interest is the `EXPECT_CALL`, which is a standard part o= f the gMock +framework. This macro is telling the test that a call is expected to occur= to a +specific function on a specific interface. The first argument is the name = of the +interface object that was instantiated in this test, and the second argume= nt is the +name of the mock function within that interface that is expected to be cal= led. The +`WillOnce(Return(EFI_INVALID_PARAMETER))` associated with this `EXPECT_CAL= L` states +that the `gRT_SetVariable()` function (remember from earlier in this docum= entation +that this refers to the `gRT->SetVariable()` function) will be called once= during +this test, and when it does get called, we want it to return `EFI_INVALID_= PARAMETER`. + +Once this `EXPECT_CALL` has been setup, the call to `SetSecureBootMode()` = occurs in +the test, and its return value is saved in `Status` so that it can be test= ed. Based +on the `EXPECT_CALL` that was setup earlier, when `SetSecureBootMode()` in= ternally +calls `gRT->SetVariable()`, it returns `EFI_INVALID_PARAMETER`. This value= should +then be returned by `SetSecureBootMode()`, and the +`EXPECT_EQ(Status, EFI_INVALID_PARAMETER)` verifies this is the case. + +There is much more that can be done with `EXPECT_CALL` and mock functions,= but we +will leave those details to be explained in the gMock documentation. + +Now it was mentioned earlier that this test case is not written exactly li= ke this +in the test file, and the next section describes how this test is slightly +refactored to reduce the total amount of code in the entire test suite. + +### GoogleTest - A gMock Test Case (refactored) + +The sample test case from `SecureBootVariableLibGoogleTest` in the prior s= ection is +actually written as shown below. + +```cpp +class SetSecureBootModeTest : public Test { + protected: + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SecureBootMode; + EFI_STATUS Status; + + void SetUp() override { + // Any random magic number can be used for these tests + SecureBootMode =3D 0xAB; + } +}; + +TEST_F(SetSecureBootModeTest, SetVarError) { + EXPECT_CALL(RtServicesMock, gRT_SetVariable) + .WillOnce(Return(EFI_INVALID_PARAMETER)); + + Status =3D SetSecureBootMode(SecureBootMode); + EXPECT_EQ(Status, EFI_INVALID_PARAMETER); +} +``` + +This code may at first seem more complicated, but you will notice that the= code +with in it is still the same. There is still a `MockUefiRuntimeServicesTab= leLib` +instantiation, there is still a `SecureBootMode` and `Status` variable def= ined, +there is still an `EXPECT_CALL`, and etc. However, the benefit of construc= ting +the test this way is that the new `TEST_F()` requires less code than the p= rior +`TEST()`. + +This is made possible by the usage of what GoogleTest calls a _test fixtur= e_. +This concept of a test fixture allows multiple tests to use (or more speci= fically +inherit from a base class) a common set of variables and initial condition= s. +Notice that using `TEST_F()` requires the first argument to be a name that= aligns +with a test fixture (in this case `SetSecureBootModeTest`), and the second +argument is the name of the test (just like in the `TEST()` macro). + +All `TEST_F()` tests that use a specific test fixture can be thought of as= having +all of that test fixture's variables automatically defined in the test as = well as +having that text fixture's `SetUp()` function called before entering the t= est. + +This means that another `TEST_F()` can be written without needing to worry= about +defining a bunch of variables or instantiating a bunch of interfaces for m= ock +functions. For example, the below test (also in `SecureBootVariableLibGoog= leTest`) +uses the same test fixture and makes use of its `RtServicesMock`, `Status`= , and +`SecureBootMode` variables. + +```cpp +TEST_F(SetSecureBootModeTest, PropogateModeToSetVar) { + EXPECT_CALL(RtServicesMock, + gRT_SetVariable( + Char16StrEq(EFI_CUSTOM_MODE_NAME), + BufferEq(&gEfiCustomModeEnableGuid, sizeof(EFI_GUID)), + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(SecureBootMode), + BufferEq(&SecureBootMode, sizeof(SecureBootMode)))) + .WillOnce(Return(EFI_SUCCESS)); + + Status =3D SetSecureBootMode(SecureBootMode); + EXPECT_EQ(Status, EFI_SUCCESS); +} +``` + +The biggest benefit is that the `TEST_F()` code can now focus on what is b= eing +tested and not worry about any repetitive setup. There is more that can be= done +with test fixtures, but we will leave those details to be explained in the +gMock documentation. + +Now, as for what is in the above test, it is slightly more complicated tha= n the +first test. So let's explain this added complexity and what it is actually +testing. In this test, there is still an `EXPECT_CALL` for the +`gRT_SetVariable()` function. However, in this test we are stating that we +expect the input arguments passed to `gRT_SetVariable()` be specific value= s. +The order they are provided in the `EXPECT_CALL` align with the order of t= he +arguments in the `gRT_SetVariable()` function. In this case the order of t= he +`gRT_SetVariable()` arguments is as shown below. + +```cpp +IN CHAR16 *VariableName, +IN EFI_GUID *VendorGuid, +IN UINT32 Attributes, +IN UINTN DataSize, +IN VOID *Data +``` + +So in the `EXPECT_CALL` we are stating that the call to `gRT_SetVariable()` +will be made with the below input argument values. + +1. `VariableName` is equal to the `EFI_CUSTOM_MODE_NAME` string +2. `VendorGuid` is equal to the `gEfiCustomModeEnableGuid` GUID (which has= a byte length of `sizeof(EFI_GUID)`) +3. `Attributes` is equal to `EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOT= SERVICE_ACCESS` +4. `DataSize` is equal to `sizeof(SecureBootMode)` +5. `Data` is equal to `SecureBootMode` (which has a byte length of `sizeof= (SecureBootMode)`) + +If any one of these input arguments does not match in the actual call to +`gRT_SetVariable()` in the design, then the test will fail. There is much = more +that can be done with `EXPECT_CALL` and mock functions, but again we will +leave those details to be explained in the gMock documentation. + ### GoogleTest - More Complex Cases =20 To write more advanced tests, take a look at the @@ -654,8 +1560,8 @@ We will continue trying to make these as similar as po= ssible. =20 Code/Test | Location --------- | -------- -Host-Based Unit Tests for a Library/Protocol/PPI/GUID Interface | If wha= t's being tested is an interface (e.g. a library with a public header file,= like DebugLib), the test should be scoped to the parent package.
Examp= le: `MdePkg/Test/UnitTest/[Library/Protocol/Ppi/Guid]/`

A real-wor= ld example of this is the BaseSafeIntLib test in MdePkg.
`MdePkg/Test/U= nitTest/Library/BaseSafeIntLib/TestBaseSafeIntLibHost.inf` -Host-Based Unit Tests for a Library/Driver (PEI/DXE/SMM) implementation = | If what's being tested is a specific implementation (e.g. BaseDebugLibSer= ialPort for DebugLib), the test should be scoped to the implementation dire= ctory itself, in a UnitTest subdirectory.

Module Example: `MdeModu= lePkg/Universal/EsrtFmpDxe/UnitTest/`
Library Example: `MdePkg/Library/= BaseMemoryLib/UnitTest/` +Host-Based Unit Tests for a Library/Protocol/PPI/GUID Interface | If wha= t's being tested is an interface (e.g. a library with a public header file,= like DebugLib) and the test is agnostic to a specific implementation, then= the test should be scoped to the parent package.
Example: `MdePkg/Test= /UnitTest/[Library/Protocol/Ppi/Guid]/`

A real-world example of th= is is the BaseSafeIntLib test in MdePkg.
`MdePkg/Test/UnitTest/Library/= BaseSafeIntLib/TestBaseSafeIntLibHost.inf` +Host-Based Unit Tests for a Library/Driver (PEI/DXE/SMM) implementation = | If what's being tested is a specific implementation (e.g. BaseDebugLibSer= ialPort for DebugLib), then the test should be scoped to the implementation= directory itself, in a UnitTest (or GoogleTest) subdirectory.

Mod= ule Example: `MdeModulePkg/Universal/EsrtFmpDxe/UnitTest/`
Library Exam= ple: `MdePkg/Library/BaseMemoryLib/UnitTest/`
Library Example (GoogleTe= st): `SecurityPkg/Library/SecureBootVariableLib/GoogleTest` Host-Based Tests for a Functionality or Feature | If you're writing a fu= nctional test that operates at the module level (i.e. if it's more than a s= ingle file or library), the test should be located in the package-level Tes= ts directory under the HostFuncTest subdirectory.
For example, if you w= ere writing a test for the entire FMP Device Framework, you might put your = test in:
`FmpDevicePkg/Test/HostFuncTest/FmpDeviceFramework`

I= f the feature spans multiple packages, it's location should be determined b= y the package owners related to the feature. Non-Host-Based (PEI/DXE/SMM/Shell) Tests for a Functionality or Feature = | Similar to Host-Based, if the feature is in one package, should be locate= d in the `*Pkg/Test/[Shell/Dxe/Smm/Pei]Test` directory.

If the fea= ture spans multiple packages, it's location should be determined by the pac= kage owners related to the feature.

USAGE EXAMPLES
PEI Example= : MP_SERVICE_PPI. Or check MTRR configuration in a notification function. SMM Example: a test in a protocol callback function. (It is different w= ith the solution that SmmAgent+ShellApp)
DXE Example: a test in a UEFI = event call back to check SPI/SMRAM status.
Shell Example: the SMM han= dler audit test has a shell-based app that interacts with an SMM handler to= get information. The SMM paging audit test gathers information about both = DXE and SMM. And the SMM paging functional test actually forces errors into= SMM via a DXE driver. =20 @@ -713,8 +1619,19 @@ Non-Host-Based (PEI/DXE/SMM/Shell) Tests for a Functi= onality or Feature | Simi GeneralPurposeLibTest.c GeneralPurposeLibHostUnitTest.inf =20 + Mock/ + Include/ + GoogleTest/ + Library/ + MockGeneralPurposeLib.h + + Library/ + GoogleTest/ + MockGeneralPurposeLib/ + MockGeneralPurposeLib.cpp + MockGeneralPurposeLib.inf + Pkg.dsc # Standard Modules and any Target-Based Test A= pps (including in Test/) - ``` =20 ### Future Locations in Consideration --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101875): https://edk2.groups.io/g/devel/message/101875 Mute This Topic: https://groups.io/mt/97848874/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101876+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101876+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769956; cv=none; d=zohomail.com; s=zohoarc; b=S8XWnSqquXPIAIDEUM3AyDhyxRXWWGkG4gCko48N67JSFtq0Tm1+xYjv6QXoRkNwipMK88Chly4YixxXnK+8Rzau+skuvl/6/Du81gDVS4aLB4QSHl01L5ejLV188ZqwnPgyLO46xxl7WcZMeTkWvl2KaISe+0hp5/eLALiL+2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769956; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=LAugG4peKmiYUJBy8vn9raSf+bHyIP+PD0wMzg13b4U=; b=a/26YFoRTs9W1CW9ZIPjklBiebU8JdNvmgU1nUQBHLTAb2nQqjrTyo5KKZIRHVCMauZqh1KiQhMKh6Nk6ye5IBnLL2JZRJj9h7M7Sc9d7ejZDfRaylykHelob4k5gm+9pBW1tmy8+alu/2+kmSFBPsflDHuk+w/xoTEiOPaY9Js= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101876+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769956483285.07927692693545; Sat, 25 Mar 2023 11:45:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xr9aYY1788612xU73Pd1MV8E; Sat, 25 Mar 2023 11:45:56 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28284.1679769950911591616 for ; Sat, 25 Mar 2023 11:45:52 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655077" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655077" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541406" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541406" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:51 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [Patch 05/12] MdePkg: Add gmock examples Date: Sat, 25 Mar 2023 11:45:33 -0700 Message-Id: <20230325184541.596-6-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: 7dIbOZ3kX0r9LpceCUZuiJfLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769956; bh=rVVO5qi/tem3ntVmdGK7B/YAcVzZAipp6cdmk8oN5Pw=; h=Cc:Date:From:Reply-To:Subject:To; b=K8v3NAcAVVfg8NC6Od/r6oL9t70AAz8QImCGVZFqB/XkO2xvxPFDoosV6kVzBJuwEtI 4cR4Luk0htRRZ5RIvzngJyXNjEHDcPYb0ucUS3+l5UZgPDPNwKg9AF/ePnJiV13d3Is9Z jpL0eYj8GmlsQDMu3rJRHFnS8ddZ30YeTlI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769957820100023 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Chris Johnson --- MdePkg/MdePkg.dec | 1 + MdePkg/Test/MdePkgHostTest.dsc | 2 + .../Include/GoogleTest/Library/MockUefiLib.h | 39 +++++++++++++++++ .../Library/MockUefiRuntimeServicesTableLib.h | 42 +++++++++++++++++++ .../GoogleTest/MockUefiLib/MockUefiLib.cpp | 12 ++++++ .../GoogleTest/MockUefiLib/MockUefiLib.inf | 33 +++++++++++++++ .../MockUefiRuntimeServicesTableLib.cpp | 40 ++++++++++++++++++ .../MockUefiRuntimeServicesTableLib.inf | 33 +++++++++++++++ 8 files changed, 202 insertions(+) create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiLib= .h create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRun= timeServicesTableLib.h create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUef= iLib.cpp create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUef= iLib.inf create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServ= icesTableLib/MockUefiRuntimeServicesTableLib.cpp create mode 100644 MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServ= icesTableLib/MockUefiRuntimeServicesTableLib.inf diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec index 2d643bede1d7..2a1d7694aa18 100644 --- a/MdePkg/MdePkg.dec +++ b/MdePkg/MdePkg.dec @@ -26,6 +26,7 @@ [Defines] [Includes] Include Test/UnitTest/Include + Test/Mock/Include =20 [Includes.IA32] Include/Ia32 diff --git a/MdePkg/Test/MdePkgHostTest.dsc b/MdePkg/Test/MdePkgHostTest.dsc index b8b186dd8b17..35e3ef6d9729 100644 --- a/MdePkg/Test/MdePkgHostTest.dsc +++ b/MdePkg/Test/MdePkgHostTest.dsc @@ -34,3 +34,5 @@ [Components] # Build HOST_APPLICATION Libraries # MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf + MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf + MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/Mock= UefiRuntimeServicesTableLib.inf diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiLib.h b/Md= ePkg/Test/Mock/Include/GoogleTest/Library/MockUefiLib.h new file mode 100644 index 000000000000..dec2c93e1b34 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiLib.h @@ -0,0 +1,39 @@ +/** @file + Google Test mocks for UefiLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_UEFI_LIB_H_ +#define MOCK_UEFI_LIB_H_ + +#include +#include +extern "C" { +#include +#include +} + +struct MockUefiLib { + MOCK_INTERFACE_DECLARATION (MockUefiLib); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + GetVariable2, + (IN CONST CHAR16 *Name, + IN CONST EFI_GUID *Guid, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL) + ); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + GetEfiGlobalVariable2, + (IN CONST CHAR16 *Name, + OUT VOID **Value, + OUT UINTN *Size OPTIONAL) + ); +}; + +#endif diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeSer= vicesTableLib.h b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRunti= meServicesTableLib.h new file mode 100644 index 000000000000..afdfc6b85597 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiRuntimeServicesTa= bleLib.h @@ -0,0 +1,42 @@ +/** @file + Google Test mocks for UefiRuntimeServicesTableLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_UEFI_RUNTIME_SERVICES_TABLE_LIB_H_ +#define MOCK_UEFI_RUNTIME_SERVICES_TABLE_LIB_H_ + +#include +#include +extern "C" { +#include +#include +} + +struct MockUefiRuntimeServicesTableLib { + MOCK_INTERFACE_DECLARATION (MockUefiRuntimeServicesTableLib); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + gRT_GetVariable, + (IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + OUT UINT32 *Attributes OPTIONAL, + IN OUT UINTN *DataSize, + OUT VOID *Data) + ); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + gRT_SetVariable, + (IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid, + IN UINT32 Attributes, + IN UINTN DataSize, + IN VOID *Data) + ); +}; + +#endif diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.cp= p b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.cpp new file mode 100644 index 000000000000..5339d040c999 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.cpp @@ -0,0 +1,12 @@ +/** @file + Google Test mocks for UefiLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include + +MOCK_INTERFACE_DEFINITION(MockUefiLib); + +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetVariable2, 4, EFIAPI); +MOCK_FUNCTION_DEFINITION(MockUefiLib, GetEfiGlobalVariable2, 3, EFIAPI); diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.in= f b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf new file mode 100644 index 000000000000..1a7461e44449 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.inf @@ -0,0 +1,33 @@ +## @file +# Google Test mocks for UefiLib +# +# Copyright (c) 2022, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MockUefiLib + FILE_GUID =3D 47211F7A-6D90-4DFB-BDF9-610B69197C2E + MODULE_TYPE =3D HOST_APPLICATION + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D UefiLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MockUefiLib.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS =3D /EHsc diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTab= leLib/MockUefiRuntimeServicesTableLib.cpp b/MdePkg/Test/Mock/Library/Google= Test/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.cpp new file mode 100644 index 000000000000..ecd1ba82366c --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/M= ockUefiRuntimeServicesTableLib.cpp @@ -0,0 +1,40 @@ +/** @file + Google Test mocks for UefiRuntimeServicesTableLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include + +MOCK_INTERFACE_DEFINITION(MockUefiRuntimeServicesTableLib); + +MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_GetVariable,= 5, EFIAPI); +MOCK_FUNCTION_DEFINITION(MockUefiRuntimeServicesTableLib, gRT_SetVariable,= 5, EFIAPI); + +static EFI_RUNTIME_SERVICES localRt =3D { + {0}, // EFI_TABLE_HEADER + + NULL, // EFI_GET_TIME + NULL, // EFI_SET_TIME + NULL, // EFI_GET_WAKEUP_TIME + NULL, // EFI_SET_WAKEUP_TIME + + NULL, // EFI_SET_VIRTUAL_ADDRESS_MAP + NULL, // EFI_CONVERT_POINTER + + gRT_GetVariable, // EFI_GET_VARIABLE + NULL, // EFI_GET_NEXT_VARIABLE_NAME + gRT_SetVariable, // EFI_SET_VARIABLE + + NULL, // EFI_GET_NEXT_HIGH_MONO_COUNT + NULL, // EFI_RESET_SYSTEM + + NULL, // EFI_UPDATE_CAPSULE + NULL, // EFI_QUERY_CAPSULE_CAPABILITIES + + NULL, // EFI_QUERY_VARIABLE_INFO +}; + +extern "C" { + EFI_RUNTIME_SERVICES* gRT =3D &localRt; +} diff --git a/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTab= leLib/MockUefiRuntimeServicesTableLib.inf b/MdePkg/Test/Mock/Library/Google= Test/MockUefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf new file mode 100644 index 000000000000..7ba74d93bfc2 --- /dev/null +++ b/MdePkg/Test/Mock/Library/GoogleTest/MockUefiRuntimeServicesTableLib/M= ockUefiRuntimeServicesTableLib.inf @@ -0,0 +1,33 @@ +## @file +# Google Test mocks for UefiRuntimeServicesTableLib +# +# Copyright (c) 2022, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MockUefiRuntimeServicesTableLib + FILE_GUID =3D 0A0E13C2-4176-4293-89C7-C2497AA31B92 + MODULE_TYPE =3D HOST_APPLICATION + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D UefiRuntimeServicesTableLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MockUefiRuntimeServicesTableLib.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS =3D /EHsc --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101876): https://edk2.groups.io/g/devel/message/101876 Mute This Topic: https://groups.io/mt/97848876/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101877+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101877+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769957; cv=none; d=zohomail.com; s=zohoarc; b=CBDzJ1NbOl4cUt9JKUDH+zTcFZuIGQybSblaDis3CNC+BuSOeuNDRe/fwiQv2BIHdhpMZ70qZwkTWSf6z4yeYZ43XOX0T/un+zjY2XwiZUViXJTeCNSYmlxUTasfL08SiB5J0JXZjHdiyeLi0vaDunVzA1fRdVfAqXzgEwlsR6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=OlkgC2w220h5GJrl6xoKr04sPGVarT+5+aEi2J6+v0I=; b=O9x1P3IxzpL4uK15EUs10GGREJeZkxzbMxGkcW9DsswCqqAxRrfhp/tkvI4ejy4vx/jttS4TUf5qOBLYtXI3uPZOlGeFc/5CEGo0FKBuonB8Th+FHPQ14XrENzw7sHI7GwRiqEpmbk2/D9cxEza6qtZ2CDmIcBAny6/xVX4dcXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101877+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769957085582.1943306299416; Sat, 25 Mar 2023 11:45:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id v4hcYY1788612xwb9rT8rNHx; Sat, 25 Mar 2023 11:45:56 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28286.1679769952773908107 for ; Sat, 25 Mar 2023 11:45:52 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655082" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655082" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541409" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541409" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Jian J Wang , Liming Gao Subject: [edk2-devel] [Patch 06/12] MdeModulePkg/Library/UefiSortLib: Add GoogleTestLib example Date: Sat, 25 Mar 2023 11:45:34 -0700 Message-Id: <20230325184541.596-7-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: yAc7Rdnvpj7ZMOrQhtVP15rlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769956; bh=gCrxf5/eWFSmkNgUCOR/6SRe6h4OitTrxZABtGwwZpQ=; h=Cc:Date:From:Reply-To:Subject:To; b=fPxWIb2npxdvvFQ6R4306Av6hZHzn0q3EmpDjaQkAEYYT2zaMc6j41e8PnASTbIfw7E 9am+tLlz9ScvGJZkErObJ+wJ/uIzWQ3K2O0zN/BrKzTXGlh3zokwnG/cyuq5ZhPDS+RIm 6ActG1SarN7hN/jWrmePrazqi2d/LxoH+Tc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769957796100019 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Chris Johnson --- .../MockUefiRuntimeServicesTableLib.inf | 4 +- .../GoogleTest/UefiSortLibGoogleTest.cpp | 57 +++++++++++++++++++ .../GoogleTest/UefiSortLibGoogleTest.inf | 31 ++++++++++ MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 6 ++ 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLib= GoogleTest.cpp create mode 100644 MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLib= GoogleTest.inf diff --git a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntim= eServicesTableLib.inf b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/Moc= kUefiRuntimeServicesTableLib.inf index e716b855a31a..15eb646d7c38 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntimeServic= esTableLib.inf +++ b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntimeServic= esTableLib.inf @@ -10,9 +10,9 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D MockUefiRuntimeServicesTableLib FILE_GUID =3D 4EA215EE-85C1-4A0A-847F-D2A8DE20805F - MODULE_TYPE =3D UEFI_DRIVER + MODULE_TYPE =3D HOST_APPLICATION VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D UefiRuntimeServicesTableLib|HOST_APPL= ICATION + LIBRARY_CLASS =3D UefiRuntimeServicesTableLib =20 # # VALID_ARCHITECTURES =3D IA32 X64 EBC diff --git a/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleT= est.cpp b/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleTest= .cpp new file mode 100644 index 000000000000..7ac1231c6f87 --- /dev/null +++ b/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleTest.cpp @@ -0,0 +1,57 @@ +/** @file + Unit tests for the implementation of UefiSortLib. + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include + +extern "C" { + #include + #include +} + +using namespace testing; + +INTN +EFIAPI +CompareUint32 ( + IN CONST VOID *Left, + IN CONST VOID *Right + ) +{ + if (*(UINT32*)Right > *(UINT32*)Left) { + return 1; + } else if (*(UINT32*)Right < *(UINT32*)Left) { + return -1; + } + + return 0; +} + +TEST(PerformQuickSortTest, SortUint32AscendingArray_Size9) { + CONST UINT32 ArraySize =3D 9; + UINT32 BuffActual[ArraySize]; + UINT32 BuffExpected[ArraySize]; + + for (UINT32 Index =3D 0; Index < ArraySize; Index++) { + BuffActual[Index] =3D Index + 1; + BuffExpected[Index] =3D ArraySize - Index; + } + + PerformQuickSort (BuffActual, (UINTN)ArraySize, sizeof(UINT32), (SORT_CO= MPARE)CompareUint32); + EXPECT_THAT(BuffActual, ElementsAreArray(BuffExpected, ArraySize)); +} + +TEST(StringCompareTest, CompareSameBuffer) { + INTN RetVal; + CONST CHAR16 *Buffer =3D (CHAR16*)L"abcdefg"; + + RetVal =3D StringCompare (&Buffer, &Buffer); + EXPECT_EQ(RetVal, 0); +} + +int main(int argc, char* argv[]) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleT= est.inf b/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleTest= .inf new file mode 100644 index 000000000000..ac5ffb3bc29d --- /dev/null +++ b/MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleTest.inf @@ -0,0 +1,31 @@ +## @file +# Unit test suite for the UefiSortLib using Google Test +# +# Copyright (c) 2022, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D UefiSortLibGoogleTest + FILE_GUID =3D 78FB0BEE-D0EA-4E1A-BD38-67458C8ECDEF + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D HOST_APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + UefiSortLibGoogleTest.cpp + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + UefiSortLib diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test= /MdeModulePkgHostTest.dsc index c9ec835df65d..a2bbbe8adf44 100644 --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc @@ -47,3 +47,9 @@ [Components] UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf } + + MdeModulePkg/Library/UefiSortLib/GoogleTest/UefiSortLibGoogleTest.inf { + + UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + } --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101877): https://edk2.groups.io/g/devel/message/101877 Mute This Topic: https://groups.io/mt/97848878/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101878+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101878+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769957; cv=none; d=zohomail.com; s=zohoarc; b=PYJluycCClYfSt2lBAok3lnBtlJyOkjgG7LjMioHAOjd3rReKt2FwiNUY281cGKF6JK2rjV+/2UUI7Jxzym99SudOw2TpEbJtKUJZqAZnIQnGBkEsrcnTvMYboC/NYKX45XDAUvqIxEUNrUrbeVV1SEXJCctNkif/nurJTPsU1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=BjXCfZ9yNx2VvFHsIHFHlMvLwCieyQintn97j1PygwE=; b=eM63YibGvqepw08NhMIl/Q9On/gVqjt2N8lOw0kkLzZNmrVaB9HLBpDP06lQ8DqMQl57lc9ow0fuRAHonGR0ZgrEDH+pevMfdF+WsfXEZ1U3XmGsQEKuetvUv97Wh4og59LlJOWe9tm/sNL0TnOOwtXlR83XM+XezNStNV1ey+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101878+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769957709488.6266222753171; Sat, 25 Mar 2023 11:45:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ofesYY1788612xQtvM7lztne; Sat, 25 Mar 2023 11:45:57 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28286.1679769952773908107 for ; Sat, 25 Mar 2023 11:45:53 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655084" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655084" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541413" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541413" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Chris Johnson , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [Patch 07/12] SecurityPkg: Add gmock example Date: Sat, 25 Mar 2023 11:45:35 -0700 Message-Id: <20230325184541.596-8-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: Ii6fLDx0ZhOCvcZx7e1DAComx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769957; bh=/tPYg+byVNgRq+ioOyU56EG8SahiTdivoS59vtdPS5g=; h=Cc:Date:From:Reply-To:Subject:To; b=QV6tSLNyZFbUwJTkVaST6qP3lelNleaWM1mhWkkHSG2bM0phz60eBwNxAZwfYNpRXL/ iQcX5999v5VYbOMW21K3qwvuB+SLqCUuJxXzCRqrcc4gBtINTC7cWquowwUjWQ2VUi8P+ hzIZqZcnJYLIc5lCA7DlbkRCoBbZA28wdkI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769959844100039 Content-Type: text/plain; charset="utf-8" From: Chris Johnson REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4389 Cc: Jiewen Yao Cc: Jian J Wang Signed-off-by: Chris Johnson Acked-by: Jiewen Yao --- .../SecureBootVariableLibGoogleTest.cpp | 156 ++++++++++++++++++ .../SecureBootVariableLibGoogleTest.inf | 32 ++++ .../UnitTest/MockPlatformPKProtectionLib.inf | 4 +- .../UnitTest/MockUefiLib.inf | 4 +- .../MockUefiRuntimeServicesTableLib.inf | 4 +- .../UnitTest/SecureBootVariableLibUnitTest.c | 2 +- SecurityPkg/SecurityPkg.dec | 1 + .../Library/MockPlatformPKProtectionLib.h | 28 ++++ .../MockPlatformPKProtectionLib.cpp | 11 ++ .../MockPlatformPKProtectionLib.inf | 34 ++++ SecurityPkg/Test/SecurityPkgHostTest.dsc | 8 + 11 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 SecurityPkg/Library/SecureBootVariableLib/GoogleTest/Se= cureBootVariableLibGoogleTest.cpp create mode 100644 SecurityPkg/Library/SecureBootVariableLib/GoogleTest/Se= cureBootVariableLibGoogleTest.inf create mode 100644 SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPl= atformPKProtectionLib.h create mode 100644 SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPK= ProtectionLib/MockPlatformPKProtectionLib.cpp create mode 100644 SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPK= ProtectionLib/MockPlatformPKProtectionLib.inf diff --git a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBoo= tVariableLibGoogleTest.cpp b/SecurityPkg/Library/SecureBootVariableLib/Goog= leTest/SecureBootVariableLibGoogleTest.cpp new file mode 100644 index 000000000000..f9a0ab35e4da --- /dev/null +++ b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariab= leLibGoogleTest.cpp @@ -0,0 +1,156 @@ +/** @file + Unit tests for the implementation of SecureBootVariableLib. + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include +#include +#include + +extern "C" { + #include + #include + #include + #include + #include + #include +} + +using namespace testing; + +//////////////////////////////////////////////////////////////////////////= //// +class SetSecureBootModeTest : public Test { + protected: + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SecureBootMode; + EFI_STATUS Status; + + void SetUp() override { + // Any random magic number can be used for these tests + SecureBootMode =3D 0xAB; + } +}; + +TEST_F(SetSecureBootModeTest, SetVarError) { + EXPECT_CALL(RtServicesMock, gRT_SetVariable) + .WillOnce(Return(EFI_INVALID_PARAMETER)); + + Status =3D SetSecureBootMode(SecureBootMode); + EXPECT_EQ(Status, EFI_INVALID_PARAMETER); +} + +TEST_F(SetSecureBootModeTest, PropogateModeToSetVar) { + EXPECT_CALL(RtServicesMock, + gRT_SetVariable( + Char16StrEq(EFI_CUSTOM_MODE_NAME), + BufferEq(&gEfiCustomModeEnableGuid, sizeof(EFI_GUID)), + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof(SecureBootMode), + BufferEq(&SecureBootMode, sizeof(SecureBootMode)))) + .WillOnce(Return(EFI_SUCCESS)); + + Status =3D SetSecureBootMode(SecureBootMode); + EXPECT_EQ(Status, EFI_SUCCESS); +} + +//////////////////////////////////////////////////////////////////////////= //// +class GetSetupModeTest : public Test { + protected: + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SetupMode; + EFI_STATUS Status; + UINT8 ExpSetupMode; + + void SetUp() override { + // Any random magic number can be used for these tests + ExpSetupMode =3D 0xAB; + } +}; + +TEST_F(GetSetupModeTest, GetVarError) { + EXPECT_CALL(RtServicesMock, gRT_GetVariable) + .WillOnce(Return(EFI_INVALID_PARAMETER)); + + Status =3D GetSetupMode (&SetupMode); + EXPECT_EQ(Status, EFI_INVALID_PARAMETER); +} + +TEST_F(GetSetupModeTest, FetchModeFromGetVar) { + EXPECT_CALL(RtServicesMock, + gRT_GetVariable( + Char16StrEq(EFI_SETUP_MODE_NAME), + BufferEq(&gEfiGlobalVariableGuid, sizeof(EFI_GUID)), + _, + Pointee(Eq(sizeof(SetupMode))), + NotNull())) + .WillOnce(DoAll( + SetArgPointee<3>(sizeof(ExpSetupMode)), + SetArgBuffer<4>(&ExpSetupMode, sizeof(ExpSetupMode)), + Return(EFI_SUCCESS))); + + Status =3D GetSetupMode (&SetupMode); + ASSERT_EQ(Status, EFI_SUCCESS); + EXPECT_EQ(SetupMode, ExpSetupMode); +} + +//////////////////////////////////////////////////////////////////////////= //// +class IsSecureBootEnabledTest : public Test { + protected: + MockUefiLib UefiLibMock; + BOOLEAN Enabled; +}; + +TEST_F(IsSecureBootEnabledTest, GetVarError) { + EXPECT_CALL(UefiLibMock, GetEfiGlobalVariable2) + .WillOnce(Return(EFI_ABORTED)); + + Enabled =3D IsSecureBootEnabled (); + EXPECT_EQ(Enabled, FALSE); +} + +//////////////////////////////////////////////////////////////////////////= //// +class IsSecureBootEnabledAllocTest : public IsSecureBootEnabledTest { + protected: + UINT8 *BootEnabledBuffer; + + void SetUp() override { + BootEnabledBuffer =3D (UINT8*) AllocatePool(1); + ASSERT_NE(BootEnabledBuffer, nullptr); + } +}; + +TEST_F(IsSecureBootEnabledAllocTest, IsEnabled) { + *BootEnabledBuffer =3D SECURE_BOOT_MODE_ENABLE; + EXPECT_CALL(UefiLibMock, + GetEfiGlobalVariable2( + Char16StrEq(EFI_SECURE_BOOT_MODE_NAME), + NotNull(), + _)) + .WillOnce(DoAll( + SetArgBuffer<1>(&BootEnabledBuffer, sizeof(VOID*)), + Return(EFI_SUCCESS))); + + Enabled =3D IsSecureBootEnabled (); + EXPECT_EQ(Enabled, TRUE); +} + +TEST_F(IsSecureBootEnabledAllocTest, IsDisabled) { + *BootEnabledBuffer =3D SECURE_BOOT_MODE_DISABLE; + EXPECT_CALL(UefiLibMock, + GetEfiGlobalVariable2( + Char16StrEq(EFI_SECURE_BOOT_MODE_NAME), + NotNull(), + _)) + .WillOnce(DoAll( + SetArgBuffer<1>(&BootEnabledBuffer, sizeof(VOID*)), + Return(EFI_SUCCESS))); + + Enabled =3D IsSecureBootEnabled (); + EXPECT_EQ(Enabled, FALSE); +} + +int main(int argc, char* argv[]) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBoo= tVariableLibGoogleTest.inf b/SecurityPkg/Library/SecureBootVariableLib/Goog= leTest/SecureBootVariableLibGoogleTest.inf new file mode 100644 index 000000000000..5503dcfa32d1 --- /dev/null +++ b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariab= leLibGoogleTest.inf @@ -0,0 +1,32 @@ +## @file +# Unit test suite for the SecureBootVariableLib using Google Test +# +# Copyright (c) 2022, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010017 + BASE_NAME =3D SecureBootVariableLibGoogleTest + FILE_GUID =3D C88372AB-726B-4344-A250-6C7F826C874E + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D HOST_APPLICATION + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + SecureBootVariableLibGoogleTest.cpp + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + SecurityPkg/SecurityPkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + SecureBootVariableLib diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatfor= mPKProtectionLib.inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/M= ockPlatformPKProtectionLib.inf index 1e19033c5a91..c927ef709958 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProt= ectionLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProt= ectionLib.inf @@ -10,9 +10,9 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D MockPlatformPKProtectionLib FILE_GUID =3D 5FCD74D3-3965-4D56-AB83-000B9B4806A0 - MODULE_TYPE =3D DXE_DRIVER + MODULE_TYPE =3D HOST_APPLICATION VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D PlatformPKProtectionLib|HOST_APPLICAT= ION + LIBRARY_CLASS =3D PlatformPKProtectionLib =20 # # The following information is for reference only and not required by the = build tools. diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib= .inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf index a84242ac7205..fecf46841131 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf @@ -18,9 +18,9 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D MockUefiLib FILE_GUID =3D E3B7AEF9-4E55-49AF-B035-ED776C928EC6 - MODULE_TYPE =3D UEFI_DRIVER + MODULE_TYPE =3D HOST_APPLICATION VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D UefiLib|HOST_APPLICATION + LIBRARY_CLASS =3D UefiLib =20 # # VALID_ARCHITECTURES =3D IA32 X64 EBC diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRun= timeServicesTableLib.inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTe= st/MockUefiRuntimeServicesTableLib.inf index f832a93e2254..6fe04189606e 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeSer= vicesTableLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeSer= vicesTableLib.inf @@ -10,9 +10,9 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D MockUefiRuntimeServicesTableLib FILE_GUID =3D 84CE0021-ABEE-403C-9A1B-763CCF2D40F1 - MODULE_TYPE =3D UEFI_DRIVER + MODULE_TYPE =3D HOST_APPLICATION VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D UefiRuntimeServicesTableLib|HOST_APPL= ICATION + LIBRARY_CLASS =3D UefiRuntimeServicesTableLib =20 # # VALID_ARCHITECTURES =3D IA32 X64 EBC diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootV= ariableLibUnitTest.c b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/S= ecureBootVariableLibUnitTest.c index a23135dfb016..3a92d5d83457 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariable= LibUnitTest.c +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariable= LibUnitTest.c @@ -163,7 +163,7 @@ MockGetVariable ( return EFI_BUFFER_TOO_SMALL; } else { assert_non_null (Data); - CopyMem (Data, (VOID *)mock (), TargetSize); + CopyMem (Data, (VOID *)(UINTN)mock (), TargetSize); } =20 return EFI_SUCCESS; diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index 0382090f4e75..0a8042d63fe1 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -21,6 +21,7 @@ [Defines] =20 [Includes] Include + Test/Mock/Include =20 [LibraryClasses] ## @libraryclass Provides hash interfaces from different implementatio= ns. diff --git a/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformP= KProtectionLib.h b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPla= tformPKProtectionLib.h new file mode 100644 index 000000000000..8024f4be2975 --- /dev/null +++ b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtec= tionLib.h @@ -0,0 +1,28 @@ +/** @file + Google Test mocks for PlatformPKProtectionLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_PLATFORM_PK_PROTECTION_LIB_H_ +#define MOCK_PLATFORM_PK_PROTECTION_LIB_H_ + +#include +#include +extern "C" { +#include +#include +} + +struct MockPlatformPKProtectionLib { + MOCK_INTERFACE_DECLARATION (MockPlatformPKProtectionLib); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + DisablePKProtection, + () + ); +}; + +#endif diff --git a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtect= ionLib/MockPlatformPKProtectionLib.cpp b/SecurityPkg/Test/Mock/Library/Goog= leTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.cpp new file mode 100644 index 000000000000..5ea030f6dfcf --- /dev/null +++ b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/= MockPlatformPKProtectionLib.cpp @@ -0,0 +1,11 @@ +/** @file + Google Test mocks for PlatformPKProtectionLib + + Copyright (c) 2022, Intel Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ +#include + +MOCK_INTERFACE_DEFINITION(MockPlatformPKProtectionLib); + +MOCK_FUNCTION_DEFINITION(MockPlatformPKProtectionLib, DisablePKProtection,= 0, EFIAPI); diff --git a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtect= ionLib/MockPlatformPKProtectionLib.inf b/SecurityPkg/Test/Mock/Library/Goog= leTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf new file mode 100644 index 000000000000..3ed638eaf74c --- /dev/null +++ b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/= MockPlatformPKProtectionLib.inf @@ -0,0 +1,34 @@ +## @file +# Google Test mocks for PlatformPKProtectionLib +# +# Copyright (c) 2022, Intel Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MockPlatformPKProtectionLib + FILE_GUID =3D C1383D85-E0ED-44E0-A0A6-125F1D78B6E9 + MODULE_TYPE =3D HOST_APPLICATION + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformPKProtectionLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + MockPlatformPKProtectionLib.cpp + +[Packages] + MdePkg/MdePkg.dec + SecurityPkg/SecurityPkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + +[BuildOptions] + MSFT:*_*_*_CC_FLAGS =3D /EHsc diff --git a/SecurityPkg/Test/SecurityPkgHostTest.dsc b/SecurityPkg/Test/Se= curityPkgHostTest.dsc index c4df01fe1b73..ad5b4fc350ea 100644 --- a/SecurityPkg/Test/SecurityPkgHostTest.dsc +++ b/SecurityPkg/Test/SecurityPkgHostTest.dsc @@ -25,6 +25,7 @@ [Components] SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeServic= esTableLib.inf SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProtect= ionLib.inf SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf + SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/Moc= kPlatformPKProtectionLib.inf =20 # # Build SecurityPkg HOST_APPLICATION Tests @@ -36,3 +37,10 @@ [Components] PlatformPKProtectionLib|SecurityPkg/Library/SecureBootVariableLib/Un= itTest/MockPlatformPKProtectionLib.inf UefiLib|SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiL= ib.inf } + SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableL= ibGoogleTest.inf { + + SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/Secu= reBootVariableLib.inf + UefiRuntimeServicesTableLib|MdePkg/Test/Mock/Library/GoogleTest/Mock= UefiRuntimeServicesTableLib/MockUefiRuntimeServicesTableLib.inf + PlatformPKProtectionLib|SecurityPkg/Test/Mock/Library/GoogleTest/Moc= kPlatformPKProtectionLib/MockPlatformPKProtectionLib.inf + UefiLib|MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.= inf + } --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101878): https://edk2.groups.io/g/devel/message/101878 Mute This Topic: https://groups.io/mt/97848879/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101879+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101879+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769957; cv=none; d=zohomail.com; s=zohoarc; b=hY3AqED60sQqCD8JuWIvREt+ww0oN3kaBX+OwfDEuKDOxhq5ma1JMgdoxLDIs+AlgTGjrcWWPCoW+2IEtKqnFgQgU5TV3SrMFabdgy6eTlGaWPzBlWEznd9f4j9ps6u6ZrFRaFJMQ+kooUhXVYfsAx2qDwZckjCKshOee5kqNKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jvlEAu4UH8QwPCQKzI/j0dTctdk23p4LgnytnetEe64=; b=g1Cg2JWz1KJfcs+EnEnMyLeorqdmVOCNZVeQUD6YhWXGfkzfHWPFreo8e2xL/+wjSZwJLYwNAkfKQureOUUNACUoZyi6EVN0EF9VpRMBjwXOlPgzKXbO8TUk7+ZivTcnFwYzXUBPeIGwr26ULf2hKFK0ocFOAbfcdJGY4ZlNUDc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101879+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769957972539.1324393594942; Sat, 25 Mar 2023 11:45:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id WKpjYY1788612xGugWp6B3Kh; Sat, 25 Mar 2023 11:45:57 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28286.1679769952773908107 for ; Sat, 25 Mar 2023 11:45:53 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655085" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655085" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541416" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541416" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:52 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang Subject: [edk2-devel] [Patch 08/12] SecurityPkg/Library/SecureBootVariableLib: Fix VS20xx 4122 errors Date: Sat, 25 Mar 2023 11:45:36 -0700 Message-Id: <20230325184541.596-9-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: 5QUgnX1NN5kwXBSQqkprFOsux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769957; bh=na9bV477sqv5SXx9IuGMUv6ZYvvVp6De7xkPvwFTlmM=; h=Cc:Date:From:Reply-To:Subject:To; b=iHzsbJ59iEpfb72Fh/fXGxs5vIj1qyNwdd7nCtLhnwkppHbRhuY84HGj4R+4ib56ty8 8h1JI5DChsVTbI3Hr4e0Gq2RQpN59Bz5CVKDCUMROP+8cj1Gn70j+rojPtIEc8mWBVOem 5A/fzGOEWesg7Kcx7feDVHv/T6TEOvP6AWY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769959779100031 Content-Type: text/plain; charset="utf-8" The unit test code for the SecureBootVariableLib is initializing local variable structures in their declaration from other local variables that are also initialized in their declaration. ANSI C does not allow this and error 4122 is generated on VS20xx compilers. The test cases are updated to initialize the local structure fields in C statements instead of their local variable declaration. Cc: Jiewen Yao Cc: Jian J Wang Signed-off-by: Michael D Kinney Reviewed-by: Jiewen Yao --- .../UnitTest/SecureBootVariableLibUnitTest.c | 170 +++++++++--------- 1 file changed, 83 insertions(+), 87 deletions(-) diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootV= ariableLibUnitTest.c b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/S= ecureBootVariableLibUnitTest.c index 3a92d5d83457..e4cdc68bbb35 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariable= LibUnitTest.c +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/SecureBootVariable= LibUnitTest.c @@ -351,10 +351,10 @@ SecureBootCreateDataFromInputSimple ( UINTN SigListSize =3D 0; EFI_STATUS Status; UINT8 TestData[] =3D { 0 }; - SECURE_BOOT_CERTIFICATE_INFO KeyInfo =3D { - .Data =3D TestData, - .DataSize =3D sizeof (TestData) - }; + SECURE_BOOT_CERTIFICATE_INFO KeyInfo; + + KeyInfo.Data =3D TestData; + KeyInfo.DataSize =3D sizeof (TestData); =20 Status =3D SecureBootCreateDataFromInput (&SigListSize, &SigList, 1, &Ke= yInfo); =20 @@ -441,16 +441,12 @@ SecureBootCreateDataFromInputMultiple ( UINT8 TestData1[] =3D { 0 }; UINT8 TestData2[] =3D { 1, 2 }; EFI_STATUS Status; - SECURE_BOOT_CERTIFICATE_INFO KeyInfo[2] =3D { - { - .Data =3D TestData1, - .DataSize =3D sizeof (TestData1) - }, - { - .Data =3D TestData2, - .DataSize =3D sizeof (TestData2) - } - }; + SECURE_BOOT_CERTIFICATE_INFO KeyInfo[2]; + + KeyInfo[0].Data =3D TestData1; + KeyInfo[0].DataSize =3D sizeof (TestData1); + KeyInfo[1].Data =3D TestData2; + KeyInfo[1].DataSize =3D sizeof (TestData2); =20 Status =3D SecureBootCreateDataFromInput (&SigListSize, &SigList, 2, Key= Info); UT_ASSERT_NOT_EFI_ERROR (Status); @@ -1219,19 +1215,19 @@ SetSecureBootVariablesShouldComplete ( UINT8 PkDummy =3D 0xFE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .DbtPtr =3D &DbtDummy, - .DbtSize =3D sizeof (DbtDummy), - .KekPtr =3D &KekDummy, - .KekSize =3D sizeof (KekDummy), - .PkPtr =3D &PkDummy, - .PkSize =3D sizeof (PkDummy), - .SecureBootKeyName =3D L"Food" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.DbtPtr =3D &DbtDummy; + PayloadInfo.DbtSize =3D sizeof (DbtDummy); + PayloadInfo.KekPtr =3D &KekDummy; + PayloadInfo.KekSize =3D sizeof (KekDummy); + PayloadInfo.PkPtr =3D &PkDummy; + PayloadInfo.PkSize =3D sizeof (PkDummy); + PayloadInfo.SecureBootKeyName =3D L"Food"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1385,11 +1381,11 @@ SetSecureBootVariablesShouldStopFailDBX ( UINT8 DbxDummy =3D 0xBE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbxDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .SecureBootKeyName =3D L"Fail DBX" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.SecureBootKeyName =3D L"Fail DBX"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1442,13 +1438,13 @@ SetSecureBootVariablesShouldStopFailDB ( UINT8 DbxDummy =3D 0xBE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .SecureBootKeyName =3D L"Fail DB" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.SecureBootKeyName =3D L"Fail DB"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1516,15 +1512,15 @@ SetSecureBootVariablesShouldStopFailDBT ( UINT8 DbxDummy =3D 0xBE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .DbtPtr =3D &DbtDummy, - .DbtSize =3D sizeof (DbtDummy), - .SecureBootKeyName =3D L"Fail DBT" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.DbtPtr =3D &DbtDummy; + PayloadInfo.DbtSize =3D sizeof (DbtDummy); + PayloadInfo.SecureBootKeyName =3D L"Fail DBT"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1608,19 +1604,19 @@ SetSecureBootVariablesShouldStopFailKEK ( UINT8 PkDummy =3D 0xFE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .DbtPtr =3D &DbtDummy, - .DbtSize =3D sizeof (DbtDummy), - .KekPtr =3D &KekDummy, - .KekSize =3D sizeof (KekDummy), - .PkPtr =3D &PkDummy, - .PkSize =3D sizeof (PkDummy), - .SecureBootKeyName =3D L"Food" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.DbtPtr =3D &DbtDummy; + PayloadInfo.DbtSize =3D sizeof (DbtDummy); + PayloadInfo.KekPtr =3D &KekDummy; + PayloadInfo.KekSize =3D sizeof (KekDummy); + PayloadInfo.PkPtr =3D &PkDummy; + PayloadInfo.PkSize =3D sizeof (PkDummy); + PayloadInfo.SecureBootKeyName =3D L"Food"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1718,19 +1714,19 @@ SetSecureBootVariablesShouldStopFailPK ( UINT8 PkDummy =3D 0xFE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .DbtPtr =3D &DbtDummy, - .DbtSize =3D sizeof (DbtDummy), - .KekPtr =3D &KekDummy, - .KekSize =3D sizeof (KekDummy), - .PkPtr =3D &PkDummy, - .PkSize =3D sizeof (PkDummy), - .SecureBootKeyName =3D L"Food" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.DbtPtr =3D &DbtDummy; + PayloadInfo.DbtSize =3D sizeof (DbtDummy); + PayloadInfo.KekPtr =3D &KekDummy; + PayloadInfo.KekSize =3D sizeof (KekDummy); + PayloadInfo.PkPtr =3D &PkDummy; + PayloadInfo.PkSize =3D sizeof (PkDummy); + PayloadInfo.SecureBootKeyName =3D L"Food"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); @@ -1841,19 +1837,19 @@ SetSecureBootVariablesDBTOptional ( UINT8 PkDummy =3D 0xFE; UINT8 *Payload =3D NULL; UINTN PayloadSize =3D sizeof (DbDummy); - SECURE_BOOT_PAYLOAD_INFO PayloadInfo =3D { - .DbPtr =3D &DbDummy, - .DbSize =3D sizeof (DbDummy), - .DbxPtr =3D &DbxDummy, - .DbxSize =3D sizeof (DbxDummy), - .DbtPtr =3D NULL, - .DbtSize =3D 0, - .KekPtr =3D &KekDummy, - .KekSize =3D sizeof (KekDummy), - .PkPtr =3D &PkDummy, - .PkSize =3D sizeof (PkDummy), - .SecureBootKeyName =3D L"Food" - }; + SECURE_BOOT_PAYLOAD_INFO PayloadInfo; + + PayloadInfo.DbPtr =3D &DbDummy; + PayloadInfo.DbSize =3D sizeof (DbDummy); + PayloadInfo.DbxPtr =3D &DbxDummy; + PayloadInfo.DbxSize =3D sizeof (DbxDummy); + PayloadInfo.DbtPtr =3D NULL; + PayloadInfo.DbtSize =3D 0; + PayloadInfo.KekPtr =3D &KekDummy; + PayloadInfo.KekSize =3D sizeof (KekDummy); + PayloadInfo.PkPtr =3D &PkDummy; + PayloadInfo.PkSize =3D sizeof (PkDummy); + PayloadInfo.SecureBootKeyName =3D L"Food"; =20 expect_memory (MockGetVariable, VariableName, EFI_SECURE_BOOT_MODE_NAME,= sizeof (EFI_SECURE_BOOT_MODE_NAME)); expect_value (MockGetVariable, VendorGuid, &gEfiGlobalVariableGuid); --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101879): https://edk2.groups.io/g/devel/message/101879 Mute This Topic: https://groups.io/mt/97848880/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101880+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101880+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769959; cv=none; d=zohomail.com; s=zohoarc; b=IP/Nwr66RJueJ/8upHzixH9rBl8g9smSFLX7jqGxYpUUjt6wkkuvrHQaHm5hprmuMIGy9umSP9I849kUF1tYblM8s315jp/nLOlPsLPJMv2T+CffSAXiRYE2mQlk7Yx30CzdiWlPZLsPtcmQIiC/7VzsBK+avSn22OYAv/ybd30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769959; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=a4q4GRBY8u+B3txpsC9Z6HqPucEf0M3ZKcDZT/SMS4c=; b=fIBkK8k5E6qIOfjAmIF3OkPXCy0nFjSddhbG/HlB/wljorUS+uiYqDPUZ0HZudSSzwZcRoBeGF5Z7SdX2RkNxe24pz8Wkw4ETdz3e33N8ZEXL5Hvz2M0H+wri2+P3rqhzpaFpA/zOP6T16hbWA7qmaXxA4WBsohnQoIfPC0wfcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101880+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167976995915357.7365234272055; Sat, 25 Mar 2023 11:45:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id og2vYY1788612x7SAJ6wTnqy; Sat, 25 Mar 2023 11:45:58 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28286.1679769952773908107 for ; Sat, 25 Mar 2023 11:45:53 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655088" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655088" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541419" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541419" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang Subject: [edk2-devel] [Patch 09/12] SecurityPkg/Library/SecureBootVariableLib: HOST_APPLICATION IA32/X64 only Date: Sat, 25 Mar 2023 11:45:37 -0700 Message-Id: <20230325184541.596-10-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: rs9QNC8zcnQgp7zaiu3wOJfAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769958; bh=GQ0jqKdXf/UFFlZkj4UU9Hc4wzGYe/EL8svR1z6hRTI=; h=Cc:Date:From:Reply-To:Subject:To; b=YfiOthvfNzq/UH5dQ5DlkOP3kzpOqlAQLWWA+C+J58eQUGuIbe4gz6H2ZHKmOoKO4ma dna0VStpV06kOx6RWnVfv0XMO7W8elBheXtcJLio12JxFcIpy2E8+xjTTmoFPZ51Kk0LQ FD/31fsVQghfJHswTKVXUFfxQfs7eSX8apI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769959801100037 Content-Type: text/plain; charset="utf-8" Cc: Jiewen Yao Cc: Jian J Wang Signed-off-by: Michael D Kinney Reviewed-by: Jiewen Yao --- .../UnitTest/MockPlatformPKProtectionLib.inf | 2 +- .../Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf | 2 +- .../UnitTest/MockUefiRuntimeServicesTableLib.inf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatfor= mPKProtectionLib.inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/M= ockPlatformPKProtectionLib.inf index c927ef709958..3698e4fad059 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProt= ectionLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockPlatformPKProt= ectionLib.inf @@ -17,7 +17,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib= .inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf index fecf46841131..e02d04f376da 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiLib.inf @@ -23,7 +23,7 @@ [Defines] LIBRARY_CLASS =3D UefiLib =20 # -# VALID_ARCHITECTURES =3D IA32 X64 EBC +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] diff --git a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRun= timeServicesTableLib.inf b/SecurityPkg/Library/SecureBootVariableLib/UnitTe= st/MockUefiRuntimeServicesTableLib.inf index 6fe04189606e..e59a3394d58f 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeSer= vicesTableLib.inf +++ b/SecurityPkg/Library/SecureBootVariableLib/UnitTest/MockUefiRuntimeSer= vicesTableLib.inf @@ -15,7 +15,7 @@ [Defines] LIBRARY_CLASS =3D UefiRuntimeServicesTableLib =20 # -# VALID_ARCHITECTURES =3D IA32 X64 EBC +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101880): https://edk2.groups.io/g/devel/message/101880 Mute This Topic: https://groups.io/mt/97848881/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101881+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101881+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769958; cv=none; d=zohomail.com; s=zohoarc; b=AilqqkD2oNVv7kThIg5zcmkJBKDlFwMTOZqy385bND/cxDT7mcwpff52KtjtVB7afsmPyN60DV2XG66dywUwaX6mNDNo+CX3WciQjjFbWZnSfFW7wohZOseG8Bny781seix0scbXk2W0XXntyEyVEDLLxohylmYBPUZRP5Uw5i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769958; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8KxM5K5Mr/QXGpbW1Cmd8r9qek2WF0bKtuWcfyTin5A=; b=fTd97LKmHS6ai5cC5EL1NTJqVdVEZJ3rr+CV4faB3ENx5pAz4EQ5krMx3vJULEVru2K7Mx33YVHM3784wwptug6xzpvbV1Y9yPgXcN2rgMpFk2Uc1dgHR7j7shQj5k01/o916Yi5YvL+NkkIs9KlIaftEdP6PiVaxEjigh+bjRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101881+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167976995877648.11420551466381; Sat, 25 Mar 2023 11:45:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id YVtxYY1788612x0FeL1xHGWb; Sat, 25 Mar 2023 11:45:58 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.28286.1679769952773908107 for ; Sat, 25 Mar 2023 11:45:54 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655089" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655089" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541423" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541423" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Zhiguang Liu Subject: [edk2-devel] [Patch 10/12] MdePkg/Library/BaseLib: HOST_APPLICATION IA32/X64 only Date: Sat, 25 Mar 2023 11:45:38 -0700 Message-Id: <20230325184541.596-11-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: 5aIEtGHPJZbuPjUXTzUL7DiVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769958; bh=lPbbfiS1EvPbiiJzTtWKh295nieLP/6esqhOL3wwpdw=; h=Cc:Date:From:Reply-To:Subject:To; b=BxVvaxe5Ggc1ewsmEAo2R0mntVLYRBt4mK9QkfQ3WfM2q+A1Z8SSPrn1kjJowubp2qv AsU+FArQw+Aj/ZCIqLLktSudgZdMkeqiY+oXkIC83w/Px5Nst55gYV1eNK2jJg8ytIDrO cAv+CB0hKHlwtlcu/d12SLiLiriOVl6n4ww= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769959787100033 Content-Type: text/plain; charset="utf-8" Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Michael D Kinney --- MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf b/MdePkg/Librar= y/BaseLib/UnitTestHostBaseLib.inf index 12a5cdcc0a9e..1d53f940f5d0 100644 --- a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf +++ b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf @@ -23,7 +23,7 @@ [Defines] LIBRARY_CLASS =3D UnitTestHostBaseLib|HOST_APPLICATION =20 # -# VALID_ARCHITECTURES =3D IA32 X64 EBC ARM AARCH64 RISCV64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101881): https://edk2.groups.io/g/devel/message/101881 Mute This Topic: https://groups.io/mt/97848882/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101882+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101882+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769959; cv=none; d=zohomail.com; s=zohoarc; b=lMkgbVsl90radbN96q363KCCtm9H8Zk3AeSqxuUQrs/jvsQ6JH7bfr5WVyMbxki1RurnwUrZ2nV5WTYOhhXRrnRTj6cM2SBsqV/L5Zd7pQF3ZtluSOV68oVe4Aw80g7kpEie9xUB6nu/vls6IjoV+DGKkVBkgFjQO0mmfLbwpPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769959; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=fiJivZcN+Z0p01R+SDTVC956g993CxtvgXOkxDFbpUE=; b=FtScQBZwXHET8fdLc5Jld74qR6LslWjn1wFY5gzRifwUdGSZEYvbCbSOqWmSRFv4fT2MFGnUG2s7V4tr72o9VboMIunvtR/3jtTdeGN3lT9zpFuH0eKwaodcFVtn0uPqimK7PzNrLA1gN6ZyIUYCOSaDCWlj/ylHD4quRPayRUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101882+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679769959543746.481249343861; Sat, 25 Mar 2023 11:45:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qrtyYY1788612x8jyKEXUfiy; Sat, 25 Mar 2023 11:45:59 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.28400.1679769954248531046 for ; Sat, 25 Mar 2023 11:45:54 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655094" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655094" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541428" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541428" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:53 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao Subject: [edk2-devel] [Patch 11/12] MdeModulePkg: HOST_APPLICATION IA32/X64 only Date: Sat, 25 Mar 2023 11:45:39 -0700 Message-Id: <20230325184541.596-12-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: TSb3LWrFdlaK6VRfF0U1cIsCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769959; bh=LcIBgn3viDiW7+joUvpXbUKUyNJTsyeH+4Q78WUdwgo=; h=Cc:Date:From:Reply-To:Subject:To; b=MZlHjW2sMJG/CZCnORAGZokIPEhGYlZE2ghXCnfN+uefIGd783vWPASR2LgtSz8fzEB vhLrn5wbkiSvMkc0gSmdxoIzHWX3y8PMJ4Y+LgdMNyWt5L3Etcfm9kcB2Q7Y3fmPxD0fR +Z066wrPe1RQlH7qJnYrdXvLl0tgJOmVBjg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769959796100034 Content-Type: text/plain; charset="utf-8" Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Michael D Kinney --- .../UnitTest/MockUefiRuntimeServicesTableLib.inf | 2 +- .../RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.inf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntim= eServicesTableLib.inf b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/Moc= kUefiRuntimeServicesTableLib.inf index 15eb646d7c38..24dc934f8d25 100644 --- a/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntimeServic= esTableLib.inf +++ b/MdeModulePkg/Library/DxeResetSystemLib/UnitTest/MockUefiRuntimeServic= esTableLib.inf @@ -15,7 +15,7 @@ [Defines] LIBRARY_CLASS =3D UefiRuntimeServicesTableLib =20 # -# VALID_ARCHITECTURES =3D IA32 X64 EBC +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/= VariableLockRequestToLockUnitTest.inf b/MdeModulePkg/Universal/Variable/Run= timeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.inf index 2a659d7e1370..59c743ad1fa6 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Variabl= eLockRequestToLockUnitTest.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/Variabl= eLockRequestToLockUnitTest.inf @@ -15,7 +15,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101882): https://edk2.groups.io/g/devel/message/101882 Mute This Topic: https://groups.io/mt/97848883/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Apr 26 07:05:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101883+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101883+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679769959; cv=none; d=zohomail.com; s=zohoarc; b=ejDQfgbbSaBHUIAESS7ONz1LcEmgEvQBFZCKxOXIAQCcDPLjqqnry/StQpuLnG/EyQ8D3TMsRRoKX/dWA7MfuxxyJOs0J8C3WSALeYwA0kZ8TwiJBc7/CzOxIYt2UnfWK2+CJwxEEmB2u6db+mbze981e9ZL0TgOfuDZfPgdaAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679769959; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=L9Dr69bXnUX717JhwuS/fQej/C9oGkZ3Fl4jpDJwAno=; b=SUTMignNrkijR+dF2MihtWKMazT7aXkZxja4U1245kU/l6kEoxVFY7NOr934cLsbwuEszChRla+3OYOrZu06UfouPxwsYnYhEd0AFEOqV2NeXGMWrdiRc64dURmAaRhey+RHnpgVeJiJPBYUMQpbjmZSM5EEPuUui7lEPIa8kfc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101883+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16797699597221023.6390373200854; Sat, 25 Mar 2023 11:45:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id moOHYY1788612xamyeLazZzY; Sat, 25 Mar 2023 11:45:59 -0700 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.28400.1679769954248531046 for ; Sat, 25 Mar 2023 11:45:54 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="319655097" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="319655097" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10660"; a="685541435" X-IronPort-AV: E=Sophos;i="5.98,291,1673942400"; d="scan'208";a="685541435" X-Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.254.125]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2023 11:45:54 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Michael Kubacki , Nate DeSimone Subject: [edk2-devel] [Patch 12/12] PrmPkg/Library: HOST_APPLICATION IA32/X64 only Date: Sat, 25 Mar 2023 11:45:40 -0700 Message-Id: <20230325184541.596-13-michael.d.kinney@intel.com> In-Reply-To: <20230325184541.596-1-michael.d.kinney@intel.com> References: <20230325184541.596-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: M94lGG826WYg0zMDBZXJmJgSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679769959; bh=mOkRxSxZjWjj4iPAw7kXMRt1pCBEMhOgjThr00rzVgs=; h=Cc:Date:From:Reply-To:Subject:To; b=v7T4lu4DV8AvdNt3aXS4JE89AmCKgfTWuaxpGEa1JKBJHyEcg82UuL2hThlJ5iwJOEc 9cQCB81fh+cqIcc4Cm5m/edy6mD7Laoh5WIz+yvUCBx+7YV03L1bcb0qrXngKeFUUcW2D 05AFoLy8uEfHn2cShZIfihZtqV2imVmlwg8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679769961791100049 Content-Type: text/plain; charset="utf-8" Cc: Michael Kubacki Cc: Nate DeSimone Signed-off-by: Michael D Kinney --- .../UnitTest/DxePrmContextBufferLibUnitTestHost.inf | 2 +- .../UnitTest/DxePrmModuleDiscoveryLibUnitTestHost.inf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBu= fferLibUnitTestHost.inf b/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/Dx= ePrmContextBufferLibUnitTestHost.inf index 7cf6a16867d4..eefaddb10aaf 100644 --- a/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLib= UnitTestHost.inf +++ b/PrmPkg/Library/DxePrmContextBufferLib/UnitTest/DxePrmContextBufferLib= UnitTestHost.inf @@ -17,7 +17,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] diff --git a/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleD= iscoveryLibUnitTestHost.inf b/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitT= est/DxePrmModuleDiscoveryLibUnitTestHost.inf index 8aae1f7cd78a..fd4b44a9bf85 100644 --- a/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscover= yLibUnitTestHost.inf +++ b/PrmPkg/Library/DxePrmModuleDiscoveryLib/UnitTest/DxePrmModuleDiscover= yLibUnitTestHost.inf @@ -17,7 +17,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 # =20 [Sources] --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101883): https://edk2.groups.io/g/devel/message/101883 Mute This Topic: https://groups.io/mt/97848884/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-