Skip to content

Commit

Permalink
Merge pull request #1804 from nmullane/fix1760-check-maximum-resource…
Browse files Browse the repository at this point in the history
…-id-index

Fix #1760, check resource ID idx is less than max
  • Loading branch information
astrogeco authored Aug 13, 2021
2 parents 14a16e3 + 6214ff2 commit 5fd8c21
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/cfe_testcase/src/es_resource_id_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void TestAppIDToIndex(void)
UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, &TestAppIdx), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, &idx), CFE_SUCCESS);
UtAssert_INT32_LTEQ(TestAppIdx, CFE_PLATFORM_ES_MAX_APPLICATIONS);
UtAssert_UINT32_EQ(idx, TestAppIdx);

UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, NULL), CFE_ES_BAD_ARGUMENT);
Expand All @@ -58,6 +59,7 @@ void TestLibIDToIndex(void)
UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibId, LibName), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &LibIdx), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &idx), CFE_SUCCESS);
UtAssert_INT32_LTEQ(LibIdx, CFE_PLATFORM_ES_MAX_LIBRARIES);
UtAssert_UINT32_EQ(idx, LibIdx);

UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, NULL), CFE_ES_BAD_ARGUMENT);
Expand All @@ -73,6 +75,7 @@ void TestTaskIDToIndex(void)
UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &TaskIdx), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &idx), CFE_SUCCESS);
UtAssert_INT32_LTEQ(TaskIdx, OS_MAX_TASKS);
UtAssert_UINT32_EQ(idx, TaskIdx);

UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, NULL), CFE_ES_BAD_ARGUMENT);
Expand All @@ -89,11 +92,15 @@ void TestCounterIDToIndex(void)
UtAssert_UINT32_EQ(CFE_ES_RegisterGenCounter(&CounterId, CounterName), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, &CounterIdx), CFE_SUCCESS);
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, &idx), CFE_SUCCESS);
UtAssert_INT32_LTEQ(CounterIdx, CFE_PLATFORM_ES_MAX_GEN_COUNTERS);
UtAssert_UINT32_EQ(idx, CounterIdx);

UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, NULL), CFE_ES_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CFE_ES_COUNTERID_UNDEFINED, &CounterIdx),
CFE_ES_ERR_RESOURCEID_NOT_VALID);

/* Unregister Counter */
UtAssert_INT32_EQ(CFE_ES_DeleteGenCounter(CounterId), CFE_SUCCESS);
}

void ESResourceIDTestSetup(void)
Expand Down

0 comments on commit 5fd8c21

Please sign in to comment.