]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UnitTestFramewokPkg/SampleUnitTest: Use UT_EXPECT_ASSERT_FAILURE()
authorMichael D Kinney <michael.d.kinney@intel.com>
Thu, 11 Jun 2020 01:14:39 +0000 (18:14 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 15 Jul 2020 05:25:21 +0000 (05:25 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801

Add samples for all UnitTestLib macros including using
UT_EXPECT_ASSERT_FAILURE() for positive test cases where an
ASSERT() is triggered and detected correctly.

Additional test cases are added that disable ASSERT()s and
verify that UT_EXPECT_ASSERT_FAILURE() macros are skipped.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTest.c
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestDxe.inf
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestHost.inf
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestPei.inf
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestSmm.inf
UnitTestFrameworkPkg/Test/UnitTest/Sample/SampleUnitTest/SampleUnitTestUefiShell.inf
UnitTestFrameworkPkg/Test/UnitTestFrameworkPkgHostTest.dsc
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc

index 37d5747bcaae135c4494386f780a60e83d5d0b52..cb50f45391035f2f6b1525adb1f97872a74244ee 100644 (file)
@@ -181,6 +181,466 @@ GlobalPointerShouldBeChangeable (
   return UNIT_TEST_PASSED;\r
 }\r
 \r
+/**\r
+  Unit-Test Test Suite Setup (before) function that enables ASSERT() macros.\r
+**/\r
+VOID\r
+EFIAPI\r
+TestSuiteEnableAsserts (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Set BIT0 (DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED)\r
+  //\r
+  PatchPcdSet8 (PcdDebugPropertyMask, PcdGet8 (PcdDebugPropertyMask) | BIT0);\r
+}\r
+\r
+/**\r
+  Unit-Test Test Suite Setup (before) function that disables ASSERT() macros.\r
+**/\r
+VOID\r
+EFIAPI\r
+TestSuiteDisableAsserts (\r
+  VOID\r
+  )\r
+{\r
+  //\r
+  // Clear BIT0 (DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED)\r
+  //\r
+  PatchPcdSet8 (PcdDebugPropertyMask, PcdGet8 (PcdDebugPropertyMask) & (~BIT0));\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_TRUE() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertTrue (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  UINT64  Result;\r
+\r
+  //\r
+  // This test passes because expression always evaluated to TRUE.\r
+  //\r
+  UT_ASSERT_TRUE (TRUE);\r
+\r
+  //\r
+  // This test passes because expression always evaluates to TRUE.\r
+  //\r
+  Result = LShiftU64 (BIT0, 1);\r
+  UT_ASSERT_TRUE (Result == BIT1);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_FALSE() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertFalse (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  UINT64  Result;\r
+\r
+  //\r
+  // This test passes because expression always evaluated to FALSE.\r
+  //\r
+  UT_ASSERT_FALSE (FALSE);\r
+\r
+  //\r
+  // This test passes because expression always evaluates to FALSE.\r
+  //\r
+  Result = LShiftU64 (BIT0, 1);\r
+  UT_ASSERT_FALSE (Result == BIT0);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_EQUAL() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertEqual (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  UINT64  Result;\r
+\r
+  //\r
+  // This test passes because both values are always equal.\r
+  //\r
+  UT_ASSERT_EQUAL (1, 1);\r
+\r
+  //\r
+  // This test passes because both values are always equal.\r
+  //\r
+  Result = LShiftU64 (BIT0, 1);\r
+  UT_ASSERT_EQUAL (Result, BIT1);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_MEM_EQUAL() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertMemEqual (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  CHAR8  *String1;\r
+  CHAR8  *String2;\r
+  UINTN  Length;\r
+\r
+  //\r
+  // This test passes because String1 and String2 are the same.\r
+  //\r
+  String1 = "Hello";\r
+  String2 = "Hello";\r
+  Length  = sizeof ("Hello");\r
+  UT_ASSERT_MEM_EQUAL (String1, String2, Length);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_NOT_EQUAL() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertNotEqual (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  UINT64  Result;\r
+\r
+  //\r
+  // This test passes because both values are never equal.\r
+  //\r
+  UT_ASSERT_NOT_EQUAL (0, 1);\r
+\r
+  //\r
+  // This test passes because both values are never equal.\r
+  //\r
+  Result = LShiftU64 (BIT0, 1);\r
+  UT_ASSERT_NOT_EQUAL (Result, BIT0);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_NOT_EFI_ERROR() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertNotEfiError (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // This test passes because the status is not an EFI error.\r
+  //\r
+  UT_ASSERT_NOT_EFI_ERROR (EFI_SUCCESS);\r
+\r
+  //\r
+  // This test passes because the status is not an EFI error.\r
+  //\r
+  UT_ASSERT_NOT_EFI_ERROR (EFI_WARN_BUFFER_TOO_SMALL);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_STATUS_EQUAL() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertStatusEqual (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // This test passes because the status value are always equal.\r
+  //\r
+  UT_ASSERT_STATUS_EQUAL (EFI_SUCCESS, EFI_SUCCESS);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_ASSERT_NOT_NULL() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtAssertNotNull (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  UINT64  Result;\r
+\r
+  //\r
+  // This test passes because the pointer is never NULL.\r
+  //\r
+  UT_ASSERT_NOT_NULL (&Result);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_EXPECT_ASSERT_FAILURE() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtExpectAssertFailure (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // This test passes because it directly triggers an ASSERT().\r
+  //\r
+  UT_EXPECT_ASSERT_FAILURE (ASSERT (FALSE), NULL);\r
+\r
+  //\r
+  // This test passes because DecimalToBcd() generates an ASSERT() if the\r
+  // value passed in is >= 100.  The expected ASSERT() is caught by the unit\r
+  // test framework and UT_EXPECT_ASSERT_FAILURE() returns without an error.\r
+  //\r
+  UT_EXPECT_ASSERT_FAILURE (DecimalToBcd8 (101), NULL);\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_LOG_ERROR() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtLogError (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // Example of logging.\r
+  //\r
+  UT_LOG_ERROR ("UT_LOG_ERROR() message\n");\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_LOG_WARNING() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtLogWarning (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // Example of logging.\r
+  //\r
+  UT_LOG_WARNING ("UT_LOG_WARNING() message\n");\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_LOG_INFO() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtLogInfo (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // Example of logging.\r
+  //\r
+  UT_LOG_INFO ("UT_LOG_INFO() message\n");\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
+/**\r
+  Sample unit test using the UT_LOG_VERBOSE() macro.\r
+\r
+  @param[in]  Context    [Optional] An optional parameter that enables:\r
+                         1) test-case reuse with varied parameters and\r
+                         2) test-case re-entry for Target tests that need a\r
+                         reboot.  This parameter is a VOID* and it is the\r
+                         responsibility of the test author to ensure that the\r
+                         contents are well understood by all test cases that may\r
+                         consume it.\r
+\r
+  @retval  UNIT_TEST_PASSED             The Unit test has completed and the test\r
+                                        case was successful.\r
+  @retval  UNIT_TEST_ERROR_TEST_FAILED  A test case assertion has failed.\r
+**/\r
+UNIT_TEST_STATUS\r
+EFIAPI\r
+MacroUtLogVerbose (\r
+  IN UNIT_TEST_CONTEXT  Context\r
+  )\r
+{\r
+  //\r
+  // Example of logging.\r
+  //\r
+  UT_LOG_VERBOSE ("UT_LOG_VERBOSE() message\n");\r
+\r
+  return UNIT_TEST_PASSED;\r
+}\r
+\r
 /**\r
   Initialize the unit test framework, suite, and unit tests for the\r
   sample unit tests and run the unit tests.\r
@@ -199,6 +659,8 @@ UefiTestMain (
   UNIT_TEST_FRAMEWORK_HANDLE  Framework;\r
   UNIT_TEST_SUITE_HANDLE      SimpleMathTests;\r
   UNIT_TEST_SUITE_HANDLE      GlobalVarTests;\r
+  UNIT_TEST_SUITE_HANDLE      MacroTestsAssertsEnabled;\r
+  UNIT_TEST_SUITE_HANDLE      MacroTestsAssertsDisabled;\r
 \r
   Framework = NULL;\r
 \r
@@ -236,6 +698,54 @@ UefiTestMain (
   AddTestCase (GlobalVarTests, "You should be able to change a global BOOLEAN", "Boolean", GlobalBooleanShouldBeChangeable, NULL, NULL, NULL);\r
   AddTestCase (GlobalVarTests, "You should be able to change a global pointer", "Pointer", GlobalPointerShouldBeChangeable, MakeSureThatPointerIsNull, ClearThePointer, NULL);\r
 \r
+  //\r
+  // Populate the Macro Tests with ASSERT() enabled\r
+  //\r
+  Status = CreateUnitTestSuite (&MacroTestsAssertsEnabled, Framework, "Macro Tests with ASSERT() enabled", "Sample.MacroAssertsEnabled", TestSuiteEnableAsserts, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for MacroTestsAssertsEnabled\n"));\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto EXIT;\r
+  }\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_TRUE() macro",           "MacroUtAssertTrue",          MacroUtAssertTrue,          NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_FALSE() macro",          "MacroUtAssertFalse",         MacroUtAssertFalse,         NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_EQUAL() macro",          "MacroUtAssertEqual",         MacroUtAssertEqual,         NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_MEM_EQUAL() macro",      "MacroUtAssertMemEqual",      MacroUtAssertMemEqual,      NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_NOT_EQUAL() macro",      "MacroUtAssertNotEqual",      MacroUtAssertNotEqual,      NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_NOT_EFI_ERROR() macro",  "MacroUtAssertNotEfiError",   MacroUtAssertNotEfiError,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_STATUS_EQUAL() macro",   "MacroUtAssertStatusEqual",   MacroUtAssertStatusEqual,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_NOT_NULL() macro",       "MacroUtAssertNotNull",       MacroUtAssertNotNull,       NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_EXPECT_ASSERT_FAILURE() macro", "MacroUtExpectAssertFailure", MacroUtExpectAssertFailure, NULL, NULL, NULL);\r
+\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_LOG_ERROR() macro",   "MacroUtLogError",   MacroUtLogError,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_LOG_WARNING() macro", "MacroUtLogWarning", MacroUtLogWarning, NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_LOG_INFO() macro",    "MacroUtLogInfo",    MacroUtLogInfo,    NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsEnabled, "Test UT_LOG_VERBOSE() macro", "MacroUtLogVerbose", MacroUtLogVerbose, NULL, NULL, NULL);\r
+\r
+  //\r
+  // Populate the Macro Tests with ASSERT() disabled\r
+  //\r
+  Status = CreateUnitTestSuite (&MacroTestsAssertsDisabled, Framework, "Macro Tests with ASSERT() disabled", "Sample.MacroAssertsDisables", TestSuiteDisableAsserts, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for MacroTestsAssertsDisabled\n"));\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto EXIT;\r
+  }\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_TRUE() macro",           "MacroUtAssertTrue",          MacroUtAssertTrue,          NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_FALSE() macro",          "MacroUtAssertFalse",         MacroUtAssertFalse,         NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_EQUAL() macro",          "MacroUtAssertEqual",         MacroUtAssertEqual,         NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_MEM_EQUAL() macro",      "MacroUtAssertMemEqual",      MacroUtAssertMemEqual,      NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_NOT_EQUAL() macro",      "MacroUtAssertNotEqual",      MacroUtAssertNotEqual,      NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_NOT_EFI_ERROR() macro",  "MacroUtAssertNotEfiError",   MacroUtAssertNotEfiError,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_STATUS_EQUAL() macro",   "MacroUtAssertStatusEqual",   MacroUtAssertStatusEqual,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_NOT_NULL() macro",       "MacroUtAssertNotNull",       MacroUtAssertNotNull,       NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_EXPECT_ASSERT_FAILURE() macro", "MacroUtExpectAssertFailure", MacroUtExpectAssertFailure, NULL, NULL, NULL);\r
+\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_LOG_ERROR() macro",   "MacroUtLogError",   MacroUtLogError,   NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_LOG_WARNING() macro", "MacroUtLogWarning", MacroUtLogWarning, NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_LOG_INFO() macro",    "MacroUtLogInfo",    MacroUtLogInfo,    NULL, NULL, NULL);\r
+  AddTestCase (MacroTestsAssertsDisabled, "Test UT_LOG_VERBOSE() macro", "MacroUtLogVerbose", MacroUtLogVerbose, NULL, NULL, NULL);\r
+\r
   //\r
   // Execute the tests.\r
   //\r
index e253cf6e16dd7c65269d147b722f1b8777554bab..a1b1e53789eba5985ae1344dbe05788ff46ae1c3 100644 (file)
@@ -32,5 +32,8 @@
   UnitTestLib\r
   PrintLib\r
 \r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask\r
+\r
 [Depex]\r
   TRUE\r
index 59a367cc6ed90723fa9941adffdc786b08f0bf54..681165da3b437e5f2d299ee3952fe57463682f2e 100644 (file)
@@ -28,3 +28,6 @@
   BaseLib\r
   DebugLib\r
   UnitTestLib\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask\r
index 60f5252c343706efa4613fc86c5d46057cbfa91f..2565f764a072d1566303641536a70b7445887820 100644 (file)
@@ -32,5 +32,8 @@
   UnitTestLib\r
   PrintLib\r
 \r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask\r
+\r
 [Depex]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r
index 324ad2686e68f102f0975f9023e940e2c1ad3750..f47bc87df31ba747496946c889e6a4066122851f 100644 (file)
@@ -33,5 +33,8 @@
   UnitTestLib\r
   PrintLib\r
 \r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask\r
+\r
 [Depex]\r
   gEfiSmmCpuProtocolGuid\r
index 6e39c229d4db3642fcf9e65e08265a9289831dea..19534e7b1f345d2281889d53013e31cc78dda0d0 100644 (file)
@@ -31,3 +31,6 @@
   DebugLib\r
   UnitTestLib\r
   PrintLib\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask\r
index 70affddead7572b75089c03f5c51da0fb8e95e08..184fdec87acf038278b4b02745c742e4c8469f3c 100644 (file)
@@ -18,6 +18,9 @@
 \r
 !include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc\r
 \r
+[PcdsPatchableInModule]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17\r
+\r
 [Components]\r
   #\r
   # Build HOST_APPLICATION that tests the SampleUnitTest\r
index 0dfd98f2a8620021e623a0ff935e4be92f13e36d..2f0fbfc7cc6c054dd50c4933f39b8d4e9143dcf1 100644 (file)
@@ -20,6 +20,9 @@
 \r
 !include UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc\r
 \r
+[PcdsPatchableInModule]\r
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17\r
+\r
 [Components]\r
   UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.inf\r
   UnitTestFrameworkPkg/Library/UnitTestPersistenceLibNull/UnitTestPersistenceLibNull.inf\r