Skip to content

Commit 41667d6

Browse files
committed
Fix nasa#807, Add ES Application Behavior Functional Tests
1 parent eb9c523 commit 41667d6

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

modules/cfe_testcase/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_cfe_app(cfe_testcase
66
src/cfe_test.c
77
src/cfe_test_table.c
88
src/es_application_control_test.c
9+
src/es_behavior_test.c
910
src/es_info_test.c
1011
src/es_task_test.c
1112
src/es_cds_test.c

modules/cfe_testcase/src/cfe_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void CFE_TestMain(void)
5959
* Register test cases in UtAssert
6060
*/
6161
ESApplicationControlTestSetup();
62+
ESBehaviorestSetup();
6263
ESCDSTestSetup();
6364
ESCounterTestSetup();
6465
ESInfoTestSetup();
@@ -77,8 +78,8 @@ void CFE_TestMain(void)
7778
TBLInformationTestSetup();
7879
TBLRegistrationTestSetup();
7980
TimeArithmeticTestSetup();
80-
TimeCurrentTestSetup();
8181
TimeConversionTestSetup();
82+
TimeCurrentTestSetup();
8283
TimeMiscTestSetup();
8384

8485
/*

modules/cfe_testcase/src/cfe_test.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ bool TimeInRange(CFE_TIME_SysTime_t Time, CFE_TIME_SysTime_t Target, OS_time_t d
9090

9191
void CFE_TestMain(void);
9292
void ESApplicationControlTestSetup(void);
93+
void ESBehaviorestSetup(void);
9394
void ESCDSTestSetup(void);
9495
void ESCounterTestSetup(void);
9596
void ESInfoTestSetup(void);
@@ -108,8 +109,8 @@ void TBLContentMangTestSetup(void);
108109
void TBLInformationTestSetup(void);
109110
void TBLRegistrationTestSetup(void);
110111
void TimeArithmeticTestSetup(void);
111-
void TimeCurrentTestSetup(void);
112112
void TimeConversionTestSetup(void);
113+
void TimeCurrentTestSetup(void);
113114
void TimeMiscTestSetup(void);
114115

115116
#endif /* CFE_TEST_H */
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*************************************************************************
2+
**
3+
** GSC-18128-1, "Core Flight Executive Version 6.7"
4+
**
5+
** Copyright (c) 2006-2019 United States Government as represented by
6+
** the Administrator of the National Aeronautics and Space Administration.
7+
** All Rights Reserved.
8+
**
9+
** Licensed under the Apache License, Version 2.0 (the "License");
10+
** you may not use this file except in compliance with the License.
11+
** You may obtain a copy of the License at
12+
**
13+
** http://www.apache.org/licenses/LICENSE-2.0
14+
**
15+
** Unless required by applicable law or agreed to in writing, software
16+
** distributed under the License is distributed on an "AS IS" BASIS,
17+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
** See the License for the specific language governing permissions and
19+
** limitations under the License.
20+
**
21+
** File: es_behavior_test.c
22+
**
23+
** Purpose:
24+
** Functional test of basic ES Application Behavior APIs
25+
**
26+
** Demonstration of how to register and use the UT assert functions.
27+
**
28+
*************************************************************************/
29+
30+
/*
31+
* Includes
32+
*/
33+
34+
#include "cfe_test.h"
35+
36+
void TestRunCounter(void)
37+
{
38+
CFE_ES_TaskId_t TaskId;
39+
CFE_ES_TaskInfo_t TaskInfo;
40+
uint32 ExecutionCounter;
41+
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
42+
43+
UtPrintf("Testing: CFE_ES_RunLoop, CFE_ES_IncrementTaskCounter");
44+
45+
UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS);
46+
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
47+
ExecutionCounter = TaskInfo.ExecutionCounter;
48+
49+
UtAssert_BOOL_TRUE(CFE_ES_RunLoop(&RunStatus));
50+
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
51+
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 1));
52+
53+
UtAssert_BOOL_TRUE(CFE_ES_RunLoop(NULL));
54+
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
55+
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 2));
56+
57+
UtAssert_VOIDCALL(CFE_ES_IncrementTaskCounter());
58+
UtAssert_INT32_EQ(CFE_ES_GetTaskInfo(&TaskInfo, TaskId), CFE_SUCCESS);
59+
UtAssert_UINT32_EQ(TaskInfo.ExecutionCounter, (ExecutionCounter + 3));
60+
61+
RunStatus = CFE_ES_RunStatus_UNDEFINED;
62+
UtAssert_BOOL_FALSE(CFE_ES_RunLoop(&RunStatus));
63+
}
64+
65+
void TestWaitBehavior(void)
66+
{
67+
CFE_TIME_SysTime_t start;
68+
CFE_TIME_SysTime_t end;
69+
CFE_TIME_SysTime_t TimePassed;
70+
CFE_TIME_SysTime_t TimeExpected = {8, 0};
71+
72+
start = CFE_TIME_GetTime();
73+
74+
/* MinSystemStates of CFE_ES_SystemState_SHUTDOWN and higher not tested because they cause a shutdown */
75+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_UNDEFINED, 10000), CFE_SUCCESS);
76+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_EARLY_INIT, 10000), CFE_SUCCESS);
77+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_STARTUP, 10000), CFE_SUCCESS);
78+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 10000), CFE_SUCCESS);
79+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_APPS_INIT, 10000), CFE_SUCCESS);
80+
UtAssert_INT32_EQ(CFE_ES_WaitForSystemState(CFE_ES_SystemState_OPERATIONAL, 10000), CFE_SUCCESS);
81+
UtAssert_VOIDCALL(CFE_ES_WaitForStartupSync(10000));
82+
83+
end = CFE_TIME_GetTime();
84+
TimePassed = CFE_TIME_Subtract(end, start);
85+
86+
UtAssert_UINT32_EQ(CFE_TIME_Compare(TimePassed, TimeExpected), CFE_TIME_A_LT_B);
87+
}
88+
89+
void ESBehaviorestSetup(void)
90+
{
91+
UtTest_Add(TestRunCounter, NULL, NULL, "Test Run Counter");
92+
UtTest_Add(TestWaitBehavior, NULL, NULL, "Test Wait Behavior");
93+
}

modules/core_api/fsw/inc/cfe_es.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,9 @@ bool CFE_ES_RunLoop(uint32 *RunStatus);
391391
**
392392
** \param[in] MinSystemState Determine the state of the App
393393
** \param[in] TimeOutMilliseconds The timeout value in Milliseconds.
394-
** This parameter must be at least 1000. Lower values
395-
** will be rounded up. There is not an option to
396-
** wait indefinitely to avoid hanging a critical
397-
** application because a non-critical app did not start.
394+
** There is not an option to wait indefinitely to
395+
** avoid hanging a critical application because a
396+
** non-critical app did not start.
398397
**
399398
** \return Execution status, see \ref CFEReturnCodes
400399
** \retval #CFE_SUCCESS State successfully achieved

0 commit comments

Comments
 (0)