Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #807, Add ES Application Behavior Functional Tests #1778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/cfe_testcase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_cfe_app(cfe_testcase
src/cfe_test.c
src/cfe_test_table.c
src/es_application_control_test.c
src/es_behavior_test.c
src/es_info_test.c
src/es_task_test.c
src/es_cds_test.c
Expand Down
3 changes: 2 additions & 1 deletion modules/cfe_testcase/src/cfe_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void CFE_TestMain(void)
* Register test cases in UtAssert
*/
ESApplicationControlTestSetup();
ESBehaviorestSetup();
ESCDSTestSetup();
ESCounterTestSetup();
ESInfoTestSetup();
Expand All @@ -77,8 +78,8 @@ void CFE_TestMain(void)
TBLInformationTestSetup();
TBLRegistrationTestSetup();
TimeArithmeticTestSetup();
TimeCurrentTestSetup();
TimeConversionTestSetup();
TimeCurrentTestSetup();
skliper marked this conversation as resolved.
Show resolved Hide resolved
TimeMiscTestSetup();

/*
Expand Down
3 changes: 2 additions & 1 deletion modules/cfe_testcase/src/cfe_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t d

void CFE_TestMain(void);
void ESApplicationControlTestSetup(void);
void ESBehaviorestSetup(void);
void ESCDSTestSetup(void);
void ESCounterTestSetup(void);
void ESInfoTestSetup(void);
Expand All @@ -108,8 +109,8 @@ void TBLContentMangTestSetup(void);
void TBLInformationTestSetup(void);
void TBLRegistrationTestSetup(void);
void TimeArithmeticTestSetup(void);
void TimeCurrentTestSetup(void);
void TimeConversionTestSetup(void);
void TimeCurrentTestSetup(void);
skliper marked this conversation as resolved.
Show resolved Hide resolved
void TimeMiscTestSetup(void);

#endif /* CFE_TEST_H */
93 changes: 93 additions & 0 deletions modules/cfe_testcase/src/es_behavior_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*************************************************************************
**
** 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_behavior_test.c
**
** Purpose:
** Functional test of basic ES Application Behavior APIs
**
** Demonstration of how to register and use the UT assert functions.
**
*************************************************************************/

/*
* Includes
*/

#include "cfe_test.h"

void TestRunCounter(void)
{
CFE_ES_TaskId_t TaskId;
CFE_ES_TaskInfo_t TaskInfo;
uint32 ExecutionCounter;
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;

UtPrintf("Testing: CFE_ES_RunLoop, CFE_ES_IncrementTaskCounter");

UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
ExecutionCounter = TaskInfo.ExecutionCounter;

UtAssert_BOOL_TRUE(CFE_ES_RunLoop(&RunStatus));
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 1));

UtAssert_BOOL_TRUE(CFE_ES_RunLoop(NULL));
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 2));

UtAssert_VOIDCALL(CFE_ES_IncrementTaskCounter());
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 3));

RunStatus = CFE_ES_RunStatus_UNDEFINED;
UtAssert_BOOL_FALSE(CFE_ES_RunLoop(&RunStatus));
}

void TestWaitBehavior(void)
{
CFE_TIME_SysTime_t start;
CFE_TIME_SysTime_t end;
CFE_TIME_SysTime_t TimePassed;
CFE_TIME_SysTime_t TimeExpected = {8, 0};

start = CFE_TIME_GetTime();

/* MinSystemStates of CFE_ES_SystemState_SHUTDOWN and higher not tested because they cause a shutdown */
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_UNDEFINED, 10000), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_EARLY_INIT, 10000), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_STARTUP, 10000), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 10000), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_APPS_INIT, 10000), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_OPERATIONAL, 10000), CFE_SUCCESS);
UtAssert_VOIDCALL(CFE_ES_WaitForStartupSync(10000));

end = CFE_TIME_GetTime();
TimePassed = CFE_TIME_Subtract(end, start);

UtAssert_UINT32_EQ(CFE_TIME_Compare(TimePassed, TimeExpected), CFE_TIME_A_LT_B);
}

void ESBehaviorestSetup(void)
{
UtTest_Add(TestRunCounter, NULL, NULL, "Test Run Counter");
UtTest_Add(TestWaitBehavior, NULL, NULL, "Test Wait Behavior");
}
7 changes: 3 additions & 4 deletions modules/core_api/fsw/inc/cfe_es.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,9 @@ bool CFE_ES_RunLoop(uint32 *RunStatus);
**
** \param[in] MinSystemState Determine the state of the App
** \param[in] TimeOutMilliseconds The timeout value in Milliseconds.
** This parameter must be at least 1000. Lower values
** will be rounded up. There is not an option to
** wait indefinitely to avoid hanging a critical
** application because a non-critical app did not start.
** There is not an option to wait indefinitely to
** avoid hanging a critical application because a
** non-critical app did not start.
**
** \return Execution status, see \ref CFEReturnCodes
** \retval #CFE_SUCCESS State successfully achieved
Expand Down