summaryrefslogtreecommitdiff
path: root/UnitTestFrameworkPkg/Test/GoogleTest
diff options
context:
space:
mode:
Diffstat (limited to 'UnitTestFrameworkPkg/Test/GoogleTest')
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp610
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf70
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestExpectFail.cpp668
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestHostExpectFail.inf72
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp108
-rw-r--r--UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf78
6 files changed, 803 insertions, 803 deletions
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp
index 2c2765e1e5..ac83e41d7b 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp
@@ -1,305 +1,305 @@
-/** @file
- This is a sample to demonstrates the use of GoogleTest that supports host
- execution environments.
-
- Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Library/GoogleTestLib.h>
-extern "C" {
- #include <Uefi.h>
- #include <Library/BaseLib.h>
- #include <Library/DebugLib.h>
-}
-
-/**
- Sample unit test that verifies the expected result of an unsigned integer
- addition operation.
-**/
-TEST (SimpleMathTests, OnePlusOneShouldEqualTwo) {
- UINTN A;
- UINTN B;
- UINTN C;
-
- A = 1;
- B = 1;
- C = A + B;
-
- ASSERT_EQ (C, (UINTN)2);
-}
-
-/**
- Sample unit test that verifies that a global BOOLEAN is updatable.
-**/
-class GlobalBooleanVarTests : public ::testing::Test {
-public:
- BOOLEAN SampleGlobalTestBoolean = FALSE;
-};
-
-TEST_F (GlobalBooleanVarTests, GlobalBooleanShouldBeChangeable) {
- SampleGlobalTestBoolean = TRUE;
- ASSERT_TRUE (SampleGlobalTestBoolean);
-
- SampleGlobalTestBoolean = FALSE;
- ASSERT_FALSE (SampleGlobalTestBoolean);
-}
-
-/**
- Sample unit test that logs a warning message and verifies that a global
- pointer is updatable.
-**/
-class GlobalVarTests : public ::testing::Test {
-public:
- VOID *SampleGlobalTestPointer = NULL;
-
-protected:
- void
- SetUp (
- ) override
- {
- ASSERT_EQ ((UINTN)SampleGlobalTestPointer, (UINTN)NULL);
- }
-
- void
- TearDown (
- )
- {
- SampleGlobalTestPointer = NULL;
- }
-};
-
-TEST_F (GlobalVarTests, GlobalPointerShouldBeChangeable) {
- SampleGlobalTestPointer = (VOID *)-1;
- ASSERT_EQ ((UINTN)SampleGlobalTestPointer, (UINTN)((VOID *)-1));
-}
-
-/**
- Set PcdDebugPropertyMask for each MacroTestsAssertsEnabledDisabled test
-**/
-class MacroTestsAssertsEnabledDisabled : public testing::TestWithParam<UINT8> {
- void
- SetUp (
- )
- {
- PatchPcdSet8 (PcdDebugPropertyMask, GetParam ());
- }
-};
-
-/**
- Sample unit test using the ASSERT_TRUE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertTrue) {
- UINT64 Result;
-
- //
- // This test passes because expression always evaluated to TRUE.
- //
- ASSERT_TRUE (TRUE);
-
- //
- // This test passes because expression always evaluates to TRUE.
- //
- Result = LShiftU64 (BIT0, 1);
- ASSERT_TRUE (Result == BIT1);
-}
-
-/**
- Sample unit test using the ASSERT_FALSE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertFalse) {
- UINT64 Result;
-
- //
- // This test passes because expression always evaluated to FALSE.
- //
- ASSERT_FALSE (FALSE);
-
- //
- // This test passes because expression always evaluates to FALSE.
- //
- Result = LShiftU64 (BIT0, 1);
- ASSERT_FALSE (Result == BIT0);
-}
-
-/**
- Sample unit test using the ASSERT_EQ() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertEqual) {
- UINT64 Result;
-
- //
- // This test passes because both values are always equal.
- //
- ASSERT_EQ (1, 1);
-
- //
- // This test passes because both values are always equal.
- //
- Result = LShiftU64 (BIT0, 1);
- ASSERT_EQ (Result, (UINT64)BIT1);
-}
-
-/**
- Sample unit test using the ASSERT_STREQ() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertMemEqual) {
- CHAR8 *String1;
- CHAR8 *String2;
-
- //
- // This test passes because String1 and String2 are the same.
- //
- String1 = (CHAR8 *)"Hello";
- String2 = (CHAR8 *)"Hello";
- ASSERT_STREQ (String1, String2);
-}
-
-/**
- Sample unit test using the ASSERT_NE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEqual) {
- UINT64 Result;
-
- //
- // This test passes because both values are never equal.
- //
- ASSERT_NE (0, 1);
-
- //
- // This test passes because both values are never equal.
- //
- Result = LShiftU64 (BIT0, 1);
- ASSERT_NE (Result, (UINT64)BIT0);
-}
-
-/**
- Sample unit test using the ASSERT_TRUE() and ASSERT(FALSE)
- and EFI_EFFOR() macros to check status
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEfiError) {
- //
- // This test passes because the status is not an EFI error.
- //
- ASSERT_FALSE (EFI_ERROR (EFI_SUCCESS));
-
- //
- // This test passes because the status is not an EFI error.
- //
- ASSERT_FALSE (EFI_ERROR (EFI_WARN_BUFFER_TOO_SMALL));
-}
-
-/**
- Sample unit test using the ASSERT_EQ() macro to compare EFI_STATUS values.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertStatusEqual) {
- //
- // This test passes because the status value are always equal.
- //
- ASSERT_EQ (EFI_SUCCESS, EFI_SUCCESS);
-}
-
-/**
- Sample unit test using ASSERT_NE() macro to make sure a pointer is not NULL.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotNull) {
- UINT64 Result;
-
- //
- // This test passes because the pointer is never NULL.
- //
- ASSERT_NE (&Result, (UINT64 *)NULL);
-}
-
-/**
- Sample unit test using that should not generate any ASSERTs()
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectNoAssertFailure) {
- //
- // This test passes because it never triggers an ASSERT().
- //
- ASSERT (TRUE);
-
- //
- // This test passes because DecimalToBcd() does not ASSERT() if the
- // value passed in is <= 99.
- //
- DecimalToBcd8 (99);
-}
-
-/**
- Sample unit test using the EXPECT_ANY_THROW() macro to test expected ASSERT()s.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectAssertFailure) {
- //
- // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
- //
- if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
- return;
- }
-
- //
- // This test passes because it directly triggers an ASSERT().
- //
- EXPECT_ANY_THROW (ASSERT (FALSE));
-
- //
- // This test passes because DecimalToBcd() generates an ASSERT() if the
- // value passed in is >= 100. The expected ASSERT() is caught by the unit
- // test framework and EXPECT_ANY_THROW() returns without an error.
- //
- EXPECT_ANY_THROW (DecimalToBcd8 (101));
-
- //
- // This test passes because DecimalToBcd() generates an ASSERT() if the
- // value passed in is >= 100. The expected ASSERT() is caught by the unit
- // test framework and throws the C++ exception of type std::runtime_error.
- // EXPECT_THROW() returns without an error.
- //
- EXPECT_THROW (DecimalToBcd8 (101), std::runtime_error);
-
- //
- // This test passes because DecimalToBcd() generates an ASSERT() if the
- // value passed in is >= 100. The expected ASSERT() is caught by the unit
- // test framework and throws the C++ exception of type std::runtime_error with
- // a message that includes the filename, linenumber, and the expression that
- // triggered the ASSERT().
- //
- // EXPECT_THROW_MESSAGE() calls DecimalToBcd() expecting DecimalToBds() to
- // throw a C++ exception of type std::runtime_error with a message that
- // includes the expression of "Value < 100" that triggered the ASSERT().
- //
- EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 100");
-}
-
-INSTANTIATE_TEST_SUITE_P (
- ValidInput,
- MacroTestsAssertsEnabledDisabled,
- ::testing::Values (PcdGet8 (PcdDebugPropertyMask) | BIT0, PcdGet8 (PcdDebugPropertyMask) & (~BIT0))
- );
-
-/**
- Sample unit test using the SCOPED_TRACE() macro for trace messages.
-**/
-TEST (MacroTestsMessages, MacroTraceMessage) {
- //
- // Example of logging.
- //
- SCOPED_TRACE ("SCOPED_TRACE message\n");
-
- //
- // Always pass
- //
- ASSERT_TRUE (TRUE);
-}
-
-int
-main (
- int argc,
- char *argv[]
- )
-{
- testing::InitGoogleTest (&argc, argv);
- return RUN_ALL_TESTS ();
-}
+/** @file
+ This is a sample to demonstrates the use of GoogleTest that supports host
+ execution environments.
+
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/GoogleTestLib.h>
+extern "C" {
+ #include <Uefi.h>
+ #include <Library/BaseLib.h>
+ #include <Library/DebugLib.h>
+}
+
+/**
+ Sample unit test that verifies the expected result of an unsigned integer
+ addition operation.
+**/
+TEST (SimpleMathTests, OnePlusOneShouldEqualTwo) {
+ UINTN A;
+ UINTN B;
+ UINTN C;
+
+ A = 1;
+ B = 1;
+ C = A + B;
+
+ ASSERT_EQ (C, (UINTN)2);
+}
+
+/**
+ Sample unit test that verifies that a global BOOLEAN is updatable.
+**/
+class GlobalBooleanVarTests : public ::testing::Test {
+public:
+ BOOLEAN SampleGlobalTestBoolean = FALSE;
+};
+
+TEST_F (GlobalBooleanVarTests, GlobalBooleanShouldBeChangeable) {
+ SampleGlobalTestBoolean = TRUE;
+ ASSERT_TRUE (SampleGlobalTestBoolean);
+
+ SampleGlobalTestBoolean = FALSE;
+ ASSERT_FALSE (SampleGlobalTestBoolean);
+}
+
+/**
+ Sample unit test that logs a warning message and verifies that a global
+ pointer is updatable.
+**/
+class GlobalVarTests : public ::testing::Test {
+public:
+ VOID *SampleGlobalTestPointer = NULL;
+
+protected:
+ void
+ SetUp (
+ ) override
+ {
+ ASSERT_EQ ((UINTN)SampleGlobalTestPointer, (UINTN)NULL);
+ }
+
+ void
+ TearDown (
+ )
+ {
+ SampleGlobalTestPointer = NULL;
+ }
+};
+
+TEST_F (GlobalVarTests, GlobalPointerShouldBeChangeable) {
+ SampleGlobalTestPointer = (VOID *)-1;
+ ASSERT_EQ ((UINTN)SampleGlobalTestPointer, (UINTN)((VOID *)-1));
+}
+
+/**
+ Set PcdDebugPropertyMask for each MacroTestsAssertsEnabledDisabled test
+**/
+class MacroTestsAssertsEnabledDisabled : public testing::TestWithParam<UINT8> {
+ void
+ SetUp (
+ )
+ {
+ PatchPcdSet8 (PcdDebugPropertyMask, GetParam ());
+ }
+};
+
+/**
+ Sample unit test using the ASSERT_TRUE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertTrue) {
+ UINT64 Result;
+
+ //
+ // This test passes because expression always evaluated to TRUE.
+ //
+ ASSERT_TRUE (TRUE);
+
+ //
+ // This test passes because expression always evaluates to TRUE.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ ASSERT_TRUE (Result == BIT1);
+}
+
+/**
+ Sample unit test using the ASSERT_FALSE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertFalse) {
+ UINT64 Result;
+
+ //
+ // This test passes because expression always evaluated to FALSE.
+ //
+ ASSERT_FALSE (FALSE);
+
+ //
+ // This test passes because expression always evaluates to FALSE.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ ASSERT_FALSE (Result == BIT0);
+}
+
+/**
+ Sample unit test using the ASSERT_EQ() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertEqual) {
+ UINT64 Result;
+
+ //
+ // This test passes because both values are always equal.
+ //
+ ASSERT_EQ (1, 1);
+
+ //
+ // This test passes because both values are always equal.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ ASSERT_EQ (Result, (UINT64)BIT1);
+}
+
+/**
+ Sample unit test using the ASSERT_STREQ() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertMemEqual) {
+ CHAR8 *String1;
+ CHAR8 *String2;
+
+ //
+ // This test passes because String1 and String2 are the same.
+ //
+ String1 = (CHAR8 *)"Hello";
+ String2 = (CHAR8 *)"Hello";
+ ASSERT_STREQ (String1, String2);
+}
+
+/**
+ Sample unit test using the ASSERT_NE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEqual) {
+ UINT64 Result;
+
+ //
+ // This test passes because both values are never equal.
+ //
+ ASSERT_NE (0, 1);
+
+ //
+ // This test passes because both values are never equal.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ ASSERT_NE (Result, (UINT64)BIT0);
+}
+
+/**
+ Sample unit test using the ASSERT_TRUE() and ASSERT(FALSE)
+ and EFI_EFFOR() macros to check status
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEfiError) {
+ //
+ // This test passes because the status is not an EFI error.
+ //
+ ASSERT_FALSE (EFI_ERROR (EFI_SUCCESS));
+
+ //
+ // This test passes because the status is not an EFI error.
+ //
+ ASSERT_FALSE (EFI_ERROR (EFI_WARN_BUFFER_TOO_SMALL));
+}
+
+/**
+ Sample unit test using the ASSERT_EQ() macro to compare EFI_STATUS values.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertStatusEqual) {
+ //
+ // This test passes because the status value are always equal.
+ //
+ ASSERT_EQ (EFI_SUCCESS, EFI_SUCCESS);
+}
+
+/**
+ Sample unit test using ASSERT_NE() macro to make sure a pointer is not NULL.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotNull) {
+ UINT64 Result;
+
+ //
+ // This test passes because the pointer is never NULL.
+ //
+ ASSERT_NE (&Result, (UINT64 *)NULL);
+}
+
+/**
+ Sample unit test using that should not generate any ASSERTs()
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectNoAssertFailure) {
+ //
+ // This test passes because it never triggers an ASSERT().
+ //
+ ASSERT (TRUE);
+
+ //
+ // This test passes because DecimalToBcd() does not ASSERT() if the
+ // value passed in is <= 99.
+ //
+ DecimalToBcd8 (99);
+}
+
+/**
+ Sample unit test using the EXPECT_ANY_THROW() macro to test expected ASSERT()s.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectAssertFailure) {
+ //
+ // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
+ //
+ if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
+ return;
+ }
+
+ //
+ // This test passes because it directly triggers an ASSERT().
+ //
+ EXPECT_ANY_THROW (ASSERT (FALSE));
+
+ //
+ // This test passes because DecimalToBcd() generates an ASSERT() if the
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit
+ // test framework and EXPECT_ANY_THROW() returns without an error.
+ //
+ EXPECT_ANY_THROW (DecimalToBcd8 (101));
+
+ //
+ // This test passes because DecimalToBcd() generates an ASSERT() if the
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit
+ // test framework and throws the C++ exception of type std::runtime_error.
+ // EXPECT_THROW() returns without an error.
+ //
+ EXPECT_THROW (DecimalToBcd8 (101), std::runtime_error);
+
+ //
+ // This test passes because DecimalToBcd() generates an ASSERT() if the
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit
+ // test framework and throws the C++ exception of type std::runtime_error with
+ // a message that includes the filename, linenumber, and the expression that
+ // triggered the ASSERT().
+ //
+ // EXPECT_THROW_MESSAGE() calls DecimalToBcd() expecting DecimalToBds() to
+ // throw a C++ exception of type std::runtime_error with a message that
+ // includes the expression of "Value < 100" that triggered the ASSERT().
+ //
+ EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 100");
+}
+
+INSTANTIATE_TEST_SUITE_P (
+ ValidInput,
+ MacroTestsAssertsEnabledDisabled,
+ ::testing::Values (PcdGet8 (PcdDebugPropertyMask) | BIT0, PcdGet8 (PcdDebugPropertyMask) & (~BIT0))
+ );
+
+/**
+ Sample unit test using the SCOPED_TRACE() macro for trace messages.
+**/
+TEST (MacroTestsMessages, MacroTraceMessage) {
+ //
+ // Example of logging.
+ //
+ SCOPED_TRACE ("SCOPED_TRACE message\n");
+
+ //
+ // Always pass
+ //
+ ASSERT_TRUE (TRUE);
+}
+
+int
+main (
+ int argc,
+ char *argv[]
+ )
+{
+ testing::InitGoogleTest (&argc, argv);
+ return RUN_ALL_TESTS ();
+}
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf
index 37e7c86910..e3cf9f6875 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf
@@ -1,35 +1,35 @@
-## @file
-# This is a sample to demonstrates the use of GoogleTest that supports host
-# execution environments.
-#
-# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SampleGoogleTestHost
- FILE_GUID = 7D8BBFBB-7977-4AEE-A59F-257BF5C2F87C
- MODULE_TYPE = HOST_APPLICATION
- VERSION_STRING = 1.0
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- SampleGoogleTest.cpp
-
-[Packages]
- MdePkg/MdePkg.dec
- UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
-
-[LibraryClasses]
- GoogleTestLib
- BaseLib
- DebugLib
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
+## @file
+# This is a sample to demonstrates the use of GoogleTest that supports host
+# execution environments.
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SampleGoogleTestHost
+ FILE_GUID = 7D8BBFBB-7977-4AEE-A59F-257BF5C2F87C
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ SampleGoogleTest.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+ BaseLib
+ DebugLib
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestExpectFail.cpp b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestExpectFail.cpp
index bb0e183305..6ecf4b92ce 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestExpectFail.cpp
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestExpectFail.cpp
@@ -1,334 +1,334 @@
-/** @file
- This is a sample to demonstrates the use of GoogleTest that supports host
- execution environments for test case that are always expected to fail to
- demonstrate the format of the log file and reports when failures occur.
-
- Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Library/GoogleTestLib.h>
-extern "C" {
- #include <Uefi.h>
- #include <Library/BaseLib.h>
- #include <Library/DebugLib.h>
-}
-
-/**
- Sample unit test that verifies the expected result of an unsigned integer
- addition operation.
-**/
-TEST (SimpleMathTests, OnePlusOneShouldEqualTwo) {
- UINTN A;
- UINTN B;
- UINTN C;
-
- A = 1;
- B = 1;
- C = A + B;
-
- ASSERT_NE (C, (UINTN)2);
-}
-
-/**
- Sample unit test that verifies that a global BOOLEAN is updatable.
-**/
-class GlobalBooleanVarTests : public ::testing::Test {
-public:
- BOOLEAN SampleGlobalTestBoolean = FALSE;
-};
-
-TEST_F (GlobalBooleanVarTests, GlobalBooleanShouldBeChangeable) {
- SampleGlobalTestBoolean = TRUE;
- EXPECT_FALSE (SampleGlobalTestBoolean);
-
- SampleGlobalTestBoolean = FALSE;
- EXPECT_TRUE (SampleGlobalTestBoolean);
-}
-
-/**
- Sample unit test that logs a warning message and verifies that a global
- pointer is updatable.
-**/
-class GlobalVarTests : public ::testing::Test {
-public:
- VOID *SampleGlobalTestPointer = NULL;
-
-protected:
- void
- SetUp (
- ) override
- {
- ASSERT_NE ((UINTN)SampleGlobalTestPointer, (UINTN)NULL);
- }
-
- void
- TearDown (
- )
- {
- SampleGlobalTestPointer = NULL;
- }
-};
-
-TEST_F (GlobalVarTests, GlobalPointerShouldBeChangeable) {
- SampleGlobalTestPointer = (VOID *)-1;
- ASSERT_NE ((UINTN)SampleGlobalTestPointer, (UINTN)((VOID *)-1));
-}
-
-/**
- Set PcdDebugPropertyMask for each MacroTestsAssertsEnabledDisabled test
-**/
-class MacroTestsAssertsEnabledDisabled : public testing::TestWithParam<UINT8> {
- void
- SetUp (
- )
- {
- PatchPcdSet8 (PcdDebugPropertyMask, GetParam ());
- }
-};
-
-/**
- Sample unit test using the ASSERT_TRUE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertTrue) {
- UINT64 Result;
-
- //
- // This test passes because expression always evaluated to TRUE.
- //
- EXPECT_FALSE (TRUE);
-
- //
- // This test passes because expression always evaluates to TRUE.
- //
- Result = LShiftU64 (BIT0, 1);
- EXPECT_FALSE (Result == BIT1);
-}
-
-/**
- Sample unit test using the ASSERT_FALSE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertFalse) {
- UINT64 Result;
-
- //
- // This test passes because expression always evaluated to FALSE.
- //
- EXPECT_TRUE (FALSE);
-
- //
- // This test passes because expression always evaluates to FALSE.
- //
- Result = LShiftU64 (BIT0, 1);
- EXPECT_TRUE (Result == BIT0);
-}
-
-/**
- Sample unit test using the ASSERT_EQ() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertEqual) {
- UINT64 Result;
-
- //
- // This test passes because both values are always equal.
- //
- EXPECT_NE (1, 1);
-
- //
- // This test passes because both values are always equal.
- //
- Result = LShiftU64 (BIT0, 1);
- EXPECT_NE (Result, (UINT64)BIT1);
-}
-
-/**
- Sample unit test using the ASSERT_STREQ() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertMemEqual) {
- CHAR8 *String1;
- CHAR8 *String2;
-
- //
- // This test passes because String1 and String2 are the same.
- //
- String1 = (CHAR8 *)"Hello";
- String2 = (CHAR8 *)"Hello";
- EXPECT_STRNE (String1, String2);
-}
-
-/**
- Sample unit test using the ASSERT_NE() macro.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEqual) {
- UINT64 Result;
-
- //
- // This test passes because both values are never equal.
- //
- EXPECT_EQ (0, 1);
-
- //
- // This test passes because both values are never equal.
- //
- Result = LShiftU64 (BIT0, 1);
- EXPECT_EQ (Result, (UINT64)BIT0);
-}
-
-/**
- Sample unit test using the ASSERT_TRUE() and ASSERT(FALSE)
- and EFI_EFFOR() macros to check status
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEfiError) {
- //
- // This test passes because the status is not an EFI error.
- //
- EXPECT_TRUE (EFI_ERROR (EFI_SUCCESS));
-
- //
- // This test passes because the status is not an EFI error.
- //
- EXPECT_TRUE (EFI_ERROR (EFI_WARN_BUFFER_TOO_SMALL));
-}
-
-/**
- Sample unit test using the ASSERT_EQ() macro to compare EFI_STATUS values.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertStatusEqual) {
- //
- // This test passes because the status value are always equal.
- //
- EXPECT_NE (EFI_SUCCESS, EFI_SUCCESS);
-}
-
-/**
- Sample unit test using ASSERT_NE() macro to make sure a pointer is not NULL.
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotNull) {
- UINT64 Result;
-
- //
- // This test passes because the pointer is never NULL.
- //
- EXPECT_EQ (&Result, (UINT64 *)NULL);
-}
-
-/**
- Sample unit test using that generates an unexpected ASSERT
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroDirectForceAssertExpectTestFail) {
- //
- // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
- //
- if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
- EXPECT_TRUE (FALSE);
- return;
- }
-
- //
- // This test fails because it directly triggers an ASSERT().
- //
- ASSERT (FALSE);
-}
-
-/**
- Sample unit test using that generates an unexpected ASSERT
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroIndirectForceAssertExpectTestFail) {
- //
- // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
- //
- if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
- EXPECT_TRUE (FALSE);
- return;
- }
-
- //
- // This test fails because DecimalToBcd() generates an ASSERT() if the
- // value passed in is >= 100. The unexpected ASSERT() is caught by the unit
- // test framework and generates a failed test.
- //
- DecimalToBcd8 (101);
-}
-
-/**
- Sample unit test using that do not generate an expected ASSERT()
-**/
-TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectedAssertNotTriggeredExpectTestFail) {
- //
- // When ASSERT()s are disabled, all tests for ASSERT()s will fail.
- //
- if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
- EXPECT_ANY_THROW (ASSERT (TRUE));
- EXPECT_ANY_THROW (DecimalToBcd8 (99));
- EXPECT_ANY_THROW (DecimalToBcd8 (101));
- EXPECT_THROW (DecimalToBcd8 (99), std::runtime_error);
- EXPECT_THROW (DecimalToBcd8 (101), std::runtime_error);
- EXPECT_THROW (DecimalToBcd8 (99), std::overflow_error);
- EXPECT_THROW (DecimalToBcd8 (101), std::overflow_error);
- EXPECT_THROW_MESSAGE (DecimalToBcd8 (99), "Value < 999");
- EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 999");
- return;
- }
-
- //
- // This test fails because ASSERT(TRUE) never triggers an ASSERT().
- //
- EXPECT_ANY_THROW (ASSERT (TRUE));
-
- //
- // This test fails because DecimalToBcd() does not generate an ASSERT() if the
- // value passed in is < 100.
- //
- EXPECT_ANY_THROW (DecimalToBcd8 (99));
-
- //
- // This test fails because DecimalToBcd() does not generate an ASSERT() if the
- // value passed in is < 100.
- //
- EXPECT_THROW (DecimalToBcd8 (99), std::runtime_error);
-
- //
- // This test fails because DecimalToBcd() does generate an ASSERT() if the
- // value passed in is >= 100, but is generates a C++ exception of type
- // std::runtime_error
- //
- EXPECT_THROW (DecimalToBcd8 (101), std::overflow_error);
-
- //
- // This test fails because DecimalToBcd() generates an ASSERT() if the
- // value passed in is >= 100. The expected ASSERT() is caught by the unit
- // test framework and throws the C++ exception of type std::runtime_error with
- // a message that includes the filename, linenumber, and the expression that
- // triggered the ASSERT(). The message generated by BcdToDecimal() is
- // "Value < 100", but the expression tested is not "Value < 100".
- //
- EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 999");
-}
-
-INSTANTIATE_TEST_SUITE_P (
- ValidInput,
- MacroTestsAssertsEnabledDisabled,
- ::testing::Values (PcdGet8 (PcdDebugPropertyMask) | BIT0, PcdGet8 (PcdDebugPropertyMask) & (~BIT0))
- );
-
-/**
- Sample unit test using the SCOPED_TRACE() macro for trace messages.
-**/
-TEST (MacroTestsMessages, MacroTraceMessage) {
- //
- // Example of logging.
- //
- SCOPED_TRACE ("SCOPED_TRACE message\n");
- EXPECT_TRUE (FALSE);
-}
-
-int
-main (
- int argc,
- char *argv[]
- )
-{
- testing::InitGoogleTest (&argc, argv);
- return RUN_ALL_TESTS ();
-}
+/** @file
+ This is a sample to demonstrates the use of GoogleTest that supports host
+ execution environments for test case that are always expected to fail to
+ demonstrate the format of the log file and reports when failures occur.
+
+ Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/GoogleTestLib.h>
+extern "C" {
+ #include <Uefi.h>
+ #include <Library/BaseLib.h>
+ #include <Library/DebugLib.h>
+}
+
+/**
+ Sample unit test that verifies the expected result of an unsigned integer
+ addition operation.
+**/
+TEST (SimpleMathTests, OnePlusOneShouldEqualTwo) {
+ UINTN A;
+ UINTN B;
+ UINTN C;
+
+ A = 1;
+ B = 1;
+ C = A + B;
+
+ ASSERT_NE (C, (UINTN)2);
+}
+
+/**
+ Sample unit test that verifies that a global BOOLEAN is updatable.
+**/
+class GlobalBooleanVarTests : public ::testing::Test {
+public:
+ BOOLEAN SampleGlobalTestBoolean = FALSE;
+};
+
+TEST_F (GlobalBooleanVarTests, GlobalBooleanShouldBeChangeable) {
+ SampleGlobalTestBoolean = TRUE;
+ EXPECT_FALSE (SampleGlobalTestBoolean);
+
+ SampleGlobalTestBoolean = FALSE;
+ EXPECT_TRUE (SampleGlobalTestBoolean);
+}
+
+/**
+ Sample unit test that logs a warning message and verifies that a global
+ pointer is updatable.
+**/
+class GlobalVarTests : public ::testing::Test {
+public:
+ VOID *SampleGlobalTestPointer = NULL;
+
+protected:
+ void
+ SetUp (
+ ) override
+ {
+ ASSERT_NE ((UINTN)SampleGlobalTestPointer, (UINTN)NULL);
+ }
+
+ void
+ TearDown (
+ )
+ {
+ SampleGlobalTestPointer = NULL;
+ }
+};
+
+TEST_F (GlobalVarTests, GlobalPointerShouldBeChangeable) {
+ SampleGlobalTestPointer = (VOID *)-1;
+ ASSERT_NE ((UINTN)SampleGlobalTestPointer, (UINTN)((VOID *)-1));
+}
+
+/**
+ Set PcdDebugPropertyMask for each MacroTestsAssertsEnabledDisabled test
+**/
+class MacroTestsAssertsEnabledDisabled : public testing::TestWithParam<UINT8> {
+ void
+ SetUp (
+ )
+ {
+ PatchPcdSet8 (PcdDebugPropertyMask, GetParam ());
+ }
+};
+
+/**
+ Sample unit test using the ASSERT_TRUE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertTrue) {
+ UINT64 Result;
+
+ //
+ // This test passes because expression always evaluated to TRUE.
+ //
+ EXPECT_FALSE (TRUE);
+
+ //
+ // This test passes because expression always evaluates to TRUE.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ EXPECT_FALSE (Result == BIT1);
+}
+
+/**
+ Sample unit test using the ASSERT_FALSE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertFalse) {
+ UINT64 Result;
+
+ //
+ // This test passes because expression always evaluated to FALSE.
+ //
+ EXPECT_TRUE (FALSE);
+
+ //
+ // This test passes because expression always evaluates to FALSE.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ EXPECT_TRUE (Result == BIT0);
+}
+
+/**
+ Sample unit test using the ASSERT_EQ() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertEqual) {
+ UINT64 Result;
+
+ //
+ // This test passes because both values are always equal.
+ //
+ EXPECT_NE (1, 1);
+
+ //
+ // This test passes because both values are always equal.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ EXPECT_NE (Result, (UINT64)BIT1);
+}
+
+/**
+ Sample unit test using the ASSERT_STREQ() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertMemEqual) {
+ CHAR8 *String1;
+ CHAR8 *String2;
+
+ //
+ // This test passes because String1 and String2 are the same.
+ //
+ String1 = (CHAR8 *)"Hello";
+ String2 = (CHAR8 *)"Hello";
+ EXPECT_STRNE (String1, String2);
+}
+
+/**
+ Sample unit test using the ASSERT_NE() macro.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEqual) {
+ UINT64 Result;
+
+ //
+ // This test passes because both values are never equal.
+ //
+ EXPECT_EQ (0, 1);
+
+ //
+ // This test passes because both values are never equal.
+ //
+ Result = LShiftU64 (BIT0, 1);
+ EXPECT_EQ (Result, (UINT64)BIT0);
+}
+
+/**
+ Sample unit test using the ASSERT_TRUE() and ASSERT(FALSE)
+ and EFI_EFFOR() macros to check status
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotEfiError) {
+ //
+ // This test passes because the status is not an EFI error.
+ //
+ EXPECT_TRUE (EFI_ERROR (EFI_SUCCESS));
+
+ //
+ // This test passes because the status is not an EFI error.
+ //
+ EXPECT_TRUE (EFI_ERROR (EFI_WARN_BUFFER_TOO_SMALL));
+}
+
+/**
+ Sample unit test using the ASSERT_EQ() macro to compare EFI_STATUS values.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertStatusEqual) {
+ //
+ // This test passes because the status value are always equal.
+ //
+ EXPECT_NE (EFI_SUCCESS, EFI_SUCCESS);
+}
+
+/**
+ Sample unit test using ASSERT_NE() macro to make sure a pointer is not NULL.
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroAssertNotNull) {
+ UINT64 Result;
+
+ //
+ // This test passes because the pointer is never NULL.
+ //
+ EXPECT_EQ (&Result, (UINT64 *)NULL);
+}
+
+/**
+ Sample unit test using that generates an unexpected ASSERT
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroDirectForceAssertExpectTestFail) {
+ //
+ // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
+ //
+ if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
+ EXPECT_TRUE (FALSE);
+ return;
+ }
+
+ //
+ // This test fails because it directly triggers an ASSERT().
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Sample unit test using that generates an unexpected ASSERT
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroIndirectForceAssertExpectTestFail) {
+ //
+ // Skip tests that verify an ASSERT() is triggered if ASSERT()s are disabled.
+ //
+ if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
+ EXPECT_TRUE (FALSE);
+ return;
+ }
+
+ //
+ // This test fails because DecimalToBcd() generates an ASSERT() if the
+ // value passed in is >= 100. The unexpected ASSERT() is caught by the unit
+ // test framework and generates a failed test.
+ //
+ DecimalToBcd8 (101);
+}
+
+/**
+ Sample unit test using that do not generate an expected ASSERT()
+**/
+TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectedAssertNotTriggeredExpectTestFail) {
+ //
+ // When ASSERT()s are disabled, all tests for ASSERT()s will fail.
+ //
+ if ((PcdGet8 (PcdDebugPropertyMask) & BIT0) == 0x00) {
+ EXPECT_ANY_THROW (ASSERT (TRUE));
+ EXPECT_ANY_THROW (DecimalToBcd8 (99));
+ EXPECT_ANY_THROW (DecimalToBcd8 (101));
+ EXPECT_THROW (DecimalToBcd8 (99), std::runtime_error);
+ EXPECT_THROW (DecimalToBcd8 (101), std::runtime_error);
+ EXPECT_THROW (DecimalToBcd8 (99), std::overflow_error);
+ EXPECT_THROW (DecimalToBcd8 (101), std::overflow_error);
+ EXPECT_THROW_MESSAGE (DecimalToBcd8 (99), "Value < 999");
+ EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 999");
+ return;
+ }
+
+ //
+ // This test fails because ASSERT(TRUE) never triggers an ASSERT().
+ //
+ EXPECT_ANY_THROW (ASSERT (TRUE));
+
+ //
+ // This test fails because DecimalToBcd() does not generate an ASSERT() if the
+ // value passed in is < 100.
+ //
+ EXPECT_ANY_THROW (DecimalToBcd8 (99));
+
+ //
+ // This test fails because DecimalToBcd() does not generate an ASSERT() if the
+ // value passed in is < 100.
+ //
+ EXPECT_THROW (DecimalToBcd8 (99), std::runtime_error);
+
+ //
+ // This test fails because DecimalToBcd() does generate an ASSERT() if the
+ // value passed in is >= 100, but is generates a C++ exception of type
+ // std::runtime_error
+ //
+ EXPECT_THROW (DecimalToBcd8 (101), std::overflow_error);
+
+ //
+ // This test fails because DecimalToBcd() generates an ASSERT() if the
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit
+ // test framework and throws the C++ exception of type std::runtime_error with
+ // a message that includes the filename, linenumber, and the expression that
+ // triggered the ASSERT(). The message generated by BcdToDecimal() is
+ // "Value < 100", but the expression tested is not "Value < 100".
+ //
+ EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 999");
+}
+
+INSTANTIATE_TEST_SUITE_P (
+ ValidInput,
+ MacroTestsAssertsEnabledDisabled,
+ ::testing::Values (PcdGet8 (PcdDebugPropertyMask) | BIT0, PcdGet8 (PcdDebugPropertyMask) & (~BIT0))
+ );
+
+/**
+ Sample unit test using the SCOPED_TRACE() macro for trace messages.
+**/
+TEST (MacroTestsMessages, MacroTraceMessage) {
+ //
+ // Example of logging.
+ //
+ SCOPED_TRACE ("SCOPED_TRACE message\n");
+ EXPECT_TRUE (FALSE);
+}
+
+int
+main (
+ int argc,
+ char *argv[]
+ )
+{
+ testing::InitGoogleTest (&argc, argv);
+ return RUN_ALL_TESTS ();
+}
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestHostExpectFail.inf b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestHostExpectFail.inf
index af3d254025..ffdea8ba89 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestHostExpectFail.inf
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestExpectFail/SampleGoogleTestHostExpectFail.inf
@@ -1,36 +1,36 @@
-## @file
-# This is a sample to demonstrates the use of GoogleTest that supports host
-# execution environments for test case that are always expected to fail to
-# demonstrate the format of the log file and reports when failures occur.
-#
-# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SampleGoogleTestHostExpectFail
- FILE_GUID = 6042ADD2-E024-4FD5-8CD7-B2A146BF88D7
- MODULE_TYPE = HOST_APPLICATION
- VERSION_STRING = 1.0
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- SampleGoogleTestExpectFail.cpp
-
-[Packages]
- MdePkg/MdePkg.dec
- UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
-
-[LibraryClasses]
- GoogleTestLib
- BaseLib
- DebugLib
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
+## @file
+# This is a sample to demonstrates the use of GoogleTest that supports host
+# execution environments for test case that are always expected to fail to
+# demonstrate the format of the log file and reports when failures occur.
+#
+# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SampleGoogleTestHostExpectFail
+ FILE_GUID = 6042ADD2-E024-4FD5-8CD7-B2A146BF88D7
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ SampleGoogleTestExpectFail.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+ BaseLib
+ DebugLib
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp
index 6e62bd79ff..203bfb2d34 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp
@@ -1,54 +1,54 @@
-/** @file
- This is a sample to demonstrates the use of GoogleTest that supports host
- execution environments for test case that generates an exception. For some
- host-based environments, this is a fatal condition that terminates the unit
- tests and no additional test cases are executed. On other environments, this
- condition may be report a unit test failure and continue with additional unit
- tests.
-
- Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Library/GoogleTestLib.h>
-extern "C" {
- #include <Uefi.h>
- #include <Library/BaseLib.h>
- #include <Library/DebugLib.h>
-}
-
-UINTN
-DivideWithNoParameterChecking (
- UINTN Dividend,
- UINTN Divisor
- )
-{
- //
- // Perform integer division with no check for divide by zero
- //
- return (Dividend / Divisor);
-}
-
-/**
- Sample unit test that generates an unexpected exception
-**/
-TEST (ExceptionTest, GenerateExceptionExpectTestFail) {
- //
- // Assertion that passes without generating an exception
- //
- EXPECT_EQ (DivideWithNoParameterChecking (20, 1), (UINTN)20);
- //
- // Assertion that generates divide by zero exception before result evaluated
- //
- EXPECT_EQ (DivideWithNoParameterChecking (20, 0), MAX_UINTN);
-}
-
-int
-main (
- int argc,
- char *argv[]
- )
-{
- testing::InitGoogleTest (&argc, argv);
- return RUN_ALL_TESTS ();
-}
+/** @file
+ This is a sample to demonstrates the use of GoogleTest that supports host
+ execution environments for test case that generates an exception. For some
+ host-based environments, this is a fatal condition that terminates the unit
+ tests and no additional test cases are executed. On other environments, this
+ condition may be report a unit test failure and continue with additional unit
+ tests.
+
+ Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/GoogleTestLib.h>
+extern "C" {
+ #include <Uefi.h>
+ #include <Library/BaseLib.h>
+ #include <Library/DebugLib.h>
+}
+
+UINTN
+DivideWithNoParameterChecking (
+ UINTN Dividend,
+ UINTN Divisor
+ )
+{
+ //
+ // Perform integer division with no check for divide by zero
+ //
+ return (Dividend / Divisor);
+}
+
+/**
+ Sample unit test that generates an unexpected exception
+**/
+TEST (ExceptionTest, GenerateExceptionExpectTestFail) {
+ //
+ // Assertion that passes without generating an exception
+ //
+ EXPECT_EQ (DivideWithNoParameterChecking (20, 1), (UINTN)20);
+ //
+ // Assertion that generates divide by zero exception before result evaluated
+ //
+ EXPECT_EQ (DivideWithNoParameterChecking (20, 0), MAX_UINTN);
+}
+
+int
+main (
+ int argc,
+ char *argv[]
+ )
+{
+ testing::InitGoogleTest (&argc, argv);
+ return RUN_ALL_TESTS ();
+}
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf
index 3ce356c8ce..7c53869b09 100644
--- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf
+++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf
@@ -1,39 +1,39 @@
-## @file
-# This is a sample to demonstrates the use of GoogleTest that supports host
-# execution environments for test case that generates an exception. For some
-# host-based environments, this is a fatal condition that terminates the unit
-# tests and no additional test cases are executed. On other environments, this
-# condition may be report a unit test failure and continue with additional unit
-# tests.
-#
-# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SampleGoogleTestHostGenerateException
- FILE_GUID = 037A3C56-44C5-4899-AC4D-911943E6FBA1
- MODULE_TYPE = HOST_APPLICATION
- VERSION_STRING = 1.0
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- SampleGoogleTestGenerateException.cpp
-
-[Packages]
- MdePkg/MdePkg.dec
- UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
-
-[LibraryClasses]
- GoogleTestLib
- BaseLib
- DebugLib
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
+## @file
+# This is a sample to demonstrates the use of GoogleTest that supports host
+# execution environments for test case that generates an exception. For some
+# host-based environments, this is a fatal condition that terminates the unit
+# tests and no additional test cases are executed. On other environments, this
+# condition may be report a unit test failure and continue with additional unit
+# tests.
+#
+# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SampleGoogleTestHostGenerateException
+ FILE_GUID = 037A3C56-44C5-4899-AC4D-911943E6FBA1
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ SampleGoogleTestGenerateException.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+ BaseLib
+ DebugLib
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask