Skip to content

Commit c0cb3c6

Browse files
committed
Fix #1651, Add SB Pipe Management Functional Tests.
1 parent 063b4d8 commit c0cb3c6

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed

modules/cfe_testcase/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ add_cfe_app(cfe_testcase
88
src/es_misc_test.c
99
src/es_mempool_test.c
1010
src/fs_header_test.c
11+
src/sb_pipe_mang_test.c
1112
src/time_current_test.c
1213
)
1314

modules/cfe_testcase/src/cfe_test.c

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void CFE_TestMain(void)
5757
ESMiscTestSetup();
5858
ESMemPoolTestSetup();
5959
FSHeaderTestSetup();
60+
SBPipeMangSetup();
6061
TimeCurrentTestSetup();
6162

6263
/*

modules/cfe_testcase/src/cfe_test.h

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void ESCDSTestSetup(void);
7979
void ESMiscTestSetup(void);
8080
void ESMemPoolTestSetup(void);
8181
void FSHeaderTestSetup(void);
82+
void SBPipeMangSetup(void);
8283
void TimeCurrentTestSetup(void);
8384

8485
#endif /* CFE_TEST_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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_info_test.c
22+
**
23+
** Purpose:
24+
** Functional test of Sb Pipe Managment 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 TestPipeCreate(void)
37+
{
38+
CFE_SB_PipeId_t PipeId1;
39+
uint16 PipeDepth = 10;
40+
const char PipeName[] = "Test Pipe";
41+
42+
UtPrintf("Testing: CFE_SB_CreatePipe, CFE_SB_DeletePipe");
43+
44+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, PipeDepth, PipeName), CFE_SUCCESS);
45+
46+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(NULL, PipeDepth, PipeName), CFE_SB_BAD_ARGUMENT);
47+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, OS_QUEUE_MAX_DEPTH + 5, PipeName), CFE_SB_BAD_ARGUMENT);
48+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 0, PipeName), CFE_SB_BAD_ARGUMENT);
49+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, PipeDepth, NULL), CFE_SB_PIPE_CR_ERR);
50+
51+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS);
52+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SB_BAD_ARGUMENT);
53+
}
54+
55+
void TestPipeIndex(void)
56+
{
57+
CFE_SB_PipeId_t PipeId;
58+
uint16 PipeDepth = 10;
59+
const char PipeName[] = "Test Pipe";
60+
uint32 Idx;
61+
62+
UtPrintf("Testing: CFE_SB_PipeId_ToIndex");
63+
64+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SUCCESS);
65+
66+
UtAssert_INT32_EQ(CFE_SB_PipeId_ToIndex(PipeId, &Idx), CFE_SUCCESS);
67+
68+
UtAssert_UINT32_EQ(Idx, 13);
69+
70+
UtAssert_INT32_EQ(CFE_SB_PipeId_ToIndex(CFE_SB_INVALID_PIPE, &Idx), CFE_ES_ERR_RESOURCEID_NOT_VALID);
71+
UtAssert_INT32_EQ(CFE_SB_PipeId_ToIndex(PipeId, NULL), CFE_ES_BAD_ARGUMENT);
72+
73+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
74+
}
75+
76+
void TestPipeOptions(void)
77+
{
78+
CFE_SB_PipeId_t PipeId;
79+
uint16 PipeDepth = 10;
80+
const char PipeName[] = "Test Pipe";
81+
uint8 Opts = 2;
82+
uint8 OptsBuff;
83+
84+
UtPrintf("Testing: CFE_SB_SetPipeOpts, CFE_SB_GetPipeOpts");
85+
86+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SUCCESS);
87+
88+
UtAssert_INT32_EQ(CFE_SB_SetPipeOpts(PipeId, Opts), CFE_SUCCESS);
89+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(PipeId, &OptsBuff), CFE_SUCCESS);
90+
UtAssert_UINT32_EQ(Opts, OptsBuff);
91+
92+
UtAssert_INT32_EQ(CFE_SB_SetPipeOpts(CFE_SB_INVALID_PIPE, Opts), CFE_SB_BAD_ARGUMENT);
93+
94+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(CFE_SB_INVALID_PIPE, &OptsBuff), CFE_SB_BAD_ARGUMENT);
95+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(PipeId, NULL), CFE_SB_BAD_ARGUMENT);
96+
97+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
98+
}
99+
100+
void TestPipeName(void)
101+
{
102+
CFE_SB_PipeId_t PipeId;
103+
uint16 PipeDepth = 10;
104+
const char PipeName[] = "Test Pipe";
105+
char PipeNameBuf[OS_MAX_API_NAME];
106+
CFE_SB_PipeId_t PipeIdBuff;
107+
const char InvalidPipeName[] = "Invalid Pipe";
108+
109+
UtPrintf("Testing: CFE_SB_GetPipeName, CFE_SB_GetPipeIdByName");
110+
111+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SUCCESS);
112+
113+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, sizeof(PipeNameBuf), PipeId), CFE_SUCCESS);
114+
UtAssert_StrCmp(PipeNameBuf, PipeName, "CFE_SB_GetPipeName() = %s", PipeNameBuf);
115+
116+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(&PipeIdBuff, PipeName), CFE_SUCCESS);
117+
cFE_FTAssert_ResourceID_EQ(PipeId, PipeIdBuff);
118+
119+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(NULL, sizeof(PipeNameBuf), PipeId), CFE_SB_BAD_ARGUMENT);
120+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, 0, PipeId), CFE_SB_BAD_ARGUMENT);
121+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, OS_MAX_API_NAME * 4, PipeId), CFE_SB_BAD_ARGUMENT);
122+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, sizeof(PipeNameBuf), CFE_SB_INVALID_PIPE), CFE_SB_BAD_ARGUMENT);
123+
124+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(NULL, PipeName), CFE_SB_BAD_ARGUMENT);
125+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(&PipeIdBuff, InvalidPipeName), CFE_SB_BAD_ARGUMENT);
126+
127+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
128+
}
129+
130+
void SBPipeMangSetup(void)
131+
{
132+
UtTest_Add(TestPipeCreate, NULL, NULL, "Test Pipe Create");
133+
UtTest_Add(TestPipeIndex, NULL, NULL, "Test Pipe Index");
134+
UtTest_Add(TestPipeOptions, NULL, NULL, "Test Pipe Options");
135+
}

0 commit comments

Comments
 (0)