19#define MAX_STRING_SIZE 1025
42 IN BOOLEAN Expression,
49 CHAR8 TempStr[MAX_STRING_SIZE];
51 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_TRUE(%s:%x)", Description, Expression);
52 _assert_true (Expression, TempStr, FileName, (INT32)LineNumber);
78 IN BOOLEAN Expression,
85 CHAR8 TempStr[MAX_STRING_SIZE];
87 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_FALSE(%s:%x)", Description, Expression);
88 _assert_true (!Expression, TempStr, FileName, (INT32)LineNumber);
121 CHAR8 TempStr[MAX_STRING_SIZE];
123 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_NOT_EFI_ERROR(%s:%p)", Description, (
void *)Status);
124 _assert_true (!EFI_ERROR (Status), TempStr, FileName, (INT32)LineNumber);
126 return !EFI_ERROR (Status);
162 CHAR8 TempStr[MAX_STRING_SIZE];
164 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_EQUAL(%s:%llx, %s:%llx)", DescriptionA, ValueA, DescriptionB, ValueB);
165 _assert_true ((ValueA == ValueB), TempStr, FileName, (INT32)LineNumber);
167 return (ValueA == ValueB);
208 CHAR8 TempStr[MAX_STRING_SIZE];
211 Result = (
CompareMem (BufferA, BufferB, Length) == 0);
213 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_MEM_EQUAL(%s:%p, %s:%p)", DescriptionA, BufferA, DescriptionB, BufferB);
214 _assert_true (Result, TempStr, FileName, (INT32)LineNumber);
252 CHAR8 TempStr[MAX_STRING_SIZE];
254 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_NOT_EQUAL(%s:%llx, %s:%llx)", DescriptionA, ValueA, DescriptionB, ValueB);
255 _assert_true ((ValueA != ValueB), TempStr, FileName, (INT32)LineNumber);
257 return (ValueA != ValueB);
291 CHAR8 TempStr[MAX_STRING_SIZE];
293 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_STATUS_EQUAL(%s:%p expected:%p)", Description, (VOID *)Status, (VOID *)Expected);
294 _assert_true ((Status == Expected), TempStr, FileName, (INT32)LineNumber);
296 return (Status == Expected);
329 CHAR8 TempStr[MAX_STRING_SIZE];
331 snprintf (TempStr,
sizeof (TempStr),
"UT_ASSERT_NOT_NULL(%s:%p)", PointerName, Pointer);
332 _assert_true ((Pointer !=
NULL), TempStr, FileName, (INT32)LineNumber);
334 return (Pointer !=
NULL);
377 CHAR8 TempStr[MAX_STRING_SIZE];
379 if (ResultStatus !=
NULL) {
380 *ResultStatus = UnitTestStatus;
383 if (UnitTestStatus == UNIT_TEST_PASSED) {
385 "[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
392 if (UnitTestStatus == UNIT_TEST_SKIPPED) {
394 "[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
401 if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
402 snprintf (TempStr,
sizeof (TempStr),
"UT_EXPECT_ASSERT_FAILURE(%s) did not trigger ASSERT()", FunctionCall);
403 _assert_true (
FALSE, TempStr, FileName, (INT32)LineNumber);
406 return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
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)
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)
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)
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)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define UT_LOG_INFO(Format,...)
#define UT_LOG_WARNING(Format,...)