From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: VivianNK <vnowkakeane@linux.microsoft.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wang, Jian J" <jian.j.wang@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 5/7] SecurityPkg: Apply uncrustify formatting to relevant files
Date: Thu, 17 Aug 2023 02:41:12 +0000 [thread overview]
Message-ID: <MW4PR11MB5872AC8EC091EDC8FE19A50D8C1AA@MW4PR11MB5872.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230816211523.12-6-vnowkakeane@linux.microsoft.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
> -----Original Message-----
> From: VivianNK <vnowkakeane@linux.microsoft.com>
> Sent: Thursday, August 17, 2023 5:15 AM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>
> Subject: [PATCH v2 5/7] SecurityPkg: Apply uncrustify formatting to relevant files
>
> Apply uncrustify formatting to GoogleTest cpp and header files.
>
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Signed-off-by: Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com>
> ---
>
> SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGo
> ogleTest.cpp | 205 ++++++++++++--------
>
> SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtectionLi
> b.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/SecureBootVariableLib
> GoogleTest.cpp
> b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLib
> GoogleTest.cpp
> index c9190c8ffd61..f66c595a97a8 100644
> ---
> a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLib
> GoogleTest.cpp
> +++
> b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLib
> GoogleTest.cpp
> @@ -21,154 +21,189 @@ using namespace testing;
>
>
> //////////////////////////////////////////////////////////////////////////////
>
> class SetSecureBootModeTest : public Test {
>
> - protected:
>
> - MockUefiRuntimeServicesTableLib RtServicesMock;
>
> - UINT8 SecureBootMode;
>
> - EFI_STATUS Status;
>
> +protected:
>
> + MockUefiRuntimeServicesTableLib RtServicesMock;
>
> + UINT8 SecureBootMode;
>
> + EFI_STATUS Status;
>
>
>
> - void SetUp() override {
>
> - // Any random magic number can be used for these tests
>
> - SecureBootMode = 0xAB;
>
> - }
>
> + void
>
> + SetUp (
>
> + ) override
>
> + {
>
> + // Any random magic number can be used for these tests
>
> + SecureBootMode = 0xAB;
>
> + }
>
> };
>
>
>
> // 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));
>
>
>
> - Status = SetSecureBootMode(SecureBootMode);
>
> - EXPECT_EQ(Status, EFI_INVALID_PARAMETER);
>
> + Status = SetSecureBootMode (SecureBootMode);
>
> + EXPECT_EQ (Status, EFI_INVALID_PARAMETER);
>
> }
>
>
>
> // 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));
>
>
>
> - Status = SetSecureBootMode(SecureBootMode);
>
> - EXPECT_EQ(Status, EFI_SUCCESS);
>
> + Status = SetSecureBootMode (SecureBootMode);
>
> + EXPECT_EQ (Status, EFI_SUCCESS);
>
> }
>
>
>
> //////////////////////////////////////////////////////////////////////////////
>
> class GetSetupModeTest : public Test {
>
> - protected:
>
> - MockUefiRuntimeServicesTableLib RtServicesMock;
>
> - UINT8 SetupMode;
>
> - EFI_STATUS Status;
>
> - UINT8 ExpSetupMode;
>
> +protected:
>
> + MockUefiRuntimeServicesTableLib RtServicesMock;
>
> + UINT8 SetupMode;
>
> + EFI_STATUS Status;
>
> + UINT8 ExpSetupMode;
>
>
>
> - void SetUp() override {
>
> - // Any random magic number can be used for these tests
>
> - ExpSetupMode = 0xAB;
>
> - }
>
> + void
>
> + SetUp (
>
> + ) override
>
> + {
>
> + // Any random magic number can be used for these tests
>
> + ExpSetupMode = 0xAB;
>
> + }
>
> };
>
>
>
> // Test GetSetupMode() API from SecureBootVariableLib to verify the expected
>
> // 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));
>
>
>
> Status = GetSetupMode (&SetupMode);
>
> - EXPECT_EQ(Status, EFI_INVALID_PARAMETER);
>
> + EXPECT_EQ (Status, EFI_INVALID_PARAMETER);
>
> }
>
>
>
> // Test GetSetupMode() API from SecureBootVariableLib to verify the expected
>
> // 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)
>
> + )
>
> + );
>
>
>
> Status = GetSetupMode (&SetupMode);
>
> - ASSERT_EQ(Status, EFI_SUCCESS);
>
> - EXPECT_EQ(SetupMode, ExpSetupMode);
>
> + ASSERT_EQ (Status, EFI_SUCCESS);
>
> + EXPECT_EQ (SetupMode, ExpSetupMode);
>
> }
>
>
>
> //////////////////////////////////////////////////////////////////////////////
>
> class IsSecureBootEnabledTest : public Test {
>
> - protected:
>
> - MockUefiLib UefiLibMock;
>
> - BOOLEAN Enabled;
>
> +protected:
>
> + MockUefiLib UefiLibMock;
>
> + BOOLEAN Enabled;
>
> };
>
>
>
> // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FALSE
>
> // 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));
>
>
>
> Enabled = IsSecureBootEnabled ();
>
> - EXPECT_EQ(Enabled, FALSE);
>
> + EXPECT_EQ (Enabled, FALSE);
>
> }
>
>
>
> //////////////////////////////////////////////////////////////////////////////
>
> class IsSecureBootEnabledAllocTest : public IsSecureBootEnabledTest {
>
> - protected:
>
> - UINT8 *BootEnabledBuffer;
>
> +protected:
>
> + UINT8 *BootEnabledBuffer;
>
>
>
> - void SetUp() override {
>
> - BootEnabledBuffer = (UINT8*) AllocatePool(1);
>
> - ASSERT_NE(BootEnabledBuffer, nullptr);
>
> - }
>
> + void
>
> + SetUp (
>
> + ) override
>
> + {
>
> + BootEnabledBuffer = (UINT8 *)AllocatePool (1);
>
> + ASSERT_NE (BootEnabledBuffer, nullptr);
>
> + }
>
> };
>
>
>
> // 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 = 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)
>
> + )
>
> + );
>
>
>
> Enabled = IsSecureBootEnabled ();
>
> - EXPECT_EQ(Enabled, TRUE);
>
> + EXPECT_EQ (Enabled, TRUE);
>
> }
>
>
>
> // Test IsSecureBootEnabled() API from SecureBootVariableLib to verify FALSE
>
> // is returned when the call to GetEfiGlobalVariable2() is successful and
>
> // returns SECURE_BOOT_MODE_DISABLE.
>
> -TEST_F(IsSecureBootEnabledAllocTest, IsDisabled) {
>
> +TEST_F (IsSecureBootEnabledAllocTest, IsDisabled) {
>
> *BootEnabledBuffer = 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)
>
> + )
>
> + );
>
>
>
> Enabled = IsSecureBootEnabled ();
>
> - EXPECT_EQ(Enabled, FALSE);
>
> + EXPECT_EQ (Enabled, FALSE);
>
> }
>
>
>
> -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/MockPlatformPKProtection
> Lib.h
> b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtection
> Lib.h
> index 8024f4be2975..04288f2b75a3 100644
> ---
> a/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtection
> Lib.h
> +++
> b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtection
> Lib.h
> @@ -11,8 +11,8 @@
> #include <Library/GoogleTestLib.h>
>
> #include <Library/FunctionMockLib.h>
>
> extern "C" {
>
> -#include <Uefi.h>
>
> -#include <Library/PlatformPKProtectionLib.h>
>
> + #include <Uefi.h>
>
> + #include <Library/PlatformPKProtectionLib.h>
>
> }
>
>
>
> struct MockPlatformPKProtectionLib {
>
> diff --git
> a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/Moc
> kPlatformPKProtectionLib.cpp
> b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/Moc
> kPlatformPKProtectionLib.cpp
> index 5ea030f6dfcf..6613d5ed199a 100644
> ---
> a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/Moc
> kPlatformPKProtectionLib.cpp
> +++
> b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/Moc
> kPlatformPKProtectionLib.cpp
> @@ -6,6 +6,6 @@
> **/
>
> #include <GoogleTest/Library/MockPlatformPKProtectionLib.h>
>
>
>
> -MOCK_INTERFACE_DEFINITION(MockPlatformPKProtectionLib);
>
> +MOCK_INTERFACE_DEFINITION (MockPlatformPKProtectionLib);
>
>
>
> -MOCK_FUNCTION_DEFINITION(MockPlatformPKProtectionLib,
> DisablePKProtection, 0, EFIAPI);
>
> +MOCK_FUNCTION_DEFINITION (MockPlatformPKProtectionLib,
> DisablePKProtection, 0, EFIAPI);
>
> --
> 2.41.0.windows.3
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107820): https://edk2.groups.io/g/devel/message/107820
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]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-08-17 2:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 21:15 [edk2-devel] [PATCH v2 0/7] Uncrustify GoogleTest update VivianNK
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 1/7] .pytool: Set uncrustify check to audit only (temporary) VivianNK
2023-08-16 22:09 ` Michael Kubacki
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 2/7] .pytool: Add cpp support to uncrustify plugin VivianNK
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 3/7] MdeModulePkg: Apply uncrustify formatting to relevant files VivianNK
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 4/7] MdePkg: " VivianNK
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 5/7] SecurityPkg: " VivianNK
2023-08-17 2:41 ` Yao, Jiewen [this message]
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 6/7] UnitTestFrameworkPkg: " VivianNK
2023-08-16 21:15 ` [edk2-devel] [PATCH v2 7/7] .pytool: Undo uncrustify check change VivianNK
2023-08-16 22:09 ` Michael Kubacki
2023-09-12 1:08 ` 回复: [edk2-devel] [PATCH v2 0/7] Uncrustify GoogleTest update gaoliming via groups.io
2023-09-12 14:42 ` Michael D Kinney
2023-09-27 19:43 ` VivianNK
2023-10-24 20:34 ` VivianNK
2023-10-25 17:11 ` Michael D Kinney
2023-10-25 18:08 ` Michael D Kinney
2023-10-26 21:08 ` VivianNK
2023-10-27 2:41 ` Michael D Kinney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MW4PR11MB5872AC8EC091EDC8FE19A50D8C1AA@MW4PR11MB5872.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox