F´ Flight Software - C/C++ Documentation
NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
j
l
m
o
p
r
s
t
u
v
w
Variables
b
c
f
g
k
l
m
o
p
r
s
t
u
w
z
Typedefs
a
b
c
d
e
f
g
h
i
l
n
o
p
r
s
t
u
v
w
Enumerations
Enumerator
a
b
f
h
i
k
n
o
p
s
v
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
a
b
c
e
f
i
m
r
s
t
w
Enumerations
b
c
d
f
g
h
m
o
q
r
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Related Symbols
:
a
b
c
d
f
g
h
l
p
q
r
s
t
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
Functions
f
g
i
m
p
r
s
t
u
Variables
_
b
c
f
g
i
l
p
r
s
w
Typedefs
a
b
c
e
f
i
n
p
s
t
u
Enumerations
Enumerator
a
b
c
f
g
h
p
r
s
t
Macros
_
a
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
►
F´ Flight Software - C/C++ Documentation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
CmdTests.hpp
Go to the documentation of this file.
1
// ======================================================================
2
// \title CmdTests.hpp
3
// \author T. Chieu
4
// \brief hpp file for command tests
5
//
6
// \copyright
7
// Copyright (C) 2009-2023 California Institute of Technology.
8
// ALL RIGHTS RESERVED. United States Government Sponsorship
9
// acknowledged.
10
//
11
// ======================================================================
12
13
#include "test/ut/Tester.hpp"
14
15
// ----------------------------------------------------------------------
16
// Command test declarations
17
// ----------------------------------------------------------------------
18
19
#define CMD_TEST_INVOKE_DECL(TYPE) void invoke##TYPE##Command(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf);
20
21
#define CMD_TEST_INVOKE_DECLS \
22
CMD_TEST_INVOKE_DECL(NoArgs) \
23
CMD_TEST_INVOKE_DECL(Primitive) \
24
CMD_TEST_INVOKE_DECL(String) \
25
CMD_TEST_INVOKE_DECL(Enum) \
26
CMD_TEST_INVOKE_DECL(Array) \
27
CMD_TEST_INVOKE_DECL(Struct)
21
#define CMD_TEST_INVOKE_DECLS \
…
28
29
#define CMD_TEST_INVOKE_DECLS_ASYNC \
30
CMD_TEST_INVOKE_DECL(AsyncNoArgs) \
31
CMD_TEST_INVOKE_DECL(AsyncPrimitive) \
32
CMD_TEST_INVOKE_DECL(AsyncString) \
33
CMD_TEST_INVOKE_DECL(AsyncEnum) \
34
CMD_TEST_INVOKE_DECL(AsyncArray) \
35
CMD_TEST_INVOKE_DECL(AsyncStruct)
29
#define CMD_TEST_INVOKE_DECLS_ASYNC \
…
36
37
#define CMD_TEST_DECL(TYPE, ASYNC) void test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::TYPE& data);
38
39
#define CMD_TEST_DECLS \
40
CMD_TEST_INVOKE_DECLS \
41
CMD_TEST_DECL(NoParams, ) \
42
CMD_TEST_DECL(PrimitiveParams, ) \
43
CMD_TEST_DECL(CmdStringParams, ) \
44
CMD_TEST_DECL(EnumParam, ) \
45
CMD_TEST_DECL(ArrayParam, ) \
46
CMD_TEST_DECL(StructParam, )
39
#define CMD_TEST_DECLS \
…
47
48
#define CMD_TEST_DECLS_ASYNC \
49
CMD_TEST_INVOKE_DECLS_ASYNC \
50
CMD_TEST_DECL(NoParams, Async) \
51
CMD_TEST_DECL(PrimitiveParams, Async) \
52
CMD_TEST_DECL(CmdStringParams, Async) \
53
CMD_TEST_DECL(EnumParam, Async) \
54
CMD_TEST_DECL(ArrayParam, Async) \
55
CMD_TEST_DECL(StructParam, Async)
48
#define CMD_TEST_DECLS_ASYNC \
…
56
57
// ----------------------------------------------------------------------
58
// Command test definitions
59
// ----------------------------------------------------------------------
60
61
#define CMD_TEST_INVOKE_DEFS \
62
void Tester ::invokeNoArgsCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
63
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_NO_ARGS, 1, buf); \
64
} \
65
\
66
void Tester ::invokePrimitiveCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
67
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_PRIMITIVE, 1, buf); \
68
} \
69
\
70
void Tester ::invokeStringCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
71
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_STRINGS, 1, buf); \
72
} \
73
\
74
void Tester ::invokeEnumCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
75
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ENUM, 1, buf); \
76
} \
77
\
78
void Tester ::invokeArrayCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
79
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ARRAY, 1, buf); \
80
} \
81
\
82
void Tester ::invokeStructCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
83
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_STRUCT, 1, buf); \
84
}
61
#define CMD_TEST_INVOKE_DEFS \
…
85
86
#define CMD_TEST_INVOKE_DEFS_ASYNC \
87
void Tester ::invokeAsyncNoArgsCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
88
Fw::QueuedComponentBase::MsgDispatchStatus status; \
89
\
90
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_NO_ARGS, 1, buf); \
91
status = this->doDispatch(); \
92
\
93
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
94
} \
95
\
96
void Tester ::invokeAsyncPrimitiveCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
97
Fw::QueuedComponentBase::MsgDispatchStatus status; \
98
\
99
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_PRIMITIVE, 1, buf); \
100
status = this->doDispatch(); \
101
\
102
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
103
} \
104
\
105
void Tester ::invokeAsyncStringCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
106
Fw::QueuedComponentBase::MsgDispatchStatus status; \
107
\
108
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_STRINGS, 1, buf); \
109
status = this->doDispatch(); \
110
\
111
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
112
} \
113
\
114
void Tester ::invokeAsyncEnumCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
115
Fw::QueuedComponentBase::MsgDispatchStatus status; \
116
\
117
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_ENUM, 1, buf); \
118
status = this->doDispatch(); \
119
\
120
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
121
} \
122
\
123
void Tester ::invokeAsyncArrayCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
124
Fw::QueuedComponentBase::MsgDispatchStatus status; \
125
\
126
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_ARRAY, 1, buf); \
127
status = this->doDispatch(); \
128
\
129
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
130
} \
131
\
132
void Tester ::invokeAsyncStructCommand(NATIVE_INT_TYPE portNum, Fw::CmdArgBuffer& buf) { \
133
Fw::QueuedComponentBase::MsgDispatchStatus status; \
134
\
135
this->invoke_to_cmdOut(portNum, component.OPCODE_CMD_ASYNC_STRUCT, 1, buf); \
136
status = this->doDispatch(); \
137
\
138
ASSERT_EQ(status, Fw::QueuedComponentBase::MsgDispatchStatus::MSG_DISPATCH_OK); \
139
}
86
#define CMD_TEST_INVOKE_DEFS_ASYNC \
…
140
141
#define CMD_TEST_DEFS(ASYNC) \
142
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::NoParams& data) { \
143
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
144
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
145
\
146
component.regCommands(); \
147
\
148
Fw::CmdArgBuffer buf; \
149
\
150
/* Test success */
\
151
this->invoke##ASYNC##NoArgsCommand(portNum, buf); \
152
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
153
\
154
/* Test too many arguments */
\
155
buf.serialize(0); \
156
this->invoke##ASYNC##NoArgsCommand(portNum, buf); \
157
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
158
} \
159
\
160
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::PrimitiveParams& data) { \
161
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
162
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
163
\
164
component.regCommands(); \
165
\
166
Fw::CmdArgBuffer buf; \
167
\
168
/* Test incorrect deserialization of first argument */
\
169
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
170
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
171
\
172
/* Test incorrect deserialization of second argument */
\
173
buf.serialize(data.args.val1); \
174
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
175
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
176
\
177
/* Test incorrect deserialization of third argument */
\
178
buf.serialize(data.args.val2); \
179
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
180
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
181
\
182
/* Test incorrect deserialization of fourth argument */
\
183
buf.serialize(data.args.val3); \
184
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
185
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
186
\
187
/* Test incorrect deserialization of fifth argument */
\
188
buf.serialize(data.args.val4); \
189
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
190
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
191
\
192
/* Test incorrect deserialization of sixth argument */
\
193
buf.serialize(data.args.val5); \
194
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
195
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
196
\
197
/* Test success */
\
198
buf.serialize(data.args.val6); \
199
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
200
\
201
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
202
ASSERT_EQ(component.primitiveCmd.args.val1, data.args.val1); \
203
ASSERT_EQ(component.primitiveCmd.args.val2, data.args.val2); \
204
ASSERT_EQ(component.primitiveCmd.args.val3, data.args.val3); \
205
ASSERT_EQ(component.primitiveCmd.args.val4, data.args.val4); \
206
ASSERT_EQ(component.primitiveCmd.args.val5, data.args.val5); \
207
ASSERT_EQ(component.primitiveCmd.args.val6, data.args.val6); \
208
\
209
/* Test too many arguments */
\
210
buf.serialize(data.args.val5); \
211
this->invoke##ASYNC##PrimitiveCommand(portNum, buf); \
212
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
213
} \
214
\
215
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::CmdStringParams& data) { \
216
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
217
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
218
\
219
component.regCommands(); \
220
\
221
Fw::CmdArgBuffer buf; \
222
\
223
/* Test incorrect serialization of first argument */
\
224
this->invoke##ASYNC##StringCommand(portNum, buf); \
225
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
226
\
227
/* Test incorrect serialization of second argument */
\
228
buf.serialize(data.args.val1); \
229
this->invoke##ASYNC##StringCommand(portNum, buf); \
230
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
231
\
232
/* Test success */
\
233
buf.serialize(data.args.val2); \
234
this->invoke##ASYNC##StringCommand(portNum, buf); \
235
\
236
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
237
ASSERT_EQ(component.stringCmd.args.val1, data.args.val1); \
238
ASSERT_EQ(component.stringCmd.args.val2, data.args.val2); \
239
\
240
/* Test too many arguments */
\
241
buf.serialize(data.args.val1); \
242
this->invoke##ASYNC##StringCommand(portNum, buf); \
243
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
244
} \
245
\
246
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::EnumParam& data) { \
247
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
248
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
249
\
250
component.regCommands(); \
251
\
252
Fw::CmdArgBuffer buf; \
253
\
254
/* Test incorrect serialization of first argument */
\
255
this->invoke##ASYNC##EnumCommand(portNum, buf); \
256
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
257
\
258
/* Test success */
\
259
buf.serialize(data.args.val); \
260
this->invoke##ASYNC##EnumCommand(portNum, buf); \
261
\
262
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
263
ASSERT_EQ(component.enumCmd.args.val, data.args.val); \
264
\
265
/* Test too many arguments */
\
266
buf.serialize(data.args.val); \
267
this->invoke##ASYNC##EnumCommand(portNum, buf); \
268
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
269
} \
270
\
271
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::ArrayParam& data) { \
272
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
273
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
274
\
275
component.regCommands(); \
276
\
277
Fw::CmdArgBuffer buf; \
278
\
279
/* Test incorrect serialization of first argument */
\
280
this->invoke##ASYNC##ArrayCommand(portNum, buf); \
281
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
282
\
283
/* Test success */
\
284
buf.serialize(data.args.val); \
285
this->invoke##ASYNC##ArrayCommand(portNum, buf); \
286
\
287
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
288
ASSERT_EQ(component.arrayCmd.args.val, data.args.val); \
289
\
290
/* Test too many arguments */
\
291
buf.serialize(data.args.val); \
292
this->invoke##ASYNC##ArrayCommand(portNum, buf); \
293
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
294
} \
295
\
296
void Tester ::test##ASYNC##Command(NATIVE_INT_TYPE portNum, FppTest::Types::StructParam& data) { \
297
ASSERT_TRUE(component.isConnected_cmdRegOut_OutputPort(portNum)); \
298
ASSERT_TRUE(component.isConnected_cmdResponseOut_OutputPort(portNum)); \
299
\
300
component.regCommands(); \
301
\
302
Fw::CmdArgBuffer buf; \
303
\
304
/* Test incorrect serialization of first argument */
\
305
this->invoke##ASYNC##StructCommand(portNum, buf); \
306
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
307
\
308
/* Test success */
\
309
buf.serialize(data.args.val); \
310
this->invoke##ASYNC##StructCommand(portNum, buf); \
311
\
312
ASSERT_EQ(cmdResp, Fw::CmdResponse::OK); \
313
ASSERT_EQ(component.structCmd.args.val, data.args.val); \
314
\
315
/* Test too many arguments */
\
316
buf.serialize(data.args.val); \
317
this->invoke##ASYNC##StructCommand(portNum, buf); \
318
ASSERT_EQ(cmdResp, Fw::CmdResponse::FORMAT_ERROR); \
319
}
141
#define CMD_TEST_DEFS(ASYNC) \
…
FppTest
component
tests
CmdTests.hpp
Generated by
1.10.0