audk/MdePkg/Include
Michael D Kinney 133891b712 MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801

Add the UT_EXPECT_ASSERT_FAILURE(FunctionCall, Status) macro
to the UnitTestLib that can be used to check if a function
under test triggers an ASSERT() condition.  If an ASSERT()
condition is triggered, then the macro returns.  If the
ASSERT() condition is not triggered, then the current unit
test fails with a status of UNIT_TEST_ERROR_TEST_FAILED.

If ASSERT()s are disabled, then this check for ASSERT()
behavior is not possible, and the check is skipped.

The global variable gUnitTestExpectAssertFailureJumpBuffer
is added to the UnitTestLib to save/restore context when
the UT_EXPECT_ASSERT_FAILURE(FunctionCall, Status) macro
is used.  The UT_EXPECT_ASSERT_FAILURE() macro uses the
SetJump() service with this global variable.  The UnitTestLib
service UnitTestDebugAssert() uses the LongJump() service
with this global to restore context if an ASSERT() is
triggered by the code under test.

Add UnitTestExpectAssertFailure() to the UnitTestLib class.
The UnitTestExpectAssertFailure() is called from the new
UT_EXPECT_ASSERT_FAILURE() macro after the status of this
macro check is known.

Add UnitTestDebugAssert() to the UnitTestLib class.  The
UnitTestDebugAssert() service is the same as the DebugLib
DebugAssert() service and is invoked from the DebugLib
_ASSERT() macro if unit testing is enabled.  This allows the
Unit Test Framework to know when code under test triggers an
ASSERT() condition.

Cc: Liming Gao <liming.gao@intel.com>
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>
2020-07-15 05:25:21 +00:00
..
AArch64 MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
Arm MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
Ebc MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
Guid MdePkg: Add FMP Capsule Image Header extension 2020-05-20 14:49:13 +00:00
Ia32 MdePkg Base.h: Use correct style to check macro _MSC_VER value 2020-02-06 09:12:07 +00:00
IndustryStandard MdePkg: Include Acpi header file 2020-06-19 14:59:53 +00:00
Library MdePkg/Include: Add UT_EXPECT_ASSERT_FAILURE() to UnitTestLib 2020-07-15 05:25:21 +00:00
Pi MdePkg: Updates to PI 1.7 Revision numbers 2020-05-15 08:06:09 +00:00
Ppi MdePkg: Added header file for Delayed Dispatch PPI 2020-05-15 08:06:09 +00:00
Protocol MdePkg: Add Serial Terminal Device Type Guid 2020-07-03 01:43:50 +00:00
Register MdePkg/Register: Fix various typos 2020-02-10 22:30:07 +00:00
RiscV64 MdePkg: Add RISC-V RISCV64 binding 2020-05-07 03:17:15 +00:00
Uefi MdePkg: Fix OUT parameters marked as IN OUT 2020-05-20 14:49:13 +00:00
X64 MdePkg Base.h: Use correct style to check macro _MSC_VER value 2020-02-06 09:12:07 +00:00
Base.h MdePkg Base.h: Use correct style to check macro _MSC_VER value 2020-02-06 09:12:07 +00:00
PiDxe.h MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
PiMm.h MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
PiPei.h MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
PiSmm.h MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00
Uefi.h MdePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:13 -07:00