23STATIC UNIT_TEST_FRAMEWORK_HANDLE mFrameworkHandle =
NULL;
25UNIT_TEST_FRAMEWORK_HANDLE
30 return mFrameworkHandle;
39CmockaUnitTestFunctionRunner (
51 if (UnitTest->RunTest ==
NULL) {
52 UnitTest->Result = UNIT_TEST_SKIPPED;
54 UnitTest->Result = UNIT_TEST_RUNNING;
55 Framework->CurrentTest = UnitTest;
56 UnitTest->Result = UnitTest->RunTest (UnitTest->Context);
57 Framework->CurrentTest =
NULL;
62CmockaUnitTestSetupFunctionRunner (
75 if (UnitTest->Prerequisite ==
NULL) {
79 Framework->CurrentTest = UnitTest;
80 Result = UnitTest->Prerequisite (UnitTest->Context);
81 Framework->CurrentTest =
NULL;
90CmockaUnitTestTeardownFunctionRunner (
102 if (UnitTest->CleanUp !=
NULL) {
103 Framework->CurrentTest = UnitTest;
104 UnitTest->CleanUp (UnitTest->Context);
105 Framework->CurrentTest =
NULL;
113 if (UnitTest->Log !=
NULL) {
114 print_message (
"UnitTest: %s - %s\n", UnitTest->Name, UnitTest->Description);
115 print_message (
"Log Output Start\n");
116 print_message (
"%s", UnitTest->Log);
117 print_message (
"Log Output End\n");
127CmockaUnitTestSuiteSetupFunctionRunner (
131 if (mActiveUnitTestSuite ==
NULL) {
135 if (mActiveUnitTestSuite->Setup ==
NULL) {
139 mActiveUnitTestSuite->Setup ();
147CmockaUnitTestSuiteTeardownFunctionRunner (
151 if (mActiveUnitTestSuite ==
NULL) {
155 if (mActiveUnitTestSuite->Teardown ==
NULL) {
159 mActiveUnitTestSuite->Teardown ();
174 struct CMUnitTest *Tests;
180 return EFI_INVALID_PARAMETER;
183 DEBUG ((DEBUG_VERBOSE,
"---------------------------------------------------------\n"));
184 DEBUG ((DEBUG_VERBOSE,
"RUNNING TEST SUITE: %a\n", Suite->Title));
185 DEBUG ((DEBUG_VERBOSE,
"---------------------------------------------------------\n"));
191 ASSERT (Tests !=
NULL);
198 (
LIST_ENTRY *)TestEntry != &(Suite->TestCaseList);
201 UnitTest = &TestEntry->UT;
202 Tests[Index].name = UnitTest->Description;
203 Tests[Index].test_func = CmockaUnitTestFunctionRunner;
204 Tests[Index].setup_func = CmockaUnitTestSetupFunctionRunner;
205 Tests[Index].teardown_func = CmockaUnitTestTeardownFunctionRunner;
206 Tests[Index].initial_state = UnitTest;
210 ASSERT (Index == Suite->NumTests);
215 mActiveUnitTestSuite = Suite;
216 _cmocka_run_group_tests (
220 CmockaUnitTestSuiteSetupFunctionRunner,
221 CmockaUnitTestSuiteTeardownFunctionRunner
223 mActiveUnitTestSuite =
NULL;
246 IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle
256 if (Framework ==
NULL) {
257 return EFI_INVALID_PARAMETER;
260 DEBUG ((DEBUG_VERBOSE,
"---------------------------------------------------------\n"));
261 DEBUG ((DEBUG_VERBOSE,
"------------ RUNNING ALL TEST SUITES --------------\n"));
262 DEBUG ((DEBUG_VERBOSE,
"---------------------------------------------------------\n"));
263 mFrameworkHandle = FrameworkHandle;
269 (
LIST_ENTRY *)Suite != &Framework->TestSuiteList;
272 Status = RunTestSuite (&(Suite->UTS));
273 if (EFI_ERROR (Status)) {
274 DEBUG ((DEBUG_ERROR,
"Test Suite Failed with Error. %r\n", Status));
278 mFrameworkHandle =
NULL;
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG(Expression)
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
UNIT_TEST_FRAMEWORK_HANDLE GetActiveFrameworkHandle(VOID)