From b2d5374b6d1560a2a7ad5546493eff53c2eabeb7 Mon Sep 17 00:00:00 2001 From: Avi Date: Sat, 4 Mar 2023 17:40:31 +1000 Subject: [PATCH] Fix #85, Change EVS_Register failure from SendEvent to WriteToSysLog --- fsw/src/ds_app.c | 3 +-- unit-test/ds_app_tests.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fsw/src/ds_app.c b/fsw/src/ds_app.c index 414ab05..d6995a5 100644 --- a/fsw/src/ds_app.c +++ b/fsw/src/ds_app.c @@ -201,8 +201,7 @@ int32 DS_AppInitialize(void) if (Result != CFE_SUCCESS) { - CFE_EVS_SendEvent(DS_INIT_ERR_EID, CFE_EVS_EventType_ERROR, "Unable to register for EVS services, err = 0x%08X", - (unsigned int)Result); + CFE_ES_WriteToSysLog("DS App: Error registering for Event Services, RC = 0x%08X\n", (unsigned int)Result); } /* diff --git a/unit-test/ds_app_tests.c b/unit-test/ds_app_tests.c index 7d5fbf4..03c50b0 100644 --- a/unit-test/ds_app_tests.c +++ b/unit-test/ds_app_tests.c @@ -98,11 +98,11 @@ void DS_AppMain_Test_AppInitializeError(void) DS_AppMain(); /* Verify results */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, DS_EXIT_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_CRITICAL); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_EXIT_ERR_EID); + UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_CRITICAL); UtAssert_STUB_COUNT(CFE_ES_ExitApp, 1); - UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2); } void DS_AppMain_Test_SBError(void) @@ -166,6 +166,11 @@ void DS_AppInitialize_Test_Nominal(void) void DS_AppInitialize_Test_EVSRegisterError(void) { + int32 strCmpResult; + char ExpectedSysLogString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH]; + snprintf(ExpectedSysLogString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, + "DS App: Error registering for Event Services, RC = 0x%%08X\n"); + /* Set to generate error message DS_INIT_ERR_EID for EVS services */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, -1); @@ -179,11 +184,11 @@ void DS_AppInitialize_Test_EVSRegisterError(void) UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT / 2].FileHandle)); UtAssert_BOOL_FALSE(OS_ObjectIdDefined(DS_AppData.FileStatus[DS_DEST_FILE_CNT - 1].FileHandle)); - /* Note: not verifying that rest of DS_AppData is set to 0, because some elements of DS_AppData - * are modified by subfunctions, which we're not testing here */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, DS_INIT_ERR_EID); - UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); + call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); + UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); + + strCmpResult = strncmp(ExpectedSysLogString, context_CFE_ES_WriteToSysLog.Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH); + UtAssert_True(strCmpResult == 0, "Sys Log string matched expected result, '%s'", context_CFE_ES_WriteToSysLog.Spec); } void DS_AppInitialize_Test_SBCreatePipeError(void)