Skip to content

Commit d47b56c

Browse files
committed
Fix #1645, Add resource ID API functional tests
1 parent cfadad6 commit d47b56c

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

modules/cfe_testcase/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_cfe_app(cfe_testcase
77
src/es_cds_test.c
88
src/es_misc_test.c
99
src/es_mempool_test.c
10+
src/es_resource_id_test.c
1011
src/evs_send_test.c
1112
src/fs_header_test.c
1213
src/fs_util_test.c

modules/cfe_testcase/src/cfe_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void CFE_TestMain(void)
5555
ESInfoTestSetup();
5656
ESMemPoolTestSetup();
5757
ESMiscTestSetup();
58+
ESResourceIDTestSetup();
5859
ESTaskTestSetup();
5960
EVSSendTestSetup();
6061
FSHeaderTestSetup();

modules/cfe_testcase/src/cfe_test.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void ESCDSTestSetup(void);
8484
void ESInfoTestSetup(void);
8585
void ESMemPoolTestSetup(void);
8686
void ESMiscTestSetup(void);
87+
void ESResourceIDTestSetup(void);
8788
void ESTaskTestSetup(void);
8889
void EVSSendTestSetup(void);
8990
void FSHeaderTestSetup(void);
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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_resource_id_test.c
22+
**
23+
** Purpose:
24+
** Functional test of ES Resource ID 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 TestAppIDToIndex(void)
37+
{
38+
UtPrintf("Testing: CFE_ES_AppID_ToIndex");
39+
CFE_ES_AppId_t TestAppId;
40+
uint32 TestAppIdx;
41+
uint32 idx;
42+
UtAssert_INT32_EQ(CFE_ES_GetAppID(&TestAppId), CFE_SUCCESS);
43+
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, &TestAppIdx), CFE_SUCCESS);
44+
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, &idx), CFE_SUCCESS);
45+
UtAssert_UINT32_EQ(idx, TestAppIdx);
46+
47+
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(TestAppId, NULL), CFE_ES_BAD_ARGUMENT);
48+
UtAssert_INT32_EQ(CFE_ES_AppID_ToIndex(CFE_ES_APPID_UNDEFINED, &TestAppIdx), CFE_ES_ERR_RESOURCEID_NOT_VALID);
49+
}
50+
51+
void TestLibIDToIndex(void)
52+
{
53+
UtPrintf("Testing: CFE_ES_LibID_ToIndex");
54+
const char * LibName = "ASSERT_LIB";
55+
CFE_ES_LibId_t LibId;
56+
uint32 LibIdx;
57+
uint32 idx;
58+
UtAssert_INT32_EQ(CFE_ES_GetLibIDByName(&LibId, LibName), CFE_SUCCESS);
59+
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &LibIdx), CFE_SUCCESS);
60+
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, &idx), CFE_SUCCESS);
61+
UtAssert_UINT32_EQ(idx, LibIdx);
62+
63+
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(LibId, NULL), CFE_ES_BAD_ARGUMENT);
64+
UtAssert_INT32_EQ(CFE_ES_LibID_ToIndex(CFE_ES_LIBID_UNDEFINED, &LibIdx), CFE_ES_ERR_RESOURCEID_NOT_VALID);
65+
}
66+
67+
void TestTaskIDToIndex(void)
68+
{
69+
UtPrintf("Testing: CFE_ES_TaskID_ToIndex");
70+
CFE_ES_TaskId_t TaskId;
71+
uint32 TaskIdx;
72+
uint32 idx;
73+
UtAssert_INT32_EQ(CFE_ES_GetTaskID(&TaskId), CFE_SUCCESS);
74+
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &TaskIdx), CFE_SUCCESS);
75+
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, &idx), CFE_SUCCESS);
76+
UtAssert_UINT32_EQ(idx, TaskIdx);
77+
78+
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(TaskId, NULL), CFE_ES_BAD_ARGUMENT);
79+
UtAssert_INT32_EQ(CFE_ES_TaskID_ToIndex(CFE_ES_TASKID_UNDEFINED, &TaskIdx), CFE_ES_ERR_RESOURCEID_NOT_VALID);
80+
}
81+
82+
void TestCounterIDToIndex(void)
83+
{
84+
UtPrintf("Testing: CFE_ES_CounterID_ToIndex");
85+
const char * CounterName = "TEST_COUNTER";
86+
CFE_ES_CounterId_t CounterId;
87+
uint32 CounterIdx;
88+
uint32 idx;
89+
UtAssert_UINT32_EQ(CFE_ES_RegisterGenCounter(&CounterId, CounterName), CFE_SUCCESS);
90+
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, &CounterIdx), CFE_SUCCESS);
91+
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, &idx), CFE_SUCCESS);
92+
UtAssert_UINT32_EQ(idx, CounterIdx);
93+
94+
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CounterId, NULL), CFE_ES_BAD_ARGUMENT);
95+
UtAssert_INT32_EQ(CFE_ES_CounterID_ToIndex(CFE_ES_COUNTERID_UNDEFINED, &CounterIdx),
96+
CFE_ES_ERR_RESOURCEID_NOT_VALID);
97+
}
98+
99+
void ESResourceIDTestSetup(void)
100+
{
101+
UtTest_Add(TestAppIDToIndex, NULL, NULL, "Test Obtaining indices from App ID");
102+
UtTest_Add(TestLibIDToIndex, NULL, NULL, "Test Obtaining indices from Lib ID");
103+
UtTest_Add(TestTaskIDToIndex, NULL, NULL, "Test Obtaining indices from Task ID");
104+
UtTest_Add(TestCounterIDToIndex, NULL, NULL, "Test Obtaining indices from Counter ID");
105+
}

0 commit comments

Comments
 (0)