diff --git a/cmake/sample_defs/cpu1_cfe_es_startup.scr b/cmake/sample_defs/cpu1_cfe_es_startup.scr index e48880e15..379f4bce4 100644 --- a/cmake/sample_defs/cpu1_cfe_es_startup.scr +++ b/cmake/sample_defs/cpu1_cfe_es_startup.scr @@ -31,4 +31,3 @@ CFE_APP, sch_lab, SCH_Lab_AppMain, SCH_LAB_APP, 80, 16384, 0x0, 0; ! 3. The filename field (2) no longer requires a fully-qualified filename; the path and extension ! may be omitted. If omitted, the standard virtual path (/cf) and a platform-specific default ! extension will be used, which is derived from the build system. - diff --git a/modules/cfe_testcase/CMakeLists.txt b/modules/cfe_testcase/CMakeLists.txt index 64f4180cf..106f28eba 100644 --- a/modules/cfe_testcase/CMakeLists.txt +++ b/modules/cfe_testcase/CMakeLists.txt @@ -3,6 +3,7 @@ add_cfe_app(cfe_testcase src/cfe_test.c src/es_info_test.c + src/es_task_test.c ) # register the dependency on cfe_assert diff --git a/modules/cfe_testcase/src/cfe_test.c b/modules/cfe_testcase/src/cfe_test.c index f4015320c..1cfafd301 100644 --- a/modules/cfe_testcase/src/cfe_test.c +++ b/modules/cfe_testcase/src/cfe_test.c @@ -51,6 +51,7 @@ void CFE_TestMain(void) * Register test cases in UtAssert */ ESInfoTestSetup(); + ESTaskTestSetup(); /* * Execute the tests diff --git a/modules/cfe_testcase/src/cfe_test.h b/modules/cfe_testcase/src/cfe_test.h index 87223e978..71b5ad093 100644 --- a/modules/cfe_testcase/src/cfe_test.h +++ b/modules/cfe_testcase/src/cfe_test.h @@ -49,10 +49,12 @@ CFE_RESOURCEID_TO_ULONG(actual), #expect, CFE_RESOURCEID_TO_ULONG(expect)) /* Check if a Resource ID is Undefined */ -#define UtAssert_ResourceID_Undifeined(id) \ +#define UtAssert_ResourceID_Undefined(id) \ UtAssert_True(!CFE_RESOURCEID_TEST_DEFINED(id), "%s (%lu) not defined", #id, CFE_RESOURCEID_TO_ULONG(id)) void CFE_TestMain(void); void ESInfoTestSetup(void); +void ESTaskTestSetup(void); + #endif /* CFE_TEST_H */ diff --git a/modules/cfe_testcase/src/es_info_test.c b/modules/cfe_testcase/src/es_info_test.c index f107b611c..f251d5325 100644 --- a/modules/cfe_testcase/src/es_info_test.c +++ b/modules/cfe_testcase/src/es_info_test.c @@ -122,7 +122,7 @@ void TestAppInfo(void) UtAssert_True(ESAppInfo.NumOfChildTasks > 0, "ES App Info -> Child Tasks = %d", (int)ESAppInfo.NumOfChildTasks); UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(&AppIdByName, INVALID_APP_NAME), CFE_ES_ERR_NAME_NOT_FOUND); - UtAssert_ResourceID_Undifeined(AppIdByName); + UtAssert_ResourceID_Undefined(AppIdByName); UtAssert_INT32_EQ(CFE_ES_GetAppID(NULL), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetAppIDByName(NULL, TEST_EXPECTED_APP_NAME), CFE_ES_BAD_ARGUMENT); UtAssert_INT32_EQ(CFE_ES_GetAppName(AppNameBuf, CFE_ES_APPID_UNDEFINED, sizeof(AppNameBuf)), @@ -205,7 +205,7 @@ void TestLibInfo(void) UtAssert_INT32_EQ(LibInfo.ExceptionAction, 0); UtAssert_True(LibInfo.Priority == 0, "Lib Info -> Priority = %d", (int)LibInfo.Priority); - UtAssert_ResourceID_Undifeined(LibInfo.MainTaskId); + UtAssert_ResourceID_Undefined(LibInfo.MainTaskId); UtAssert_True(LibInfo.ExecutionCounter == 0, "Lib Info -> ExecutionCounter = %d", (int)LibInfo.ExecutionCounter); UtAssert_True(strlen(LibInfo.MainTaskName) == 0, "Lib Info -> Task Name = %s", LibInfo.MainTaskName); UtAssert_True(LibInfo.NumOfChildTasks == 0, "Lib Info -> Child Tasks = %d", (int)LibInfo.NumOfChildTasks); diff --git a/modules/cfe_testcase/src/es_task_test.c b/modules/cfe_testcase/src/es_task_test.c new file mode 100644 index 000000000..cfca4e61e --- /dev/null +++ b/modules/cfe_testcase/src/es_task_test.c @@ -0,0 +1,115 @@ +/************************************************************************* +** +** GSC-18128-1, "Core Flight Executive Version 6.7" +** +** Copyright (c) 2006-2019 United States Government as represented by +** the Administrator of the National Aeronautics and Space Administration. +** All Rights Reserved. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +** +** File: es_task_test.c +** +** Purpose: +** Functional test of basic ES Child Tasks APIs +** +** Demonstration of how to register and use the UT assert functions. +** +*************************************************************************/ + +/* + * Includes + */ + +#include "cfe_test.h" + +uint32 count = 0; + +void TaskFunction(void) +{ + while (count < 200) + { + count += 1; + OS_TaskDelay(100); + } + return; +} + +void TaskExitFunction(void) +{ + while (count < 200) + { + count += 1; + CFE_ES_ExitChildTask(); + } + return; +} + +void TestCreateChild(void) +{ + UtPrintf("Testing: CFE_ES_CreateChildTask, CFE_ES_GetTaskIDByName, CFE_ES_GetTaskName, CFE_ES_DeleteChildTask"); + + CFE_ES_TaskId_t TaskId; + const char * TaskName = "CHILD_TASK_1"; + CFE_ES_TaskId_t TaskIdByName; + char TaskNameBuf[OS_MAX_API_NAME + 4]; + 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 countCopy; + + UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&TaskId, TaskName, TaskFunction, StackPointer, StackSize, Priority, Flags), + CFE_SUCCESS); + + UtAssert_INT32_EQ(CFE_ES_GetTaskIDByName(&TaskIdByName, TaskName), CFE_SUCCESS); + UtAssert_ResourceID_EQ(TaskIdByName, TaskId); + + UtAssert_INT32_EQ(CFE_ES_GetTaskName(TaskNameBuf, TaskId, sizeof(TaskNameBuf)), CFE_SUCCESS); + UtAssert_StrCmp(TaskNameBuf, TaskName, "CFE_ES_GetTaskName() = %s", TaskNameBuf); + + OS_TaskDelay(500); + + countCopy = count; + + UtAssert_INT32_EQ(CFE_ES_DeleteChildTask(TaskId), CFE_SUCCESS); + + OS_TaskDelay(500); + + UtAssert_True(countCopy == count || countCopy == count + 1, "countCopy (%d) == count (%d)", countCopy, count); +} + +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; + + UtAssert_INT32_EQ( + CFE_ES_CreateChildTask(&TaskId, TaskName, TaskExitFunction, StackPointer, StackSize, Priority, Flags), + CFE_SUCCESS); + OS_TaskDelay(500); + UtAssert_INT32_EQ(count, 1); +} + +void ESTaskTestSetup(void) +{ + UtTest_Add(TestCreateChild, NULL, NULL, "Test Create Child"); + UtTest_Add(TestExitChild, NULL, NULL, "Test Exit Child"); +}