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 #25, RTS not loaded event no longer implies failure in text #27

Merged
merged 1 commit into from
May 11, 2022
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
12 changes: 6 additions & 6 deletions fsw/src/sc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ void SC_LoadDefaultTables(void)
char TableName[OS_MAX_PATH_LEN];
osal_id_t FileDesc = OS_OBJECT_ID_UNDEFINED;
int32 RtsIndex;
int32 RtsCount = 0;
int32 Status = OS_SUCCESS;
int32 NotLoadedCount = 0;
int32 Status = OS_SUCCESS;

/*
** Currently, only RTS tables are loaded during initialization.
Expand All @@ -572,7 +572,7 @@ void SC_LoadDefaultTables(void)
Status = CFE_TBL_Load(SC_OperData.RtsTblHandle[RtsIndex], CFE_TBL_SRC_FILE, TableName);
if (Status != CFE_SUCCESS)
{
RtsCount++;
NotLoadedCount++;

/* send an event for each failed load */
CFE_EVS_SendEvent(SC_RTS_LOAD_FAIL_DBG_EID, CFE_EVS_EventType_DEBUG,
Expand All @@ -581,17 +581,17 @@ void SC_LoadDefaultTables(void)
}
else
{
RtsCount++;
NotLoadedCount++;

/* send an event for each failed open */
CFE_EVS_SendEvent(SC_RTS_OPEN_FAIL_DBG_EID, CFE_EVS_EventType_DEBUG,
"RTS table %d file open failed, returned: 0x%08X", (int)RtsIndex, Status);
}
}

/* Display startup RTS load failure count */
/* Display startup RTS not loaded count */
CFE_EVS_SendEvent(SC_RTS_LOAD_FAIL_COUNT_INFO_EID, CFE_EVS_EventType_INFORMATION,
"RTS table file load failure count = %d", (int)RtsCount);
"RTS table files not loaded at initialization = %d of %d", (int)NotLoadedCount, SC_NUMBER_OF_RTS);

return;

Expand Down
72 changes: 4 additions & 68 deletions unit-test/sc_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,6 @@ void SC_AppInit_Test_InitTablesError(void)

void SC_InitTables_Test_Nominal(void)
{
uint32 ReturnValue;
int32 strCmpResult;
char ExpectedEventString[2][CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];

snprintf(ExpectedEventString[0], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "RTS table file load failure count = %%d");

snprintf(ExpectedEventString[1], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "SC Initialized. Version %%d.%%d.%%d.%%d");

/* Prevents error messages in call to SC_GetLoadTablePointers */
SC_APP_TEST_CFE_TBL_GetAddressHookCount = 0;
UT_SetHookFunction(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_GetAddressHookNominal, NULL);
Expand All @@ -608,32 +600,11 @@ void SC_InitTables_Test_Nominal(void)
UT_SetHookFunction(UT_KEY(CFE_TBL_Register), CFE_TBL_RegisterHook1, NULL);

/* Execute the function being tested */
ReturnValue = SC_AppInit();

/* Verify results */
UtAssert_True(ReturnValue == CFE_SUCCESS, "ReturnValue == CFE_SUCCESS");
UtAssert_INT32_EQ(SC_AppInit(), CFE_SUCCESS);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RTS_LOAD_FAIL_COUNT_INFO_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_INFORMATION);

strCmpResult =
strncmp(ExpectedEventString[0], context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_INIT_INF_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_INFORMATION);

strCmpResult =
strncmp(ExpectedEventString[1], context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec);

call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));

UtAssert_True(call_count_CFE_EVS_SendEvent == 2, "CFE_EVS_SendEvent was called %u time(s), expected 2",
call_count_CFE_EVS_SendEvent);

UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2);
} /* end SC_InitTables_Test_Nominal */

void SC_InitTables_Test_ErrorRegisterAllTables(void)
Expand Down Expand Up @@ -1332,17 +1303,6 @@ void SC_GetLoadTablePointers_Test_ErrorGetAddressLoadableRTS(void)

void SC_LoadDefaultTables_Test(void)
{
int32 strCmpResult;
char ExpectedEventString[3][CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];

snprintf(ExpectedEventString[0], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"RTS table %%d failed to load, returned: 0x%%08X");

snprintf(ExpectedEventString[1], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"RTS table %%d file open failed, returned: 0x%%08X");

snprintf(ExpectedEventString[2], CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "RTS table file load failure count = %%d");

/* Set OS_open to return 1, in order to enter if-block "if (FileDesc >= 0)" */
UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, OS_SUCCESS);

Expand All @@ -1353,38 +1313,14 @@ void SC_LoadDefaultTables_Test(void)
UT_SetDeferredRetcode(UT_KEY(OS_OpenCreate), 1, -1);

/* Execute the function being tested */
SC_LoadDefaultTables();
UtAssert_VOIDCALL(SC_LoadDefaultTables());

/* Verify results */
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, SC_RTS_LOAD_FAIL_DBG_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_DEBUG);

strCmpResult =
strncmp(ExpectedEventString[0], context_CFE_EVS_SendEvent[0].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[0].Spec);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventID, SC_RTS_OPEN_FAIL_DBG_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[1].EventType, CFE_EVS_EventType_DEBUG);

strCmpResult =
strncmp(ExpectedEventString[1], context_CFE_EVS_SendEvent[1].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[1].Spec);

UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[2].EventID, SC_RTS_LOAD_FAIL_COUNT_INFO_EID);
UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[2].EventType, CFE_EVS_EventType_INFORMATION);

strCmpResult =
strncmp(ExpectedEventString[2], context_CFE_EVS_SendEvent[2].Spec, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH);

UtAssert_True(strCmpResult == 0, "Event string matched expected result, '%s'", context_CFE_EVS_SendEvent[2].Spec);

call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent));

UtAssert_True(call_count_CFE_EVS_SendEvent == 3, "CFE_EVS_SendEvent was called %u time(s), expected 3",
call_count_CFE_EVS_SendEvent);

UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 3);
} /* end SC_LoadDefaultTables_Test */

void UtTest_Setup(void)
Expand Down