Skip to content

Commit 4594d75

Browse files
authored
Merge pull request #1657 from zanzaben/fix1651_SB_Pipe_Mang_Func_Tests
Fix #1651, Add SB Pipe Management Functional Tests.
2 parents fe8fced + 568f0a3 commit 4594d75

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-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,133 @@
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_INT32_EQ(CFE_SB_PipeId_ToIndex(CFE_SB_INVALID_PIPE, &Idx), CFE_ES_ERR_RESOURCEID_NOT_VALID);
69+
UtAssert_INT32_EQ(CFE_SB_PipeId_ToIndex(PipeId, NULL), CFE_ES_BAD_ARGUMENT);
70+
71+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
72+
}
73+
74+
void TestPipeOptions(void)
75+
{
76+
CFE_SB_PipeId_t PipeId;
77+
uint16 PipeDepth = 10;
78+
const char PipeName[] = "Test Pipe";
79+
uint8 Opts = 2;
80+
uint8 OptsBuff;
81+
82+
UtPrintf("Testing: CFE_SB_SetPipeOpts, CFE_SB_GetPipeOpts");
83+
84+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SUCCESS);
85+
86+
UtAssert_INT32_EQ(CFE_SB_SetPipeOpts(PipeId, Opts), CFE_SUCCESS);
87+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(PipeId, &OptsBuff), CFE_SUCCESS);
88+
UtAssert_UINT32_EQ(Opts, OptsBuff);
89+
90+
UtAssert_INT32_EQ(CFE_SB_SetPipeOpts(CFE_SB_INVALID_PIPE, Opts), CFE_SB_BAD_ARGUMENT);
91+
92+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(CFE_SB_INVALID_PIPE, &OptsBuff), CFE_SB_BAD_ARGUMENT);
93+
UtAssert_INT32_EQ(CFE_SB_GetPipeOpts(PipeId, NULL), CFE_SB_BAD_ARGUMENT);
94+
95+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
96+
}
97+
98+
void TestPipeName(void)
99+
{
100+
CFE_SB_PipeId_t PipeId;
101+
uint16 PipeDepth = 10;
102+
const char PipeName[] = "Test Pipe";
103+
char PipeNameBuf[OS_MAX_API_NAME];
104+
CFE_SB_PipeId_t PipeIdBuff;
105+
const char InvalidPipeName[] = "Invalid Pipe";
106+
107+
UtPrintf("Testing: CFE_SB_GetPipeName, CFE_SB_GetPipeIdByName");
108+
109+
UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SUCCESS);
110+
111+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, sizeof(PipeNameBuf), PipeId), CFE_SUCCESS);
112+
UtAssert_StrCmp(PipeNameBuf, PipeName, "CFE_SB_GetPipeName() = %s", PipeNameBuf);
113+
114+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(&PipeIdBuff, PipeName), CFE_SUCCESS);
115+
cFE_FTAssert_ResourceID_EQ(PipeId, PipeIdBuff);
116+
117+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(NULL, sizeof(PipeNameBuf), PipeId), CFE_SB_BAD_ARGUMENT);
118+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, 0, PipeId), CFE_SB_BAD_ARGUMENT);
119+
UtAssert_INT32_EQ(CFE_SB_GetPipeName(PipeNameBuf, sizeof(PipeNameBuf), CFE_SB_INVALID_PIPE), CFE_SB_BAD_ARGUMENT);
120+
121+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(NULL, PipeName), CFE_SB_BAD_ARGUMENT);
122+
UtAssert_INT32_EQ(CFE_SB_GetPipeIdByName(&PipeIdBuff, InvalidPipeName), CFE_SB_BAD_ARGUMENT);
123+
124+
UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId), CFE_SUCCESS);
125+
}
126+
127+
void SBPipeMangSetup(void)
128+
{
129+
UtTest_Add(TestPipeCreate, NULL, NULL, "Test Pipe Create");
130+
UtTest_Add(TestPipeIndex, NULL, NULL, "Test Pipe Index");
131+
UtTest_Add(TestPipeOptions, NULL, NULL, "Test Pipe Options");
132+
UtTest_Add(TestPipeName, NULL, NULL, "Test Pipe Name");
133+
}

0 commit comments

Comments
 (0)