From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 04E79AC16CB for ; Wed, 16 Aug 2023 21:15:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QBtN8YIBy2/TxNAV8IarYHbb1sDQwRIdlPL4WvUlgBg=; 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=1692220531; v=1; b=xcBJlECDSOInEy5RD0j6fiad385ghuD3C3UJp3CXy9sbJMwWzBo9RZd4s6LhVvTqmxhyOCRN EB0eDqNxUOwqqNjKm6t2tyEFpodKH8t9mB7qdnk3iihzLOt/Gths2UrngHGqVWyyCSELwgCyA8D HnGedneYxhy7AZGdwIX/6AgA= X-Received: by 127.0.0.2 with SMTP id urhoYY7687511xuHBrKJwOPf; Wed, 16 Aug 2023 14:15:31 -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: cWgBg1P2iRbpACOfSQOhEsT3x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=xcBJlECD; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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; =0D //////////////////////////////////////////////////////////////////////////= ////=0D class SetSecureBootModeTest : public Test {=0D - protected:=0D - MockUefiRuntimeServicesTableLib RtServicesMock;=0D - UINT8 SecureBootMode;=0D - EFI_STATUS Status;=0D +protected:=0D + MockUefiRuntimeServicesTableLib RtServicesMock;=0D + UINT8 SecureBootMode;=0D + EFI_STATUS Status;=0D =0D - void SetUp() override {=0D - // Any random magic number can be used for these tests=0D - SecureBootMode =3D 0xAB;=0D - }=0D + void=0D + SetUp (=0D + ) override=0D + {=0D + // Any random magic number can be used for these tests=0D + SecureBootMode =3D 0xAB;=0D + }=0D };=0D =0D // Test SetSecureBootMode() API from SecureBootVariableLib to verify the=0D // expected error is returned when the call to gRT->SetVariable() fails.=0D -TEST_F(SetSecureBootModeTest, SetVarError) {=0D - EXPECT_CALL(RtServicesMock, gRT_SetVariable)=0D - .WillOnce(Return(EFI_INVALID_PARAMETER));=0D +TEST_F (SetSecureBootModeTest, SetVarError) {=0D + EXPECT_CALL (RtServicesMock, gRT_SetVariable)=0D + .WillOnce (Return (EFI_INVALID_PARAMETER));=0D =0D - Status =3D SetSecureBootMode(SecureBootMode);=0D - EXPECT_EQ(Status, EFI_INVALID_PARAMETER);=0D + Status =3D SetSecureBootMode (SecureBootMode);=0D + EXPECT_EQ (Status, EFI_INVALID_PARAMETER);=0D }=0D =0D // Test SetSecureBootMode() API from SecureBootVariableLib to verify the=0D // expected secure boot mode is written to the correct variable in the cal= l=0D // to gRT->SetVariable().=0D -TEST_F(SetSecureBootModeTest, PropogateModeToSetVar) {=0D - EXPECT_CALL(RtServicesMock,=0D - gRT_SetVariable(=0D - Char16StrEq(EFI_CUSTOM_MODE_NAME),=0D - BufferEq(&gEfiCustomModeEnableGuid, sizeof(EFI_GUID)),=0D +TEST_F (SetSecureBootModeTest, PropogateModeToSetVar) {=0D + EXPECT_CALL (=0D + RtServicesMock,=0D + gRT_SetVariable (=0D + Char16StrEq (EFI_CUSTOM_MODE_NAME),=0D + BufferEq (&gEfiCustomModeEnableGuid, sizeof (EFI_GUID)),=0D EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,=0D - sizeof(SecureBootMode),=0D - BufferEq(&SecureBootMode, sizeof(SecureBootMode))))=0D - .WillOnce(Return(EFI_SUCCESS));=0D + sizeof (SecureBootMode),=0D + BufferEq (&SecureBootMode, sizeof (SecureBootMode))=0D + )=0D + )=0D + .WillOnce (Return (EFI_SUCCESS));=0D =0D - Status =3D SetSecureBootMode(SecureBootMode);=0D - EXPECT_EQ(Status, EFI_SUCCESS);=0D + Status =3D SetSecureBootMode (SecureBootMode);=0D + EXPECT_EQ (Status, EFI_SUCCESS);=0D }=0D =0D //////////////////////////////////////////////////////////////////////////= ////=0D class GetSetupModeTest : public Test {=0D - protected:=0D - MockUefiRuntimeServicesTableLib RtServicesMock;=0D - UINT8 SetupMode;=0D - EFI_STATUS Status;=0D - UINT8 ExpSetupMode;=0D +protected:=0D + MockUefiRuntimeServicesTableLib RtServicesMock;=0D + UINT8 SetupMode;=0D + EFI_STATUS Status;=0D + UINT8 ExpSetupMode;=0D =0D - void SetUp() override {=0D - // Any random magic number can be used for these tests=0D - ExpSetupMode =3D 0xAB;=0D - }=0D + void=0D + SetUp (=0D + ) override=0D + {=0D + // Any random magic number can be used for these tests=0D + ExpSetupMode =3D 0xAB;=0D + }=0D };=0D =0D // Test GetSetupMode() API from SecureBootVariableLib to verify the expect= ed=0D // error is returned when the call to gRT->GetVariable() fails.=0D -TEST_F(GetSetupModeTest, GetVarError) {=0D - EXPECT_CALL(RtServicesMock, gRT_GetVariable)=0D - .WillOnce(Return(EFI_INVALID_PARAMETER));=0D +TEST_F (GetSetupModeTest, GetVarError) {=0D + EXPECT_CALL (RtServicesMock, gRT_GetVariable)=0D + .WillOnce (Return (EFI_INVALID_PARAMETER));=0D =0D Status =3D GetSetupMode (&SetupMode);=0D - EXPECT_EQ(Status, EFI_INVALID_PARAMETER);=0D + EXPECT_EQ (Status, EFI_INVALID_PARAMETER);=0D }=0D =0D // Test GetSetupMode() API from SecureBootVariableLib to verify the expect= ed=0D // setup mode is returned (and with a success return code) when the mode i= s=0D // successfully read from the call to gRT->GetVariable().=0D -TEST_F(GetSetupModeTest, FetchModeFromGetVar) {=0D - EXPECT_CALL(RtServicesMock,=0D - gRT_GetVariable(=0D - Char16StrEq(EFI_SETUP_MODE_NAME),=0D - BufferEq(&gEfiGlobalVariableGuid, sizeof(EFI_GUID)),=0D +TEST_F (GetSetupModeTest, FetchModeFromGetVar) {=0D + EXPECT_CALL (=0D + RtServicesMock,=0D + gRT_GetVariable (=0D + Char16StrEq (EFI_SETUP_MODE_NAME),=0D + BufferEq (&gEfiGlobalVariableGuid, sizeof (EFI_GUID)),=0D _,=0D - Pointee(Eq(sizeof(SetupMode))),=0D - NotNull()))=0D - .WillOnce(DoAll(=0D - SetArgPointee<3>(sizeof(ExpSetupMode)),=0D - SetArgBuffer<4>(&ExpSetupMode, sizeof(ExpSetupMode)),=0D - Return(EFI_SUCCESS)));=0D + Pointee (Eq (sizeof (SetupMode))),=0D + NotNull ()=0D + )=0D + )=0D + .WillOnce (=0D + DoAll (=0D + SetArgPointee<3>(sizeof (ExpSetupMode)),=0D + SetArgBuffer<4>(&ExpSetupMode, sizeof (ExpSetupMode)),=0D + Return (EFI_SUCCESS)=0D + )=0D + );=0D =0D Status =3D GetSetupMode (&SetupMode);=0D - ASSERT_EQ(Status, EFI_SUCCESS);=0D - EXPECT_EQ(SetupMode, ExpSetupMode);=0D + ASSERT_EQ (Status, EFI_SUCCESS);=0D + EXPECT_EQ (SetupMode, ExpSetupMode);=0D }=0D =0D //////////////////////////////////////////////////////////////////////////= ////=0D class IsSecureBootEnabledTest : public Test {=0D - protected:=0D - MockUefiLib UefiLibMock;=0D - BOOLEAN Enabled;=0D +protected:=0D + MockUefiLib UefiLibMock;=0D + BOOLEAN Enabled;=0D };=0D =0D // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FAL= SE=0D // is returned when the call to GetEfiGlobalVariable2() fails.=0D -TEST_F(IsSecureBootEnabledTest, GetVarError) {=0D - EXPECT_CALL(UefiLibMock, GetEfiGlobalVariable2)=0D - .WillOnce(Return(EFI_ABORTED));=0D +TEST_F (IsSecureBootEnabledTest, GetVarError) {=0D + EXPECT_CALL (UefiLibMock, GetEfiGlobalVariable2)=0D + .WillOnce (Return (EFI_ABORTED));=0D =0D Enabled =3D IsSecureBootEnabled ();=0D - EXPECT_EQ(Enabled, FALSE);=0D + EXPECT_EQ (Enabled, FALSE);=0D }=0D =0D //////////////////////////////////////////////////////////////////////////= ////=0D class IsSecureBootEnabledAllocTest : public IsSecureBootEnabledTest {=0D - protected:=0D - UINT8 *BootEnabledBuffer;=0D +protected:=0D + UINT8 *BootEnabledBuffer;=0D =0D - void SetUp() override {=0D - BootEnabledBuffer =3D (UINT8*) AllocatePool(1);=0D - ASSERT_NE(BootEnabledBuffer, nullptr);=0D - }=0D + void=0D + SetUp (=0D + ) override=0D + {=0D + BootEnabledBuffer =3D (UINT8 *)AllocatePool (1);=0D + ASSERT_NE (BootEnabledBuffer, nullptr);=0D + }=0D };=0D =0D // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify TRU= E=0D // is returned when the call to GetEfiGlobalVariable2() is successful and= =0D // returns SECURE_BOOT_MODE_ENABLE.=0D -TEST_F(IsSecureBootEnabledAllocTest, IsEnabled) {=0D +TEST_F (IsSecureBootEnabledAllocTest, IsEnabled) {=0D *BootEnabledBuffer =3D SECURE_BOOT_MODE_ENABLE;=0D - EXPECT_CALL(UefiLibMock,=0D - GetEfiGlobalVariable2(=0D - Char16StrEq(EFI_SECURE_BOOT_MODE_NAME),=0D - NotNull(),=0D - _))=0D - .WillOnce(DoAll(=0D - SetArgBuffer<1>(&BootEnabledBuffer, sizeof(VOID*)),=0D - Return(EFI_SUCCESS)));=0D + EXPECT_CALL (=0D + UefiLibMock,=0D + GetEfiGlobalVariable2 (=0D + Char16StrEq (EFI_SECURE_BOOT_MODE_NAME),=0D + NotNull (),=0D + _=0D + )=0D + )=0D + .WillOnce (=0D + DoAll (=0D + SetArgBuffer<1>(&BootEnabledBuffer, sizeof (VOID *)),=0D + Return (EFI_SUCCESS)=0D + )=0D + );=0D =0D Enabled =3D IsSecureBootEnabled ();=0D - EXPECT_EQ(Enabled, TRUE);=0D + EXPECT_EQ (Enabled, TRUE);=0D }=0D =0D // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FAL= SE=0D // is returned when the call to GetEfiGlobalVariable2() is successful and= =0D // returns SECURE_BOOT_MODE_DISABLE.=0D -TEST_F(IsSecureBootEnabledAllocTest, IsDisabled) {=0D +TEST_F (IsSecureBootEnabledAllocTest, IsDisabled) {=0D *BootEnabledBuffer =3D SECURE_BOOT_MODE_DISABLE;=0D - EXPECT_CALL(UefiLibMock,=0D - GetEfiGlobalVariable2(=0D - Char16StrEq(EFI_SECURE_BOOT_MODE_NAME),=0D - NotNull(),=0D - _))=0D - .WillOnce(DoAll(=0D - SetArgBuffer<1>(&BootEnabledBuffer, sizeof(VOID*)),=0D - Return(EFI_SUCCESS)));=0D + EXPECT_CALL (=0D + UefiLibMock,=0D + GetEfiGlobalVariable2 (=0D + Char16StrEq (EFI_SECURE_BOOT_MODE_NAME),=0D + NotNull (),=0D + _=0D + )=0D + )=0D + .WillOnce (=0D + DoAll (=0D + SetArgBuffer<1>(&BootEnabledBuffer, sizeof (VOID *)),=0D + Return (EFI_SUCCESS)=0D + )=0D + );=0D =0D Enabled =3D IsSecureBootEnabled ();=0D - EXPECT_EQ(Enabled, FALSE);=0D + EXPECT_EQ (Enabled, FALSE);=0D }=0D =0D -int main(int argc, char* argv[]) {=0D - testing::InitGoogleTest(&argc, argv);=0D - return RUN_ALL_TESTS();=0D +int=0D +main (=0D + int argc,=0D + char *argv[]=0D + )=0D +{=0D + testing::InitGoogleTest (&argc, argv);=0D + return RUN_ALL_TESTS ();=0D }=0D 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 =0D #include =0D extern "C" {=0D -#include =0D -#include =0D + #include =0D + #include =0D }=0D =0D struct MockPlatformPKProtectionLib {=0D 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 @@ **/=0D #include =0D =0D -MOCK_INTERFACE_DEFINITION(MockPlatformPKProtectionLib);=0D +MOCK_INTERFACE_DEFINITION (MockPlatformPKProtectionLib);=0D =0D -MOCK_FUNCTION_DEFINITION(MockPlatformPKProtectionLib, DisablePKProtection,= 0, EFIAPI);=0D +MOCK_FUNCTION_DEFINITION (MockPlatformPKProtectionLib, DisablePKProtection= , 0, EFIAPI);=0D --=20 2.41.0.windows.3 -=-=-=-=-=-=-=-=-=-=-=- 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/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-