forked from nasa/fprime
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQueuedTestTester.hpp
More file actions
248 lines (189 loc) · 8.58 KB
/
QueuedTestTester.hpp
File metadata and controls
248 lines (189 loc) · 8.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// ======================================================================
// \title QueuedTest/test/ut/QueuedTestTester.hpp
// \author tiffany
// \brief hpp file for QueuedTest test harness implementation class
// ======================================================================
#ifndef QUEUED_TEST_TESTER_HPP
#define QUEUED_TEST_TESTER_HPP
#include "FppTest/component/active/SerialPortIndexEnumAc.hpp"
#include "FppTest/component/active/TypedPortIndexEnumAc.hpp"
#include "FppTest/component/queued/QueuedTest.hpp"
#include "FppTest/component/tests/CmdTests.hpp"
#include "FppTest/component/tests/EventTests.hpp"
#include "FppTest/component/tests/ExternalParamTests.hpp"
#include "FppTest/component/tests/InternalInterfaceTests.hpp"
#include "FppTest/component/tests/ParamTests.hpp"
#include "FppTest/component/tests/PortTests.hpp"
#include "FppTest/component/tests/TlmTests.hpp"
#include "FppTest/component/types/FormalParamTypes.hpp"
#include "QueuedTestGTestBase.hpp"
class QueuedTestTester : public QueuedTestGTestBase {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
public:
// Maximum size of histories storing events, telemetry, and port outputs
static const U32 MAX_HISTORY_SIZE = 100;
// Instance ID supplied to the component instance under test
static const FwEnumStoreType TEST_INSTANCE_ID = 0;
// Queue depth supplied to component instance under test
static const FwSizeType TEST_INSTANCE_QUEUE_DEPTH = 10;
//! Construct object QueuedTestTester
//!
QueuedTestTester();
//! Destroy object QueuedTestTester
//!
~QueuedTestTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
PORT_TEST_DECLS
PORT_TEST_DECLS_ASYNC
CMD_TEST_DECLS
CMD_TEST_DECLS_ASYNC
EVENT_TEST_DECLS
TLM_TEST_DECLS
void testParam();
PARAM_CMD_TEST_DECLS
void testExternalParam();
EXTERNAL_PARAM_CMD_TEST_DECLS
INTERNAL_INT_TEST_DECLS
void testTime();
void testOverflowAssert();
void testOverflowDrop();
void testOverflowHook();
private:
#include "FppTest/component/common/tester.hpp"
private:
// ----------------------------------------------------------------------
// Handlers for serial from ports
// ----------------------------------------------------------------------
//! Handler for from_serialOut
//!
void from_serialOut_handler(FwIndexType portNum, //!< The port number
Fw::LinearBufferBase& Buffer //!< The serialization buffer
);
public:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
//! Connect ports
//!
void connectPorts();
//! Connect async ports
void connectAsyncPorts();
//! Connect prmSetIn port
void connectPrmSetIn();
//! Connect timeGetOut port
void connectTimeGetOut();
//! Connect serial ports to special ports
void connectSpecialPortsSerial();
//! Set prmValid
void setPrmValid(Fw::ParamValid valid);
//! Call doDispatch() on component under test
Fw::QueuedComponentBase::MsgDispatchStatus doDispatch();
//! Initialize components
//!
void initComponents();
//! Check successful status of a serial port invocation
void checkSerializeStatusSuccess();
//! Check unsuccessful status of a serial port invocation
void checkSerializeStatusBufferEmpty();
private:
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
//! The component under test
//!
QueuedTest component;
// Values returned by typed output ports
FppTest::Types::BoolType noParamReturnVal;
FppTest::Types::U32Type primitiveReturnVal;
FppTest::Types::EnumType enumReturnVal;
FppTest::Types::ArrayType arrayReturnVal;
FppTest::Types::StructType structReturnVal;
FppTest::Types::StringType stringReturnVal;
FppTest::Types::StringType stringAliasReturnVal;
FppTest::Types::AliasStringArrayType arrayStringAliasReturnVal;
// Buffers from serial output ports;
U8 primitiveData[PrimitiveArgsPortBuffer::CAPACITY];
U8 stringData[StringArgsPortBuffer::CAPACITY];
U8 enumData[EnumArgsPortBuffer::CAPACITY];
U8 arrayData[ArrayArgsPortBuffer::CAPACITY];
U8 structData[StructArgsPortBuffer::CAPACITY];
U8 serialData[SERIAL_ARGS_BUFFER_CAPACITY];
Fw::SerialBuffer primitiveBuf;
Fw::SerialBuffer stringBuf;
Fw::SerialBuffer enumBuf;
Fw::SerialBuffer arrayBuf;
Fw::SerialBuffer structBuf;
Fw::SerialBuffer serialBuf;
// Parameter test values
FppTest::Types::BoolParam boolPrm;
FppTest::Types::U32Param u32Prm;
FppTest::Types::PrmStringParam stringPrm;
FppTest::Types::EnumParam enumPrm;
FppTest::Types::ArrayParam arrayPrm;
FppTest::Types::StructParam structPrm;
Fw::ParamValid prmValid;
// Time test values
Fw::Time time;
//! External Parameter Delegate
class QueuedTestComponentBaseParamExternalDelegate : public Fw::ParamExternalDelegate {
public:
// ----------------------------------------------------------------------
// Parameter validity flags
// ----------------------------------------------------------------------
//! True if ParamBoolExternal was successfully received
Fw::ParamValid m_param_ParamBoolExternal_valid;
//! True if ParamI32External was successfully received
Fw::ParamValid m_param_ParamI32External_valid;
//! True if ParamStringExternal was successfully received
Fw::ParamValid m_param_ParamStringExternal_valid;
//! True if ParamEnumExternal was successfully received
Fw::ParamValid m_param_ParamEnumExternal_valid;
//! True if ParamArrayExternal was successfully received
Fw::ParamValid m_param_ParamArrayExternal_valid;
//! True if ParamStructExternal was successfully received
Fw::ParamValid m_param_ParamStructExternal_valid;
public:
// ----------------------------------------------------------------------
// Parameter variables
// ----------------------------------------------------------------------
//! Parameter ParamBoolExternal
bool m_param_ParamBoolExternal;
//! Parameter ParamI32External
I32 m_param_ParamI32External;
//! Parameter ParamStringExternal
Fw::ParamString m_param_ParamStringExternal;
//! Parameter ParamEnumExternal
FormalParamEnum m_param_ParamEnumExternal;
//! Parameter ParamArrayExternal
FormalParamArray m_param_ParamArrayExternal;
//! Parameter ParamStructExternal
FormalParamStruct m_param_ParamStructExternal;
public:
// ----------------------------------------------------------------------
// Unit test implementation of external parameter delegate serialization/deserialization
// ----------------------------------------------------------------------
//! Parameter deserialization function for external parameter unit testing
Fw::SerializeStatus deserializeParam(
const FwPrmIdType base_id, //!< The component base parameter ID to deserialize
const FwPrmIdType local_id, //!< The parameter local ID to deserialize
const Fw::ParamValid prmStat, //!< The parameter validity status
Fw::SerialBufferBase& buff //!< The buffer containing the parameter to deserialize
) override;
//! Parameter serialization function for external parameter unit testing
Fw::SerializeStatus serializeParam(const FwPrmIdType base_id, //!< The component base parameter ID to serialize
const FwPrmIdType local_id, //!< The parameter local ID to serialize
Fw::SerialBufferBase& buff //!< The buffer to serialize the parameter into
) const override;
};
// ----------------------------------------------------------------------
// Parameter delegates
// ----------------------------------------------------------------------
//! Delegate to serialize/deserialize an externally stored parameter
QueuedTestComponentBaseParamExternalDelegate paramTesterDelegate;
};
#endif