summaryrefslogtreecommitdiffstats
path: root/MdePkg
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2020-06-10 18:00:37 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-07-15 05:25:21 +0000
commit75e92c13541672a3af349067a040b9dda3d4452d (patch)
tree857d9c99c562b33cd7511c88d7c720969f0d1d29 /MdePkg
parent26824851b041d9e81921ec7ef97220d2a2576157 (diff)
downloadedk2-75e92c13541672a3af349067a040b9dda3d4452d.tar.gz
edk2-75e92c13541672a3af349067a040b9dda3d4452d.tar.bz2
edk2-75e92c13541672a3af349067a040b9dda3d4452d.zip
MdePkg/Include: Hook DebugLib _ASSERT() for unit tests
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2801 Update DebugLib.h _ASSERT() macro to check if unit testing is enabled and call UnitTestDebugAssert() instead of DebugAssert() so the an ASSERT() condition that is triggered by a function under test can be handled by the Unit Test Framework. If EDKII_UNIT_TEST_FRAMEWORK_ENABLED is not defined, then the existing DebugLib behavior is preserved. 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>
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/DebugLib.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h
index baab34bf05..4cacd4b8e2 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -289,12 +289,38 @@ DebugPrintLevelEnabled (
@param Expression Boolean expression that evaluated to FALSE
**/
+#if defined (EDKII_UNIT_TEST_FRAMEWORK_ENABLED)
+/**
+ Unit test library replacement for DebugAssert() in DebugLib.
+
+ If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
+ If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
+
+ @param FileName The pointer to the name of the source file that generated the assert condition.
+ @param LineNumber The line number in the source file that generated the assert condition
+ @param Description The pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+UnitTestDebugAssert (
+ IN CONST CHAR8 *FileName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
+ );
+
+#if defined(__clang__) && defined(__FILE_NAME__)
+#define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, __LINE__, #Expression)
+#else
+#define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, __LINE__, #Expression)
+#endif
+#else
#if defined(__clang__) && defined(__FILE_NAME__)
#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expression)
#else
#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)
#endif
-
+#endif
/**
Internal worker macro that calls DebugPrint().