diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index 016eadc57..c44a22170 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -33,6 +33,8 @@ #include "cfe_assert.h" #include "cfe_test.h" +CFE_FT_Global_t CFE_FT_Global; + /* * Test main function * Register this test routine with CFE Assert diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index e661c6849..c1f906b29 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -46,8 +46,12 @@ typedef struct { CFE_FS_FileWriteMetaData_t FuncTestState; + /* Generic utility counter */ + int Count; } CFE_FT_Global_t; +extern CFE_FT_Global_t CFE_FT_Global; + /** * Name of log file to write * diff --git a/modules/cfe_testcase/src/es_task_test.c b/modules/cfe_testcase/src/es_task_test.c index 0f5c210c2..187961ab2 100644 --- a/modules/cfe_testcase/src/es_task_test.c +++ b/modules/cfe_testcase/src/es_task_test.c @@ -33,13 +33,11 @@ #include "cfe_test.h" -uint32 count = 0; - void TaskFunction(void) { - while (count < 200) + while (CFE_FT_Global.Count < 200) { - count += 1; + CFE_FT_Global.Count += 1; OS_TaskDelay(100); } return; @@ -47,9 +45,9 @@ void TaskFunction(void) void TaskExitFunction(void) { - while (count < 200) + while (CFE_FT_Global.Count < 200) { - count += 1; + CFE_FT_Global.Count += 1; CFE_ES_ExitChildTask(); } return; @@ -68,12 +66,14 @@ void TestCreateChild(void) uint32 Flags = 0; int ExpectedCount = 5; + CFE_FT_Global.Count = 0; + UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags), CFE_SUCCESS); OS_TaskDelay(500); - UtAssert_True(ExpectedCount >= count - 1 && ExpectedCount <= count + 1, "countCopy (%d) == count (%d)", - (int)ExpectedCount, (int)count); + UtAssert_True(ExpectedCount >= CFE_FT_Global.Count - 1 && ExpectedCount <= CFE_FT_Global.Count + 1, + "countCopy (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count); UtAssert_INT32_EQ( CFE_ES_CreateChildTask(&TaskId2, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags), @@ -130,29 +130,30 @@ void TestChildTaskDelete(void) UtPrintf("Testing: CFE_ES_DeleteChildTask"); CFE_ES_TaskId_t TaskId; - const char * TaskName = "CHILD_TASK_1"; - CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; - size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; - CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY; - uint32 Flags = 0; - count = 0; - int ExpectedCount = 5; + const char * TaskName = "CHILD_TASK_1"; + CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; + size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; + CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY; + uint32 Flags = 0; + int ExpectedCount = 5; + + CFE_FT_Global.Count = 0; UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags), CFE_SUCCESS); OS_TaskDelay(500); - UtAssert_True(ExpectedCount >= count - 1 && ExpectedCount <= count + 1, "countCopy (%d) == count (%d)", - (int)ExpectedCount, (int)count); + UtAssert_True(ExpectedCount >= CFE_FT_Global.Count - 1 && ExpectedCount <= CFE_FT_Global.Count + 1, + "countCopy (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count); - ExpectedCount = count; + ExpectedCount = CFE_FT_Global.Count; UtAssert_INT32_EQ(CFE_ES_DeleteChildTask(TaskId), CFE_SUCCESS); OS_TaskDelay(500); - UtAssert_True(ExpectedCount == count || ExpectedCount == count + 1, "ExpectedCount (%d) == count (%d)", - (int)ExpectedCount, (int)count); + UtAssert_True(ExpectedCount == CFE_FT_Global.Count || ExpectedCount == CFE_FT_Global.Count + 1, + "ExpectedCount (%d) == count (%d)", (int)ExpectedCount, (int)CFE_FT_Global.Count); UtAssert_INT32_EQ(CFE_ES_DeleteChildTask(CFE_ES_TASKID_UNDEFINED), CFE_ES_ERR_RESOURCEID_NOT_VALID); } @@ -162,13 +163,12 @@ void TestExitChild(void) UtPrintf("Testing: CFE_ES_ExitChildTask"); CFE_ES_TaskId_t TaskId; - const char * TaskName = "CHILD_TASK_1"; - CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; - size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; - CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY; - uint32 Flags = 0; - count = 0; - int ExpectedCount = 1; + const char * TaskName = "CHILD_TASK_1"; + CFE_ES_StackPointer_t StackPointer = CFE_ES_TASK_STACK_ALLOCATE; + size_t StackSize = CFE_PLATFORM_ES_PERF_CHILD_STACK_SIZE; + CFE_ES_TaskPriority_Atom_t Priority = CFE_PLATFORM_ES_PERF_CHILD_PRIORITY; + uint32 Flags = 0; + int ExpectedCount = 1; UtAssert_INT32_EQ( CFE_ES_CreateChildTask(&TaskId, TaskName, TaskExitFunction, StackPointer, StackSize, Priority, Flags), diff --git a/modules/cfe_testcase/src/fs_util_test.c b/modules/cfe_testcase/src/fs_util_test.c index 8e7d865c0..dbce2c893 100644 --- a/modules/cfe_testcase/src/fs_util_test.c +++ b/modules/cfe_testcase/src/fs_util_test.c @@ -33,8 +33,6 @@ #include "cfe_test.h" -CFE_FT_Global_t CFE_FT_Global; - void TestFileCategory(void) { UtPrintf("Testing: CFE_FS_GetDefaultMountPoint, CFE_FS_GetDefaultExtension"); @@ -138,7 +136,6 @@ void TestFileDump(void) UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), false); UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpRequest(&CFE_FT_Global.FuncTestState), CFE_SUCCESS); - UtAssert_INT32_EQ(CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState), true); /* Wait for background task to complete */ while (CFE_FS_BackgroundFileDumpIsPending(&CFE_FT_Global.FuncTestState) && count < MaxWait)