mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-29 16:44:10 +02:00
UnitTestFrameworkPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the UnitTestFrameworkPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
This commit is contained in:
parent
e5efcf8be8
commit
7c0ad2c338
@ -159,6 +159,7 @@ AllocateAlignedPages (
|
|||||||
if (Alignment < SIZE_4KB) {
|
if (Alignment < SIZE_4KB) {
|
||||||
Alignment = SIZE_4KB;
|
Alignment = SIZE_4KB;
|
||||||
}
|
}
|
||||||
|
|
||||||
AlignmentMask = Alignment - 1;
|
AlignmentMask = Alignment - 1;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -171,6 +172,7 @@ AllocateAlignedPages (
|
|||||||
if (PageHead.AllocatedBufffer == NULL) {
|
if (PageHead.AllocatedBufffer == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageHead.AlignedBuffer = (VOID *)(((UINTN)PageHead.AllocatedBufffer + AlignmentMask) & ~AlignmentMask);
|
PageHead.AlignedBuffer = (VOID *)(((UINTN)PageHead.AllocatedBufffer + AlignmentMask) & ~AlignmentMask);
|
||||||
if ((UINTN)PageHead.AlignedBuffer - (UINTN)PageHead.AllocatedBufffer < sizeof (PAGE_HEAD)) {
|
if ((UINTN)PageHead.AlignedBuffer - (UINTN)PageHead.AllocatedBufffer < sizeof (PAGE_HEAD)) {
|
||||||
PageHead.AlignedBuffer = (VOID *)((UINTN)PageHead.AlignedBuffer + Alignment);
|
PageHead.AlignedBuffer = (VOID *)((UINTN)PageHead.AlignedBuffer + Alignment);
|
||||||
@ -271,6 +273,7 @@ FreeAlignedPages (
|
|||||||
if (PageHeadPtr->Signature != PAGE_HEAD_PRIVATE_SIGNATURE) {
|
if (PageHeadPtr->Signature != PAGE_HEAD_PRIVATE_SIGNATURE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageHeadPtr->AlignedPages != Pages) {
|
if (PageHeadPtr->AlignedPages != Pages) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -366,6 +369,7 @@ AllocateZeroPool (
|
|||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (Buffer, 0, AllocationSize);
|
memset (Buffer, 0, AllocationSize);
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
@ -444,6 +448,7 @@ AllocateCopyPool (
|
|||||||
if (Memory == NULL) {
|
if (Memory == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (Memory, Buffer, AllocationSize);
|
memcpy (Memory, Buffer, AllocationSize);
|
||||||
return Memory;
|
return Memory;
|
||||||
}
|
}
|
||||||
@ -534,12 +539,14 @@ ReallocatePool (
|
|||||||
VOID *NewBuffer;
|
VOID *NewBuffer;
|
||||||
|
|
||||||
NewBuffer = malloc (NewSize);
|
NewBuffer = malloc (NewSize);
|
||||||
if (NewBuffer != NULL && OldBuffer != NULL) {
|
if ((NewBuffer != NULL) && (OldBuffer != NULL)) {
|
||||||
memcpy (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
memcpy (NewBuffer, OldBuffer, MIN (OldSize, NewSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OldBuffer != NULL) {
|
if (OldBuffer != NULL) {
|
||||||
FreePool (OldBuffer);
|
FreePool (OldBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewBuffer;
|
return NewBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +117,14 @@ CLEANUP:
|
|||||||
if (Dp != NULL) {
|
if (Dp != NULL) {
|
||||||
FreePool (Dp);
|
FreePool (Dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DpEnd != NULL) {
|
if (DpEnd != NULL) {
|
||||||
FreePool (DpEnd);
|
FreePool (DpEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewOptionValid) {
|
if (NewOptionValid) {
|
||||||
EfiBootManagerFreeLoadOption (&NewOption);
|
EfiBootManagerFreeLoadOption (&NewOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ AddUnitTestFailure (
|
|||||||
//
|
//
|
||||||
// Make sure that you're cooking with gas.
|
// Make sure that you're cooking with gas.
|
||||||
//
|
//
|
||||||
if (UnitTest == NULL || FailureMessage == NULL) {
|
if ((UnitTest == NULL) || (FailureMessage == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +120,7 @@ UnitTestAssertTrue (
|
|||||||
Description
|
Description
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Expression;
|
return Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +167,7 @@ UnitTestAssertFalse (
|
|||||||
Description
|
Description
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !Expression;
|
return !Expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,6 +216,7 @@ UnitTestAssertNotEfiError (
|
|||||||
Status
|
Status
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !EFI_ERROR (Status);
|
return !EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +274,7 @@ UnitTestAssertEqual (
|
|||||||
ValueB
|
ValueB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ValueA == ValueB);
|
return (ValueA == ValueB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,6 +336,7 @@ UnitTestAssertMemEqual (
|
|||||||
);
|
);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,6 +394,7 @@ UnitTestAssertNotEqual (
|
|||||||
ValueB
|
ValueB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ValueA != ValueB);
|
return (ValueA != ValueB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -442,6 +448,7 @@ UnitTestAssertStatusEqual (
|
|||||||
Expected
|
Expected
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Status == Expected);
|
return (Status == Expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,6 +497,7 @@ UnitTestAssertNotNull (
|
|||||||
PointerName
|
PointerName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Pointer != NULL);
|
return (Pointer != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,6 +544,7 @@ UnitTestExpectAssertFailure (
|
|||||||
if (ResultStatus != NULL) {
|
if (ResultStatus != NULL) {
|
||||||
*ResultStatus = UnitTestStatus;
|
*ResultStatus = UnitTestStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_PASSED) {
|
if (UnitTestStatus == UNIT_TEST_PASSED) {
|
||||||
UT_LOG_INFO (
|
UT_LOG_INFO (
|
||||||
"[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
|
"[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
|
||||||
@ -544,6 +553,7 @@ UnitTestExpectAssertFailure (
|
|||||||
FunctionCall
|
FunctionCall
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_SKIPPED) {
|
if (UnitTestStatus == UNIT_TEST_SKIPPED) {
|
||||||
UT_LOG_WARNING (
|
UT_LOG_WARNING (
|
||||||
"[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
|
"[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
|
||||||
@ -552,6 +562,7 @@ UnitTestExpectAssertFailure (
|
|||||||
FunctionCall
|
FunctionCall
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
|
if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
|
||||||
UT_LOG_ERROR (
|
UT_LOG_ERROR (
|
||||||
"[ASSERT FAIL] %a:%d: Function call (%a) did not ASSERT()!\n",
|
"[ASSERT FAIL] %a:%d: Function call (%a) did not ASSERT()!\n",
|
||||||
@ -567,5 +578,6 @@ UnitTestExpectAssertFailure (
|
|||||||
FunctionCall
|
FunctionCall
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
|
return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
|
||||||
}
|
}
|
||||||
|
@ -379,6 +379,7 @@ UnitTestExpectAssertFailure (
|
|||||||
if (ResultStatus != NULL) {
|
if (ResultStatus != NULL) {
|
||||||
*ResultStatus = UnitTestStatus;
|
*ResultStatus = UnitTestStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_PASSED) {
|
if (UnitTestStatus == UNIT_TEST_PASSED) {
|
||||||
UT_LOG_INFO (
|
UT_LOG_INFO (
|
||||||
"[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
|
"[ASSERT PASS] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) detected expected assert\n",
|
||||||
@ -387,6 +388,7 @@ UnitTestExpectAssertFailure (
|
|||||||
FunctionCall
|
FunctionCall
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_SKIPPED) {
|
if (UnitTestStatus == UNIT_TEST_SKIPPED) {
|
||||||
UT_LOG_WARNING (
|
UT_LOG_WARNING (
|
||||||
"[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
|
"[ASSERT WARN] %a:%d: UT_EXPECT_ASSERT_FAILURE(%a) disabled\n",
|
||||||
@ -395,9 +397,11 @@ UnitTestExpectAssertFailure (
|
|||||||
FunctionCall
|
FunctionCall
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
|
if (UnitTestStatus == UNIT_TEST_ERROR_TEST_FAILED) {
|
||||||
snprintf (TempStr, sizeof (TempStr), "UT_EXPECT_ASSERT_FAILURE(%s) did not trigger ASSERT()", FunctionCall);
|
snprintf (TempStr, sizeof (TempStr), "UT_EXPECT_ASSERT_FAILURE(%s) did not trigger ASSERT()", FunctionCall);
|
||||||
_assert_true (FALSE, TempStr, FileName, (INT32)LineNumber);
|
_assert_true (FALSE, TempStr, FileName, (INT32)LineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
|
return (UnitTestStatus != UNIT_TEST_ERROR_TEST_FAILED);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ GetStringForStatusLogPrefix (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ AddStringToUnitTestLog (
|
|||||||
//
|
//
|
||||||
// Make sure that you're cooking with gas.
|
// Make sure that you're cooking with gas.
|
||||||
//
|
//
|
||||||
if (UnitTest == NULL || String == NULL) {
|
if ((UnitTest == NULL) || (String == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ RunTestSuite (
|
|||||||
//
|
//
|
||||||
for (TestEntry = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->TestCaseList));
|
for (TestEntry = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->TestCaseList));
|
||||||
(LIST_ENTRY *)TestEntry != &(Suite->TestCaseList);
|
(LIST_ENTRY *)TestEntry != &(Suite->TestCaseList);
|
||||||
TestEntry = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->TestCaseList), (LIST_ENTRY *)TestEntry)) {
|
TestEntry = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->TestCaseList), (LIST_ENTRY *)TestEntry))
|
||||||
|
{
|
||||||
Test = &TestEntry->UT;
|
Test = &TestEntry->UT;
|
||||||
ParentFramework->CurrentTest = Test;
|
ParentFramework->CurrentTest = Test;
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ RunTestSuite (
|
|||||||
// First, check to see whether the test has already been run.
|
// First, check to see whether the test has already been run.
|
||||||
// NOTE: This would generally only be the case if a saved state was detected and loaded.
|
// NOTE: This would generally only be the case if a saved state was detected and loaded.
|
||||||
//
|
//
|
||||||
if (Test->Result != UNIT_TEST_PENDING && Test->Result != UNIT_TEST_RUNNING) {
|
if ((Test->Result != UNIT_TEST_PENDING) && (Test->Result != UNIT_TEST_RUNNING)) {
|
||||||
DEBUG ((DEBUG_VERBOSE, "Test was run on a previous pass. Skipping.\n"));
|
DEBUG ((DEBUG_VERBOSE, "Test was run on a previous pass. Skipping.\n"));
|
||||||
ParentFramework->CurrentTest = NULL;
|
ParentFramework->CurrentTest = NULL;
|
||||||
continue;
|
continue;
|
||||||
@ -75,7 +76,7 @@ RunTestSuite (
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Next, if we're still running, make sure that our test prerequisites are in place.
|
// Next, if we're still running, make sure that our test prerequisites are in place.
|
||||||
if (Test->Result == UNIT_TEST_PENDING && Test->Prerequisite != NULL) {
|
if ((Test->Result == UNIT_TEST_PENDING) && (Test->Prerequisite != NULL)) {
|
||||||
DEBUG ((DEBUG_VERBOSE, "PREREQ\n"));
|
DEBUG ((DEBUG_VERBOSE, "PREREQ\n"));
|
||||||
if (SetJump (&gUnitTestJumpBuffer) == 0) {
|
if (SetJump (&gUnitTestJumpBuffer) == 0) {
|
||||||
if (Test->Prerequisite (Test->Context) != UNIT_TEST_PASSED) {
|
if (Test->Prerequisite (Test->Context) != UNIT_TEST_PASSED) {
|
||||||
@ -167,7 +168,8 @@ RunAllTestSuites (
|
|||||||
//
|
//
|
||||||
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
||||||
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
||||||
Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite)) {
|
Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite))
|
||||||
|
{
|
||||||
Status = RunTestSuite (&(Suite->UTS));
|
Status = RunTestSuite (&(Suite->UTS));
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
|
DEBUG ((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
|
||||||
|
@ -132,6 +132,7 @@ CmockaUnitTestSuiteSetupFunctionRunner (
|
|||||||
if (mActiveUnitTestSuite == NULL) {
|
if (mActiveUnitTestSuite == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mActiveUnitTestSuite->Setup == NULL) {
|
if (mActiveUnitTestSuite->Setup == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -151,6 +152,7 @@ CmockaUnitTestSuiteTeardownFunctionRunner (
|
|||||||
if (mActiveUnitTestSuite == NULL) {
|
if (mActiveUnitTestSuite == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mActiveUnitTestSuite->Teardown == NULL) {
|
if (mActiveUnitTestSuite->Teardown == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -195,7 +197,8 @@ RunTestSuite (
|
|||||||
Index = 0;
|
Index = 0;
|
||||||
for (TestEntry = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->TestCaseList));
|
for (TestEntry = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->TestCaseList));
|
||||||
(LIST_ENTRY *)TestEntry != &(Suite->TestCaseList);
|
(LIST_ENTRY *)TestEntry != &(Suite->TestCaseList);
|
||||||
TestEntry = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->TestCaseList), (LIST_ENTRY *)TestEntry)) {
|
TestEntry = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->TestCaseList), (LIST_ENTRY *)TestEntry))
|
||||||
|
{
|
||||||
UnitTest = &TestEntry->UT;
|
UnitTest = &TestEntry->UT;
|
||||||
Tests[Index].name = UnitTest->Description;
|
Tests[Index].name = UnitTest->Description;
|
||||||
Tests[Index].test_func = CmockaUnitTestFunctionRunner;
|
Tests[Index].test_func = CmockaUnitTestFunctionRunner;
|
||||||
@ -204,6 +207,7 @@ RunTestSuite (
|
|||||||
Tests[Index].initial_state = UnitTest;
|
Tests[Index].initial_state = UnitTest;
|
||||||
Index++;
|
Index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (Index == Suite->NumTests);
|
ASSERT (Index == Suite->NumTests);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -264,7 +268,8 @@ RunAllTestSuites (
|
|||||||
//
|
//
|
||||||
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
||||||
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
||||||
Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite)) {
|
Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite))
|
||||||
|
{
|
||||||
Status = RunTestSuite (&(Suite->UTS));
|
Status = RunTestSuite (&(Suite->UTS));
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
|
DEBUG ((DEBUG_ERROR, "Test Suite Failed with Error. %r\n", Status));
|
||||||
|
@ -61,6 +61,7 @@ AllocateAndCopyString (
|
|||||||
if (NewString != NULL) {
|
if (NewString != NULL) {
|
||||||
AsciiStrCpyS (NewString, NewStringLength, StringToCopy);
|
AsciiStrCpyS (NewString, NewStringLength, StringToCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NewString;
|
return NewString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,8 +217,9 @@ InitUnitTestFramework (
|
|||||||
//
|
//
|
||||||
// First, check all pointers and make sure nothing's broked.
|
// First, check all pointers and make sure nothing's broked.
|
||||||
//
|
//
|
||||||
if (FrameworkHandle == NULL || Title == NULL ||
|
if ((FrameworkHandle == NULL) || (Title == NULL) ||
|
||||||
ShortTitle == NULL || VersionString == NULL) {
|
(ShortTitle == NULL) || (VersionString == NULL))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,12 +248,14 @@ InitUnitTestFramework (
|
|||||||
NewFramework->Log = NULL;
|
NewFramework->Log = NULL;
|
||||||
NewFramework->CurrentTest = NULL;
|
NewFramework->CurrentTest = NULL;
|
||||||
NewFramework->SavedState = NULL;
|
NewFramework->SavedState = NULL;
|
||||||
if (NewFramework->Title == NULL ||
|
if ((NewFramework->Title == NULL) ||
|
||||||
NewFramework->ShortTitle == NULL ||
|
(NewFramework->ShortTitle == NULL) ||
|
||||||
NewFramework->VersionString == NULL) {
|
(NewFramework->VersionString == NULL))
|
||||||
|
{
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeListHead (&(NewFramework->TestSuiteList));
|
InitializeListHead (&(NewFramework->TestSuiteList));
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -468,6 +472,7 @@ AddTestCase (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewTestEntry->UT.Name == NULL) {
|
if (NewTestEntry->UT.Name == NULL) {
|
||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto Exit;
|
goto Exit;
|
||||||
@ -520,9 +525,10 @@ UpdateTestFromSave (
|
|||||||
//
|
//
|
||||||
// First, evaluate the inputs.
|
// First, evaluate the inputs.
|
||||||
//
|
//
|
||||||
if (Test == NULL || SavedState == NULL) {
|
if ((Test == NULL) || (SavedState == NULL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SavedState->TestCount == 0) {
|
if (SavedState->TestCount == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -590,8 +596,9 @@ UpdateTestFromSave (
|
|||||||
// at the beginning of the context structure.
|
// at the beginning of the context structure.
|
||||||
//
|
//
|
||||||
SavedContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
|
SavedContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
|
||||||
if ((SavedContext->Size - sizeof (UNIT_TEST_SAVE_CONTEXT)) > 0 &&
|
if (((SavedContext->Size - sizeof (UNIT_TEST_SAVE_CONTEXT)) > 0) &&
|
||||||
CompareFingerprints (&Test->Fingerprint[0], &SavedContext->Fingerprint[0])) {
|
CompareFingerprints (&Test->Fingerprint[0], &SavedContext->Fingerprint[0]))
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Override the test context with the saved context.
|
// Override the test context with the saved context.
|
||||||
//
|
//
|
||||||
@ -628,9 +635,10 @@ SerializeState (
|
|||||||
//
|
//
|
||||||
// First, let's not make assumptions about the parameters.
|
// First, let's not make assumptions about the parameters.
|
||||||
//
|
//
|
||||||
if (Framework == NULL ||
|
if ((Framework == NULL) ||
|
||||||
(ContextToSave != NULL && ContextToSaveSize == 0) ||
|
((ContextToSave != NULL) && (ContextToSaveSize == 0)) ||
|
||||||
ContextToSaveSize > MAX_UINT32) {
|
(ContextToSaveSize > MAX_UINT32))
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,18 +678,21 @@ SerializeState (
|
|||||||
ASSERT (LogSize < MAX_UINT32);
|
ASSERT (LogSize < MAX_UINT32);
|
||||||
TotalSize += (UINT32)LogSize;
|
TotalSize += (UINT32)LogSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Increment the test count.
|
// Increment the test count.
|
||||||
//
|
//
|
||||||
TestCount++;
|
TestCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If there are no tests, we're done here.
|
// If there are no tests, we're done here.
|
||||||
//
|
//
|
||||||
if (TestCount == 0) {
|
if (TestCount == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add room for the context, if there is one.
|
// Add room for the context, if there is one.
|
||||||
//
|
//
|
||||||
@ -737,7 +748,6 @@ SerializeState (
|
|||||||
TestSaveData->FailureType = UnitTest->FailureType;
|
TestSaveData->FailureType = UnitTest->FailureType;
|
||||||
AsciiStrnCpyS (&TestSaveData->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
|
AsciiStrnCpyS (&TestSaveData->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH, &UnitTest->FailureMessage[0], UNIT_TEST_TESTFAILUREMSG_LENGTH);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If there is a log, save the log.
|
// If there is a log, save the log.
|
||||||
//
|
//
|
||||||
@ -762,7 +772,7 @@ SerializeState (
|
|||||||
//
|
//
|
||||||
// If there is a context to save, let's do that now.
|
// If there is a context to save, let's do that now.
|
||||||
//
|
//
|
||||||
if (ContextToSave != NULL && Framework->CurrentTest != NULL) {
|
if ((ContextToSave != NULL) && (Framework->CurrentTest != NULL)) {
|
||||||
TestSaveContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
|
TestSaveContext = (UNIT_TEST_SAVE_CONTEXT *)FloatingPointer;
|
||||||
TestSaveContext->Size = (UINT32)ContextToSaveSize + sizeof (UNIT_TEST_SAVE_CONTEXT);
|
TestSaveContext->Size = (UINT32)ContextToSaveSize + sizeof (UNIT_TEST_SAVE_CONTEXT);
|
||||||
CopyMem (&TestSaveContext->Fingerprint[0], &Framework->CurrentTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
|
CopyMem (&TestSaveContext->Fingerprint[0], &Framework->CurrentTest->Fingerprint[0], UNIT_TEST_FINGERPRINT_SIZE);
|
||||||
@ -825,8 +835,9 @@ SaveFrameworkState (
|
|||||||
//
|
//
|
||||||
// First, let's not make assumptions about the parameters.
|
// First, let's not make assumptions about the parameters.
|
||||||
//
|
//
|
||||||
if ((ContextToSave != NULL && ContextToSaveSize == 0) ||
|
if (((ContextToSave != NULL) && (ContextToSaveSize == 0)) ||
|
||||||
ContextToSaveSize > MAX_UINT32) {
|
(ContextToSaveSize > MAX_UINT32))
|
||||||
|
{
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ GetCacheFileDevicePath (
|
|||||||
if (!TestName) {
|
if (!TestName) {
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiStrToUnicodeStrS (Framework->ShortTitle, TestName, CacheFilePathLength);
|
AsciiStrToUnicodeStrS (Framework->ShortTitle, TestName, CacheFilePathLength);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -99,6 +100,7 @@ GetCacheFileDevicePath (
|
|||||||
if (AppPath[DirectorySlashOffset] == L'\\') {
|
if (AppPath[DirectorySlashOffset] == L'\\') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectorySlashOffset--;
|
DirectorySlashOffset--;
|
||||||
} while (DirectorySlashOffset > 0);
|
} while (DirectorySlashOffset > 0);
|
||||||
|
|
||||||
@ -143,9 +145,11 @@ Exit:
|
|||||||
if (AppPath != NULL) {
|
if (AppPath != NULL) {
|
||||||
FreePool (AppPath);
|
FreePool (AppPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CacheFilePath != NULL) {
|
if (CacheFilePath != NULL) {
|
||||||
FreePool (CacheFilePath);
|
FreePool (CacheFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TestName != NULL) {
|
if (TestName != NULL) {
|
||||||
FreePool (TestName);
|
FreePool (TestName);
|
||||||
}
|
}
|
||||||
@ -229,7 +233,7 @@ SaveUnitTestCache (
|
|||||||
//
|
//
|
||||||
// Check the inputs for sanity.
|
// Check the inputs for sanity.
|
||||||
//
|
//
|
||||||
if (FrameworkHandle == NULL || SaveData == NULL) {
|
if ((FrameworkHandle == NULL) || (SaveData == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +288,7 @@ SaveUnitTestCache (
|
|||||||
SaveData
|
SaveData
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status) || WriteCount != SaveData->SaveStateSize) {
|
if (EFI_ERROR (Status) || (WriteCount != SaveData->SaveStateSize)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status));
|
DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status));
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
|
DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
|
||||||
@ -338,7 +342,7 @@ LoadUnitTestCache (
|
|||||||
//
|
//
|
||||||
// Check the inputs for sanity.
|
// Check the inputs for sanity.
|
||||||
//
|
//
|
||||||
if (FrameworkHandle == NULL || SaveData == NULL) {
|
if ((FrameworkHandle == NULL) || (SaveData == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,6 +403,7 @@ Exit:
|
|||||||
if (FileDevicePath != NULL) {
|
if (FileDevicePath != NULL) {
|
||||||
FreePool (FileDevicePath);
|
FreePool (FileDevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsFileOpened) {
|
if (IsFileOpened) {
|
||||||
ShellCloseFile (&FileHandle);
|
ShellCloseFile (&FileHandle);
|
||||||
}
|
}
|
||||||
@ -406,7 +411,7 @@ Exit:
|
|||||||
//
|
//
|
||||||
// If we're returning an error, make sure
|
// If we're returning an error, make sure
|
||||||
// the state is sane.
|
// the state is sane.
|
||||||
if (EFI_ERROR (Status) && Buffer != NULL) {
|
if (EFI_ERROR (Status) && (Buffer != NULL)) {
|
||||||
FreePool (Buffer);
|
FreePool (Buffer);
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ GetStringForUnitTestStatus (
|
|||||||
return mStatusStrings[Index].String;
|
return mStatusStrings[Index].String;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return last entry if no match found.
|
// Return last entry if no match found.
|
||||||
//
|
//
|
||||||
@ -97,6 +98,7 @@ GetStringForFailureType (
|
|||||||
return mFailureTypeStrings[Index].String;
|
return mFailureTypeStrings[Index].String;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Return last entry if no match found.
|
// Return last entry if no match found.
|
||||||
//
|
//
|
||||||
@ -146,8 +148,8 @@ OutputUnitTestFrameworkReport (
|
|||||||
//
|
//
|
||||||
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
for (Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetFirstNode (&Framework->TestSuiteList);
|
||||||
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
(LIST_ENTRY *)Suite != &Framework->TestSuiteList;
|
||||||
Suite = (UNIT_TEST_SUITE_LIST_ENTRY*)GetNextNode(&Framework->TestSuiteList, (LIST_ENTRY*)Suite)) {
|
Suite = (UNIT_TEST_SUITE_LIST_ENTRY *)GetNextNode (&Framework->TestSuiteList, (LIST_ENTRY *)Suite))
|
||||||
|
{
|
||||||
Test = NULL;
|
Test = NULL;
|
||||||
SPassed = 0;
|
SPassed = 0;
|
||||||
SFailed = 0;
|
SFailed = 0;
|
||||||
@ -163,8 +165,8 @@ OutputUnitTestFrameworkReport (
|
|||||||
//
|
//
|
||||||
for (Test = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->UTS.TestCaseList));
|
for (Test = (UNIT_TEST_LIST_ENTRY *)GetFirstNode (&(Suite->UTS.TestCaseList));
|
||||||
(LIST_ENTRY *)Test != &(Suite->UTS.TestCaseList);
|
(LIST_ENTRY *)Test != &(Suite->UTS.TestCaseList);
|
||||||
Test = (UNIT_TEST_LIST_ENTRY*)GetNextNode(&(Suite->UTS.TestCaseList), (LIST_ENTRY*)Test)) {
|
Test = (UNIT_TEST_LIST_ENTRY *)GetNextNode (&(Suite->UTS.TestCaseList), (LIST_ENTRY *)Test))
|
||||||
|
{
|
||||||
ReportPrint ("*********************************************************\n");
|
ReportPrint ("*********************************************************\n");
|
||||||
ReportPrint (" CLASS NAME: %a\n", Test->UT.Name);
|
ReportPrint (" CLASS NAME: %a\n", Test->UT.Name);
|
||||||
ReportPrint (" TEST: %a\n", Test->UT.Description);
|
ReportPrint (" TEST: %a\n", Test->UT.Description);
|
||||||
@ -192,6 +194,7 @@ OutputUnitTestFrameworkReport (
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportPrint ("**********************************************************\n");
|
ReportPrint ("**********************************************************\n");
|
||||||
} // End Test iteration
|
} // End Test iteration
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ ReportPrint (
|
|||||||
} else {
|
} else {
|
||||||
gST->ConOut->OutputString (gST->ConOut, String);
|
gST->ConOut->OutputString (gST->ConOut, String);
|
||||||
}
|
}
|
||||||
|
|
||||||
VA_END (Marker);
|
VA_END (Marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ ReportPrint (
|
|||||||
} else {
|
} else {
|
||||||
DEBUG ((DEBUG_INFO, String));
|
DEBUG ((DEBUG_INFO, String));
|
||||||
}
|
}
|
||||||
|
|
||||||
VA_END (Marker);
|
VA_END (Marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,6 +684,7 @@ UefiTestMain (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTestCase (SimpleMathTests, "Adding 1 to 1 should produce 2", "Addition", OnePlusOneShouldEqualTwo, NULL, NULL, NULL);
|
AddTestCase (SimpleMathTests, "Adding 1 to 1 should produce 2", "Addition", OnePlusOneShouldEqualTwo, NULL, NULL, NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -695,6 +696,7 @@ UefiTestMain (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTestCase (GlobalVarTests, "You should be able to change a global BOOLEAN", "Boolean", GlobalBooleanShouldBeChangeable, NULL, NULL, NULL);
|
AddTestCase (GlobalVarTests, "You should be able to change a global BOOLEAN", "Boolean", GlobalBooleanShouldBeChangeable, NULL, NULL, NULL);
|
||||||
AddTestCase (GlobalVarTests, "You should be able to change a global pointer", "Pointer", GlobalPointerShouldBeChangeable, MakeSureThatPointerIsNull, ClearThePointer, NULL);
|
AddTestCase (GlobalVarTests, "You should be able to change a global pointer", "Pointer", GlobalPointerShouldBeChangeable, MakeSureThatPointerIsNull, ClearThePointer, NULL);
|
||||||
|
|
||||||
@ -707,6 +709,7 @@ UefiTestMain (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_TRUE() macro", "MacroUtAssertTrue", MacroUtAssertTrue, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_TRUE() macro", "MacroUtAssertTrue", MacroUtAssertTrue, NULL, NULL, NULL);
|
||||||
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_FALSE() macro", "MacroUtAssertFalse", MacroUtAssertFalse, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_FALSE() macro", "MacroUtAssertFalse", MacroUtAssertFalse, NULL, NULL, NULL);
|
||||||
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_EQUAL() macro", "MacroUtAssertEqual", MacroUtAssertEqual, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsEnabled, "Test UT_ASSERT_EQUAL() macro", "MacroUtAssertEqual", MacroUtAssertEqual, NULL, NULL, NULL);
|
||||||
@ -731,6 +734,7 @@ UefiTestMain (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_TRUE() macro", "MacroUtAssertTrue", MacroUtAssertTrue, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_TRUE() macro", "MacroUtAssertTrue", MacroUtAssertTrue, NULL, NULL, NULL);
|
||||||
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_FALSE() macro", "MacroUtAssertFalse", MacroUtAssertFalse, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_FALSE() macro", "MacroUtAssertFalse", MacroUtAssertFalse, NULL, NULL, NULL);
|
||||||
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_EQUAL() macro", "MacroUtAssertEqual", MacroUtAssertEqual, NULL, NULL, NULL);
|
AddTestCase (MacroTestsAssertsDisabled, "Test UT_ASSERT_EQUAL() macro", "MacroUtAssertEqual", MacroUtAssertEqual, NULL, NULL, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user