16extern BASE_LIBRARY_JUMP_BUFFER gUnitTestJumpBuffer;
29 if ((UnitTest ==
NULL) || (FailureMessage ==
NULL)) {
30 return EFI_INVALID_PARAMETER;
33 UnitTest->FailureType = FailureType;
35 &UnitTest->FailureMessage[0],
52 UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle;
59 FrameworkHandle = GetActiveFrameworkHandle ();
60 if (FrameworkHandle ==
NULL) {
61 DEBUG ((DEBUG_ERROR,
"%a - FrameworkHandle not initialized\n", __func__));
69 AsciiVSPrint (LogString,
sizeof (LogString), Format, Marker);
105 IN BOOLEAN Expression,
114 "[ASSERT FAIL] %a:%d: Expression (%a) is not TRUE!\n",
120 FAILURETYPE_ASSERTTRUE,
121 "%a:%d: Expression (%a) is not TRUE!\n",
152 IN BOOLEAN Expression,
161 "[ASSERT FAIL] %a:%d: Expression (%a) is not FALSE!\n",
167 FAILURETYPE_ASSERTFALSE,
168 "%a:%d: Expression(%a) is not FALSE!\n",
206 if (EFI_ERROR (Status)) {
208 "[ASSERT FAIL] %a:%d: Status '%a' is EFI_ERROR (%r)!\n",
215 FAILURETYPE_ASSERTNOTEFIERROR,
216 "%a:%d: Status '%a' is EFI_ERROR (%r)!\n",
224 return !EFI_ERROR (Status);
260 if (ValueA != ValueB) {
262 "[ASSERT FAIL] %a:%d: Value %a != %a (%d != %d)!\n",
271 FAILURETYPE_ASSERTEQUAL,
272 "%a:%d: Value %a != %a (%d != %d)!\n",
282 return (ValueA == ValueB);
323 if (
CompareMem (BufferA, BufferB, Length) != 0) {
325 "[ASSERT FAIL] %a:%d: Value %a != %a for length %d bytes!\n",
333 FAILURETYPE_ASSERTEQUAL,
334 "%a:%d: Memory at %a != %a for length %d bytes!\n",
380 if (ValueA == ValueB) {
382 "[ASSERT FAIL] %a:%d: Value %a == %a (%d == %d)!\n",
391 FAILURETYPE_ASSERTNOTEQUAL,
392 "%a:%d: Value %a == %a (%d == %d)!\n",
402 return (ValueA != ValueB);
436 if (Status != Expected) {
438 "[ASSERT FAIL] %a:%d: Status '%a' is %r, should be %r!\n",
446 FAILURETYPE_ASSERTSTATUSEQUAL,
447 "%a:%d: Status '%a' is %r, should be %r!\n",
456 return (Status == Expected);
489 if (Pointer ==
NULL) {
491 "[ASSERT FAIL] %a:%d: Pointer (%a) is NULL!\n",
497 FAILURETYPE_ASSERTNOTNULL,
498 "%a:%d: Pointer (%a) is NULL!\n",
505 return (Pointer !=
NULL);
548 if (ResultStatus !=
NULL) {
549 *ResultStatus = UnitTestStatus;
552 if (UnitTestStatus == UNIT_TEST_PASSED) {
554 "[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
561 if (UnitTestStatus == UNIT_TEST_SKIPPED) {
563 "[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
570 if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
572 "[ASSERT FAIL] %a:%d: Function call (%a) did not ASSERT()!\n",
578 FAILURETYPE_EXPECTASSERT,
579 "%a:%d: Function call (%a) did not ASSERT()!\n",
586 return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
VOID EFIAPI LongJump(IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer, IN UINTN Value)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINTN EFIAPI AsciiVSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
#define VA_START(Marker, Parameter)
#define DEBUG(Expression)
#define UNIT_TEST_MAX_STRING_LENGTH
BOOLEAN EFIAPI UnitTestAssertEqual(IN UINT64 ValueA, IN UINT64 ValueB, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *DescriptionA, IN CONST CHAR8 *DescriptionB)
BOOLEAN EFIAPI UnitTestAssertNotNull(IN VOID *Pointer, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *PointerName)
#define UT_LOG_ERROR(Format,...)
BOOLEAN EFIAPI UnitTestAssertFalse(IN BOOLEAN Expression, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
BOOLEAN EFIAPI UnitTestExpectAssertFailure(IN UNIT_TEST_STATUS UnitTestStatus, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *FunctionCall, OUT UNIT_TEST_STATUS *ResultStatus OPTIONAL)
#define UT_LOG_INFO(Format,...)
BOOLEAN EFIAPI UnitTestAssertTrue(IN BOOLEAN Expression, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
BOOLEAN EFIAPI UnitTestAssertNotEfiError(IN EFI_STATUS Status, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
#define UT_LOG_WARNING(Format,...)
BOOLEAN EFIAPI UnitTestAssertNotEqual(IN UINT64 ValueA, IN UINT64 ValueB, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *DescriptionA, IN CONST CHAR8 *DescriptionB)
BOOLEAN EFIAPI UnitTestAssertStatusEqual(IN EFI_STATUS Status, IN EFI_STATUS Expected, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *Description)
BOOLEAN EFIAPI UnitTestAssertMemEqual(IN VOID *BufferA, IN VOID *BufferB, IN UINTN Length, IN CONST CHAR8 *FunctionName, IN UINTN LineNumber, IN CONST CHAR8 *FileName, IN CONST CHAR8 *DescriptionA, IN CONST CHAR8 *DescriptionB)