diff options
author | Vivian Nowka-Keane <vnowkakeane@linux.microsoft.com> | 2023-08-16 14:15:20 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-10-27 00:50:49 +0000 |
commit | a00f7a355ad8e1a84d8087861020d45d6565a8f1 (patch) | |
tree | fc6b169881725eec54ea8d7f8bb7a5c2b20984a1 | |
parent | 716a3292e084b4217790aefa088d4faaa8c1ca8e (diff) | |
download | edk2-a00f7a355ad8e1a84d8087861020d45d6565a8f1.tar.gz edk2-a00f7a355ad8e1a84d8087861020d45d6565a8f1.tar.bz2 edk2-a00f7a355ad8e1a84d8087861020d45d6565a8f1.zip |
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>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
3 files changed, 128 insertions, 93 deletions
diff --git a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGoogleTest.cpp b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGoogleTest.cpp index c9190c8ffd..f66c595a97 100644 --- a/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGoogleTest.cpp +++ b/SecurityPkg/Library/SecureBootVariableLib/GoogleTest/SecureBootVariableLibGoogleTest.cpp @@ -21,154 +21,189 @@ 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 = 0xAB;
- }
+protected:
+ MockUefiRuntimeServicesTableLib RtServicesMock;
+ UINT8 SecureBootMode;
+ EFI_STATUS Status;
+
+ 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));
-
- Status = SetSecureBootMode(SecureBootMode);
- EXPECT_EQ(Status, EFI_SUCCESS);
+ sizeof (SecureBootMode),
+ BufferEq (&SecureBootMode, sizeof (SecureBootMode))
+ )
+ )
+ .WillOnce (Return (EFI_SUCCESS));
+
+ Status = 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 = 0xAB;
- }
+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;
+ }
};
// 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;
-
- void SetUp() override {
- BootEnabledBuffer = (UINT8*) AllocatePool(1);
- ASSERT_NE(BootEnabledBuffer, nullptr);
- }
+protected:
+ UINT8 *BootEnabledBuffer;
+
+ 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/MockPlatformPKProtectionLib.h b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtectionLib.h index 8024f4be29..04288f2b75 100644 --- a/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtectionLib.h +++ b/SecurityPkg/Test/Mock/Include/GoogleTest/Library/MockPlatformPKProtectionLib.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/MockPlatformPKProtectionLib.cpp b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.cpp index 5ea030f6df..6613d5ed19 100644 --- a/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.cpp +++ b/SecurityPkg/Test/Mock/Library/GoogleTest/MockPlatformPKProtectionLib/MockPlatformPKProtectionLib.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);
|