Skip to content

Commit e80aae9

Browse files
authored
Merge pull request #1295 from nasa/integration-candidate
cFE Integration Candidate: 2021-04-13
2 parents eaa343c + 104e6e5 commit e80aae9

File tree

9 files changed

+225
-62
lines changed

9 files changed

+225
-62
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ The detailed cFE user's guide can be viewed at <https://github.com/nasa/cFS/blob
1010

1111
## Version History
1212

13+
### Development Build: v6.8.0-rc1+dev498
14+
15+
- Reports test failures as CFE events. Test status messages are now sent as Events rather than Syslog. This allows for more processing capability, and allows failures to be received externally (e.g. ground system).
16+
- See <https://github.com/nasa/cFE/pull/1295> and <https://github.com/nasa/cFS/pull/242>
17+
1318
### Development Build: v6.8.0-rc1+dev494
1419

1520
- Adds new tests for the ES Info APIs

modules/cfe_assert/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
project(CFE_ASSERT C)
22

3-
include_directories("${CFE_ASSERT_SOURCE_DIR}/inc")
4-
include_directories("${UT_ASSERT_SOURCE_DIR}/inc")
5-
63
# Create the app module
74
add_cfe_app(cfe_assert
85
src/cfe_assert_io.c
96
src/cfe_assert_init.c
107
$<TARGET_OBJECTS:ut_assert_pic>
118
)
129

10+
# publicize the interface to cfe_assert (and ut_assert)
11+
target_include_directories(cfe_assert PUBLIC
12+
${CFE_ASSERT_SOURCE_DIR}/inc
13+
$<TARGET_PROPERTY:ut_assert,INTERFACE_INCLUDE_DIRECTORIES>
14+
)

modules/cfe_assert/inc/cfe_assert.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
** Type Definitions
4444
*************************************************************************/
4545

46+
typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefix, const char *OutputMessage);
47+
4648
/*************************************************************************
4749
** Exported Functions
4850
*************************************************************************/
@@ -57,9 +59,27 @@
5759
** \par Assumptions, External Events, and Notes:
5860
** None
5961
**
60-
** \return Execution status, see \ref CFEReturnCodes
62+
** \return None
6163
**
6264
*************************************************************************/
6365
void CFE_Assert_AppMain(void);
6466

67+
/************************************************************************/
68+
/** \brief Register a test status callback
69+
*
70+
* \par Description
71+
* This user-supplied function will be invoked with the status
72+
* of each test and the associated message. It may be used to
73+
* write the test messages to a location other than CFE ES Syslog.
74+
*
75+
* \par Assumptions, External Events, and Notes:
76+
* None
77+
*
78+
* \param[in] Callback Callback function to invoke after every test
79+
*
80+
* \return None
81+
*
82+
*/
83+
void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback);
84+
6585
#endif /* CFE_ASSERT_H */

modules/cfe_assert/src/cfe_assert_init.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@
3131

3232
#include "cfe.h"
3333

34-
#include "cfe_assert.h"
34+
#include "cfe_assert_priv.h"
3535

3636
#include "uttest.h"
3737
#include "utbsp.h"
3838

39+
/*
40+
* Allows the test reports to be redirected to another destination
41+
*/
42+
void CFE_Assert_RegisterCallback(CFE_Assert_StatusCallback_t Callback)
43+
{
44+
CFE_Assert_Global.StatusCallback = Callback;
45+
}
46+
3947
/*
4048
* Initialization Function for this library
4149
*/

modules/cfe_assert/src/cfe_assert_io.c

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,16 @@
3131
#include <stdbool.h>
3232

3333
#include "cfe.h"
34+
#include "cfe_assert_priv.h"
3435

3536
#include "utbsp.h"
3637
#include "uttest.h"
3738

38-
/*
39-
** Local Variables
40-
*/
41-
typedef struct
42-
{
43-
uint32 CurrVerbosity;
44-
} BSP_UT_GlobalData_t;
45-
46-
BSP_UT_GlobalData_t BSP_UT_Global;
39+
CFE_Assert_Global_t CFE_Assert_Global;
4740

4841
void UT_BSP_Setup(void)
4942
{
50-
BSP_UT_Global.CurrVerbosity = (2 << UTASSERT_CASETYPE_PASS) - 1;
43+
CFE_Assert_Global.CurrVerbosity = (2 << UTASSERT_CASETYPE_PASS) - 1;
5144
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, "CFE FUNCTIONAL TEST");
5245
}
5346

@@ -59,55 +52,70 @@ void UT_BSP_StartTestSegment(uint32 SegmentNumber, const char *SegmentName)
5952
UT_BSP_DoText(UTASSERT_CASETYPE_BEGIN, ReportBuffer);
6053
}
6154

62-
void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
55+
void UT_BSP_SysLogStatusReport(uint8 MessageType, const char *Prefix, const char *OutputMessage)
6356
{
64-
const char *Prefix;
65-
uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType;
57+
uint32 MsgEnabled = CFE_Assert_Global.CurrVerbosity >> MessageType;
6658

6759
if (MsgEnabled & 1)
6860
{
69-
switch (MessageType)
70-
{
71-
case UTASSERT_CASETYPE_ABORT:
72-
Prefix = "ABORT";
73-
break;
74-
case UTASSERT_CASETYPE_FAILURE:
75-
Prefix = "FAIL";
76-
break;
77-
case UTASSERT_CASETYPE_MIR:
78-
Prefix = "MIR";
79-
break;
80-
case UTASSERT_CASETYPE_TSF:
81-
Prefix = "TSF";
82-
break;
83-
case UTASSERT_CASETYPE_TTF:
84-
Prefix = "TTF";
85-
break;
86-
case UTASSERT_CASETYPE_NA:
87-
Prefix = "N/A";
88-
break;
89-
case UTASSERT_CASETYPE_BEGIN:
90-
Prefix = "BEGIN";
91-
break;
92-
case UTASSERT_CASETYPE_END:
93-
Prefix = "END";
94-
break;
95-
case UTASSERT_CASETYPE_PASS:
96-
Prefix = "PASS";
97-
break;
98-
case UTASSERT_CASETYPE_INFO:
99-
Prefix = "INFO";
100-
break;
101-
case UTASSERT_CASETYPE_DEBUG:
102-
Prefix = "DEBUG";
103-
break;
104-
default:
105-
Prefix = "OTHER";
106-
break;
107-
}
108-
10961
CFE_ES_WriteToSysLog("[%5s] %s\n", Prefix, OutputMessage);
11062
}
63+
}
64+
65+
void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
66+
{
67+
const char * Prefix;
68+
CFE_Assert_StatusCallback_t StatusCallback;
69+
70+
switch (MessageType)
71+
{
72+
case UTASSERT_CASETYPE_ABORT:
73+
Prefix = "ABORT";
74+
break;
75+
case UTASSERT_CASETYPE_FAILURE:
76+
Prefix = "FAIL";
77+
break;
78+
case UTASSERT_CASETYPE_MIR:
79+
Prefix = "MIR";
80+
break;
81+
case UTASSERT_CASETYPE_TSF:
82+
Prefix = "TSF";
83+
break;
84+
case UTASSERT_CASETYPE_TTF:
85+
Prefix = "TTF";
86+
break;
87+
case UTASSERT_CASETYPE_NA:
88+
Prefix = "N/A";
89+
break;
90+
case UTASSERT_CASETYPE_BEGIN:
91+
Prefix = "BEGIN";
92+
break;
93+
case UTASSERT_CASETYPE_END:
94+
Prefix = "END";
95+
break;
96+
case UTASSERT_CASETYPE_PASS:
97+
Prefix = "PASS";
98+
break;
99+
case UTASSERT_CASETYPE_INFO:
100+
Prefix = "INFO";
101+
break;
102+
case UTASSERT_CASETYPE_DEBUG:
103+
Prefix = "DEBUG";
104+
break;
105+
default:
106+
Prefix = "OTHER";
107+
break;
108+
}
109+
110+
StatusCallback = CFE_Assert_Global.StatusCallback;
111+
112+
/* If not set, report status to CFE ES Syslog facility */
113+
if (StatusCallback == NULL)
114+
{
115+
StatusCallback = UT_BSP_SysLogStatusReport;
116+
}
117+
118+
StatusCallback(MessageType, Prefix, OutputMessage);
111119

112120
/*
113121
* If any ABORT (major failure) message is thrown,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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: cfe_assert.h
22+
**
23+
** Purpose:
24+
** Specification for the CFE assert (UT assert wrapper) functions.
25+
**
26+
*************************************************************************/
27+
28+
/**
29+
* @file
30+
*
31+
* Internal Declarations and prototypes for cfe_assert module
32+
*/
33+
34+
#ifndef CFE_ASSERT_PRIV_H
35+
#define CFE_ASSERT_PRIV_H
36+
37+
/************************************************************************
38+
** Includes
39+
*************************************************************************/
40+
#include "common_types.h"
41+
#include "cfe_assert.h"
42+
43+
/************************************************************************
44+
** Type Definitions
45+
*************************************************************************/
46+
47+
typedef struct
48+
{
49+
uint32 CurrVerbosity;
50+
51+
/**
52+
* Function to invoke to report test status
53+
*/
54+
CFE_Assert_StatusCallback_t StatusCallback;
55+
} CFE_Assert_Global_t;
56+
57+
extern CFE_Assert_Global_t CFE_Assert_Global;
58+
59+
#endif /* CFE_ASSERT_PRIV_H */
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
project(CFE_TESTRUNNER C)
22

3-
include_directories("inc")
4-
include_directories("${UT_ASSERT_SOURCE_DIR}/inc")
5-
63
# Create the app module
74
add_cfe_app(cfe_testrunner
85
src/cfe_testrunner_main.c
96
)
107

8+
target_include_directories(cfe_testrunner PUBLIC
9+
${CFE_TESTRUNNER_SOURCE_DIR}/inc
10+
)
11+
12+
# register the dependency on cfe_assert
13+
add_cfe_app_dependency(cfe_testrunner cfe_assert)

modules/cfe_testrunner/src/cfe_testrunner_main.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "cfe.h"
3333

3434
#include "cfe_testrunner.h"
35+
#include "cfe_assert.h"
3536

3637
#include "uttest.h"
3738
#include "utbsp.h"
@@ -56,6 +57,50 @@
5657
*/
5758
#define CFE_TESTRUNNER_START_DELAY 4000
5859

60+
/*
61+
* This uses the message type as the event ID, because these are already
62+
* sequential integers, and there is no need to redefine - this app has no other events.
63+
*/
64+
static CFE_EVS_BinFilter_t CFE_TR_EventFilters[] = {
65+
{UTASSERT_CASETYPE_ABORT, CFE_EVS_NO_FILTER}, {UTASSERT_CASETYPE_FAILURE, CFE_EVS_NO_FILTER},
66+
{UTASSERT_CASETYPE_TSF, CFE_EVS_NO_FILTER}, {UTASSERT_CASETYPE_TTF, CFE_EVS_NO_FILTER},
67+
{UTASSERT_CASETYPE_MIR, CFE_EVS_NO_FILTER}, {UTASSERT_CASETYPE_NA, CFE_EVS_NO_FILTER},
68+
{UTASSERT_CASETYPE_BEGIN, CFE_EVS_NO_FILTER}, {UTASSERT_CASETYPE_END, CFE_EVS_NO_FILTER},
69+
{UTASSERT_CASETYPE_INFO, CFE_EVS_NO_FILTER}, {UTASSERT_CASETYPE_PASS, CFE_EVS_NO_FILTER},
70+
{UTASSERT_CASETYPE_DEBUG, CFE_EVS_NO_FILTER},
71+
};
72+
73+
void CFE_TR_StatusReport(uint8 MessageType, const char *Prefix, const char *OutputMessage)
74+
{
75+
uint16 EventType;
76+
77+
switch (MessageType)
78+
{
79+
case UTASSERT_CASETYPE_ABORT:
80+
EventType = CFE_EVS_EventType_CRITICAL;
81+
break;
82+
case UTASSERT_CASETYPE_FAILURE:
83+
case UTASSERT_CASETYPE_TSF:
84+
case UTASSERT_CASETYPE_TTF:
85+
EventType = CFE_EVS_EventType_ERROR;
86+
break;
87+
case UTASSERT_CASETYPE_INFO:
88+
case UTASSERT_CASETYPE_MIR:
89+
case UTASSERT_CASETYPE_NA:
90+
EventType = CFE_EVS_EventType_INFORMATION;
91+
break;
92+
case UTASSERT_CASETYPE_BEGIN:
93+
case UTASSERT_CASETYPE_END:
94+
case UTASSERT_CASETYPE_PASS:
95+
case UTASSERT_CASETYPE_DEBUG:
96+
default:
97+
EventType = CFE_EVS_EventType_DEBUG;
98+
break;
99+
}
100+
101+
CFE_EVS_SendEvent(MessageType, EventType, "[%5s] %s", Prefix, OutputMessage);
102+
}
103+
59104
/*
60105
* Entry point for this application
61106
*/
@@ -64,6 +109,14 @@ void CFE_TR_AppMain(void)
64109
int32 rc;
65110
uint32 RunStatus;
66111

112+
rc = CFE_EVS_Register(CFE_TR_EventFilters, sizeof(CFE_TR_EventFilters) / sizeof(CFE_EVS_BinFilter_t),
113+
CFE_EVS_EventFilter_BINARY);
114+
if (rc != CFE_SUCCESS)
115+
{
116+
CFE_ES_WriteToSysLog("Error from CFE_EVS_Register: %08lx\n", (unsigned long)rc);
117+
return;
118+
}
119+
67120
/*
68121
* Delay until the system reaches "operational" state -- this is when all libs have initialized
69122
* and all apps have reached their RunLoop.
@@ -80,6 +133,11 @@ void CFE_TR_AppMain(void)
80133
*/
81134
UtAssert_EndTest();
82135

136+
/*
137+
* Use the local status report function for the remainder of tests
138+
*/
139+
CFE_Assert_RegisterCallback(CFE_TR_StatusReport);
140+
83141
/*
84142
* Note - in a normal app this would be a while loop,
85143
* but is just an "if" right now as it only runs once.

0 commit comments

Comments
 (0)