From nobody Sat Feb 7 16:00:17 2026 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+107814+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+107814+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1692220529; cv=none; d=zohomail.com; s=zohoarc; b=b7sum16D4U/4V/RCSDO5mhxt/e+QsvIrbhhEfwvUca2MAZx9uMNU3a4xnVIUssQi9ea3M9OdtNDxWuhlTq2fWpmAa2gKADUtmCYiVvaS+rDKDmN+E/H0fSddrF/qd1r1OYl4gVFTg46eAWSxuIWBqi+DBjL3e3tJatBkp+UbSD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692220529; 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=0iYXPAOw8AGQt4BpaiCYVVnPOoW4cWHwJ6KmZ6FubrA=; b=mWbQc908WNodRM1u3HaBUeEeEwt/JbrSfBsUI9iu03NRMaYi98Awod4aLNYdhCM0EixRLcNFeiFZITDrOXAbV1zc5Sj3aPvoOJfNZ4sNLK154yPQ9ekKPdRbdC7BfzCiTHgUMjII8xiEcpfx0jriDokS2AMjK8+Z+du1WQWVQP4= 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+107814+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 1692220529442200.6864169850478; Wed, 16 Aug 2023 14:15:29 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=8Cyi0HgODv55d/np5ZKaIq8Hsi6av9g3iIRj6/E0Ckw=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1692220529; v=1; b=QwZ2AhjiCr9BugzQQuaUjlgMPwY99ifCadVpyXDTtuNEmbVE5SUjaFPN/NXBJgxk7JtQ2Qi1 mC5XG4C5he1aM+qW/rQ23zSFY75O12dHBag6u4pqNLXlpyoltUkR3gb8ZCnKX4vc61c3SRu3l6p Q6P7sWnvHrsF5PYnFbMmMxME= X-Received: by 127.0.0.2 with SMTP id XDF5YY1788612xalN6HUaJsV; Wed, 16 Aug 2023 14:15:29 -0700 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.172398.1692220526202465604 for ; Wed, 16 Aug 2023 14:15:26 -0700 X-Received: from vivian-P520.redmond.corp.microsoft.com (unknown [131.107.1.251]) by linux.microsoft.com (Postfix) with ESMTPSA id C9248211F7A4; Wed, 16 Aug 2023 14:15:25 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C9248211F7A4 From: "VivianNK" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v2 5/7] SecurityPkg: Apply uncrustify formatting to relevant files Date: Wed, 16 Aug 2023 14:15:20 -0700 Message-ID: <20230816211523.12-6-vnowkakeane@linux.microsoft.com> In-Reply-To: <20230816211523.12-1-vnowkakeane@linux.microsoft.com> References: <20230816211523.12-1-vnowkakeane@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,vnowkakeane@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: K8lOX0sXa7YN3fKRfGT3cbj0x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692220531141100024 Content-Type: text/plain; charset="utf-8" Apply uncrustify formatting to GoogleTest cpp and header files. Cc: Jiewen Yao =20 Cc: Jian J Wang Signed-off-by: Vivian Nowka-Keane --- SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLib= GoogleTest.cpp | 205 ++++++++++++-------- SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtectionL= ib.h | 4 +- SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockP= latformPKProtectionLib.cpp | 4 +- 3 files changed, 124 insertions(+), 89 deletions(-) diff --git a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBoo= tVariableLibGoogleTest.cpp b/SecurityPkg/Library/SecureBootVariableLib/Goog= leTest/SecureBootVariableLibGoogleTest.cpp index c9190c8ffd61..f66c595a97a8 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariab= leLibGoogleTest.cpp +++ b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariab= leLibGoogleTest.cpp @@ -21,154 +21,189 @@ using namespace testing; =20 //////////////////////////////////////////////////////////////////////////= //// class SetSecureBootModeTest : public Test { - protected: - MockUefiRuntimeServicesTableLib RtServicesMock; - UINT8 SecureBootMode; - EFI_STATUS Status; +protected: + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SecureBootMode; + EFI_STATUS Status; =20 - void SetUp() override { - // Any random magic number can be used for these tests - SecureBootMode =3D 0xAB; - } + void + SetUp ( + ) override + { + // Any random magic number can be used for these tests + SecureBootMode =3D 0xAB; + } }; =20 // Test SetSecureBootMode() API from SecureBootVariableLib to verify the // expected error is returned when the call to gRT->SetVariable() fails. -TEST_F(SetSecureBootModeTest, SetVarError) { - EXPECT_CALL(RtServicesMock, gRT_SetVariable) - .WillOnce(Return(EFI_INVALID_PARAMETER)); +TEST_F (SetSecureBootModeTest, SetVarError) { + EXPECT_CALL (RtServicesMock, gRT_SetVariable) + .WillOnce (Return (EFI_INVALID_PARAMETER)); =20 - Status =3D SetSecureBootMode(SecureBootMode); - EXPECT_EQ(Status, EFI_INVALID_PARAMETER); + Status =3D SetSecureBootMode (SecureBootMode); + EXPECT_EQ (Status, EFI_INVALID_PARAMETER); } =20 // Test SetSecureBootMode() API from SecureBootVariableLib to verify the // expected secure boot mode is written to the correct variable in the call // to gRT->SetVariable(). -TEST_F(SetSecureBootModeTest, PropogateModeToSetVar) { - EXPECT_CALL(RtServicesMock, - gRT_SetVariable( - Char16StrEq(EFI_CUSTOM_MODE_NAME), - BufferEq(&gEfiCustomModeEnableGuid, sizeof(EFI_GUID)), +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)); + sizeof (SecureBootMode), + BufferEq (&SecureBootMode, sizeof (SecureBootMode)) + ) + ) + .WillOnce (Return (EFI_SUCCESS)); =20 - Status =3D SetSecureBootMode(SecureBootMode); - EXPECT_EQ(Status, EFI_SUCCESS); + Status =3D SetSecureBootMode (SecureBootMode); + EXPECT_EQ (Status, EFI_SUCCESS); } =20 //////////////////////////////////////////////////////////////////////////= //// class GetSetupModeTest : public Test { - protected: - MockUefiRuntimeServicesTableLib RtServicesMock; - UINT8 SetupMode; - EFI_STATUS Status; - UINT8 ExpSetupMode; +protected: + MockUefiRuntimeServicesTableLib RtServicesMock; + UINT8 SetupMode; + EFI_STATUS Status; + UINT8 ExpSetupMode; =20 - void SetUp() override { - // Any random magic number can be used for these tests - ExpSetupMode =3D 0xAB; - } + void + SetUp ( + ) override + { + // Any random magic number can be used for these tests + ExpSetupMode =3D 0xAB; + } }; =20 // Test GetSetupMode() API from SecureBootVariableLib to verify the expect= ed // error is returned when the call to gRT->GetVariable() fails. -TEST_F(GetSetupModeTest, GetVarError) { - EXPECT_CALL(RtServicesMock, gRT_GetVariable) - .WillOnce(Return(EFI_INVALID_PARAMETER)); +TEST_F (GetSetupModeTest, GetVarError) { + EXPECT_CALL (RtServicesMock, gRT_GetVariable) + .WillOnce (Return (EFI_INVALID_PARAMETER)); =20 Status =3D GetSetupMode (&SetupMode); - EXPECT_EQ(Status, EFI_INVALID_PARAMETER); + EXPECT_EQ (Status, EFI_INVALID_PARAMETER); } =20 // Test GetSetupMode() API from SecureBootVariableLib to verify the expect= ed // setup mode is returned (and with a success return code) when the mode is // successfully read from the call to gRT->GetVariable(). -TEST_F(GetSetupModeTest, FetchModeFromGetVar) { - EXPECT_CALL(RtServicesMock, - gRT_GetVariable( - Char16StrEq(EFI_SETUP_MODE_NAME), - BufferEq(&gEfiGlobalVariableGuid, sizeof(EFI_GUID)), +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))); + Pointee (Eq (sizeof (SetupMode))), + NotNull () + ) + ) + .WillOnce ( + DoAll ( + SetArgPointee<3>(sizeof (ExpSetupMode)), + SetArgBuffer<4>(&ExpSetupMode, sizeof (ExpSetupMode)), + Return (EFI_SUCCESS) + ) + ); =20 Status =3D GetSetupMode (&SetupMode); - ASSERT_EQ(Status, EFI_SUCCESS); - EXPECT_EQ(SetupMode, ExpSetupMode); + ASSERT_EQ (Status, EFI_SUCCESS); + EXPECT_EQ (SetupMode, ExpSetupMode); } =20 //////////////////////////////////////////////////////////////////////////= //// class IsSecureBootEnabledTest : public Test { - protected: - MockUefiLib UefiLibMock; - BOOLEAN Enabled; +protected: + MockUefiLib UefiLibMock; + BOOLEAN Enabled; }; =20 // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FAL= SE // is returned when the call to GetEfiGlobalVariable2() fails. -TEST_F(IsSecureBootEnabledTest, GetVarError) { - EXPECT_CALL(UefiLibMock, GetEfiGlobalVariable2) - .WillOnce(Return(EFI_ABORTED)); +TEST_F (IsSecureBootEnabledTest, GetVarError) { + EXPECT_CALL (UefiLibMock, GetEfiGlobalVariable2) + .WillOnce (Return (EFI_ABORTED)); =20 Enabled =3D IsSecureBootEnabled (); - EXPECT_EQ(Enabled, FALSE); + EXPECT_EQ (Enabled, FALSE); } =20 //////////////////////////////////////////////////////////////////////////= //// class IsSecureBootEnabledAllocTest : public IsSecureBootEnabledTest { - protected: - UINT8 *BootEnabledBuffer; +protected: + UINT8 *BootEnabledBuffer; =20 - void SetUp() override { - BootEnabledBuffer =3D (UINT8*) AllocatePool(1); - ASSERT_NE(BootEnabledBuffer, nullptr); - } + void + SetUp ( + ) override + { + BootEnabledBuffer =3D (UINT8 *)AllocatePool (1); + ASSERT_NE (BootEnabledBuffer, nullptr); + } }; =20 // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify TRUE // is returned when the call to GetEfiGlobalVariable2() is successful and // returns SECURE_BOOT_MODE_ENABLE. -TEST_F(IsSecureBootEnabledAllocTest, IsEnabled) { +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))); + EXPECT_CALL ( + UefiLibMock, + GetEfiGlobalVariable2 ( + Char16StrEq (EFI_SECURE_BOOT_MODE_NAME), + NotNull (), + _ + ) + ) + .WillOnce ( + DoAll ( + SetArgBuffer<1>(&BootEnabledBuffer, sizeof (VOID *)), + Return (EFI_SUCCESS) + ) + ); =20 Enabled =3D IsSecureBootEnabled (); - EXPECT_EQ(Enabled, TRUE); + EXPECT_EQ (Enabled, TRUE); } =20 // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FAL= SE // is returned when the call to GetEfiGlobalVariable2() is successful and // returns SECURE_BOOT_MODE_DISABLE. -TEST_F(IsSecureBootEnabledAllocTest, IsDisabled) { +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))); + EXPECT_CALL ( + UefiLibMock, + GetEfiGlobalVariable2 ( + Char16StrEq (EFI_SECURE_BOOT_MODE_NAME), + NotNull (), + _ + ) + ) + .WillOnce ( + DoAll ( + SetArgBuffer<1>(&BootEnabledBuffer, sizeof (VOID *)), + Return (EFI_SUCCESS) + ) + ); =20 Enabled =3D IsSecureBootEnabled (); - EXPECT_EQ(Enabled, FALSE); + EXPECT_EQ (Enabled, FALSE); } =20 -int main(int argc, char* argv[]) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); +int +main ( + int argc, + char *argv[] + ) +{ + testing::InitGoogleTest (&argc, argv); + return RUN_ALL_TESTS (); } diff --git a/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformP= KProtectionLib.h b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPla= tformPKProtectionLib.h index 8024f4be2975..04288f2b75a3 100644 --- a/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtec= tionLib.h +++ b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtec= tionLib.h @@ -11,8 +11,8 @@ #include #include extern "C" { -#include -#include + #include + #include } =20 struct MockPlatformPKProtectionLib { diff --git a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtect= ionLib/MockPlatformPKProtectionLib.cpp b/SecurityPkg/Test/Mock/Library/Goog= leTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.cpp index 5ea030f6dfcf..6613d5ed199a 100644 --- a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/= MockPlatformPKProtectionLib.cpp +++ b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/= MockPlatformPKProtectionLib.cpp @@ -6,6 +6,6 @@ **/ #include =20 -MOCK_INTERFACE_DEFINITION(MockPlatformPKProtectionLib); +MOCK_INTERFACE_DEFINITION (MockPlatformPKProtectionLib); =20 -MOCK_FUNCTION_DEFINITION(MockPlatformPKProtectionLib, DisablePKProtection,= 0, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockPlatformPKProtectionLib, DisablePKProtection= , 0, EFIAPI); --=20 2.41.0.windows.3 -=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 (#107814): https://edk2.groups.io/g/devel/message/107814 Mute This Topic: https://groups.io/mt/100788670/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-