F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
TesterHelpers.cpp
Go to the documentation of this file.
1// ======================================================================
2// \title TesterHelpers.cpp
3// \author T. Chieu
4// \brief cpp file for tester helper functions
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// Helper methods
17// ----------------------------------------------------------------------
18
19void Tester ::connectPorts() {
20 // arrayArgsGuarded
21 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
22 this->connect_to_arrayArgsGuarded(i, this->component.get_arrayArgsGuarded_InputPort(i));
23 }
24
25 // arrayArgsSync
26 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
27 this->connect_to_arrayArgsSync(i, this->component.get_arrayArgsSync_InputPort(i));
28 }
29
30 // arrayReturnGuarded
31 this->connect_to_arrayReturnGuarded(0, this->component.get_arrayReturnGuarded_InputPort(0));
32
33 // arrayReturnSync
34 this->connect_to_arrayReturnSync(0, this->component.get_arrayReturnSync_InputPort(0));
35
36 // cmdIn
37 this->connect_to_cmdIn(0, this->component.get_cmdIn_InputPort(0));
38
39 // enumArgsGuarded
40 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
41 this->connect_to_enumArgsGuarded(i, this->component.get_enumArgsGuarded_InputPort(i));
42 }
43
44 // enumArgsSync
45 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
46 this->connect_to_enumArgsSync(i, this->component.get_enumArgsSync_InputPort(i));
47 }
48
49 // enumReturnGuarded
50 this->connect_to_enumReturnGuarded(0, this->component.get_enumReturnGuarded_InputPort(0));
51
52 // enumReturnSync
53 this->connect_to_enumReturnSync(0, this->component.get_enumReturnSync_InputPort(0));
54
55 // noArgsGuarded
56 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
57 this->connect_to_noArgsGuarded(i, this->component.get_noArgsGuarded_InputPort(i));
58 }
59
60 // noArgsReturnGuarded
61 this->connect_to_noArgsReturnGuarded(0, this->component.get_noArgsReturnGuarded_InputPort(0));
62
63 // noArgsReturnSync
64 this->connect_to_noArgsReturnSync(0, this->component.get_noArgsReturnSync_InputPort(0));
65
66 // noArgsSync
67 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
68 this->connect_to_noArgsSync(i, this->component.get_noArgsSync_InputPort(i));
69 }
70
71 // primitiveArgsGuarded
72 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
73 this->connect_to_primitiveArgsGuarded(i, this->component.get_primitiveArgsGuarded_InputPort(i));
74 }
75
76 // primitiveArgsSync
77 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
78 this->connect_to_primitiveArgsSync(i, this->component.get_primitiveArgsSync_InputPort(i));
79 }
80
81 // primitiveReturnGuarded
82 this->connect_to_primitiveReturnGuarded(0, this->component.get_primitiveReturnGuarded_InputPort(0));
83
84 // primitiveReturnSync
85 this->connect_to_primitiveReturnSync(0, this->component.get_primitiveReturnSync_InputPort(0));
86
87 // stringArgsGuarded
88 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
89 this->connect_to_stringArgsGuarded(i, this->component.get_stringArgsGuarded_InputPort(i));
90 }
91
92 // stringArgsSync
93 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
94 this->connect_to_stringArgsSync(i, this->component.get_stringArgsSync_InputPort(i));
95 }
96
97 // structArgsGuarded
98 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
99 this->connect_to_structArgsGuarded(i, this->component.get_structArgsGuarded_InputPort(i));
100 }
101
102 // structArgsSync
103 for (NATIVE_INT_TYPE i = 0; i < 2; ++i) {
104 this->connect_to_structArgsSync(i, this->component.get_structArgsSync_InputPort(i));
105 }
106
107 // structReturnGuarded
108 this->connect_to_structReturnGuarded(0, this->component.get_structReturnGuarded_InputPort(0));
109
110 // structReturnSync
111 this->connect_to_structReturnSync(0, this->component.get_structReturnSync_InputPort(0));
112
113 // arrayArgsOut
114 this->component.set_arrayArgsOut_OutputPort(TypedPortIndex::TYPED,
115 this->get_from_arrayArgsOut(TypedPortIndex::TYPED));
116
117 // arrayReturnOut
118 this->component.set_arrayReturnOut_OutputPort(0, this->get_from_arrayReturnOut(0));
119
120 // cmdIn
121 this->connect_to_cmdOut(0, this->component.get_cmdIn_InputPort(0));
122
123 // cmdRegOut
124 this->component.set_cmdRegOut_OutputPort(0, this->get_from_cmdRegOut(0));
125
126 // cmdResponseOut
127 this->component.set_cmdResponseOut_OutputPort(0, this->get_from_cmdResponseOut(0));
128
129 // enumArgsOut
130 this->component.set_enumArgsOut_OutputPort(TypedPortIndex::TYPED,
131 this->get_from_enumArgsOut(TypedPortIndex::TYPED));
132
133 // enumReturnOut
134 this->component.set_enumReturnOut_OutputPort(0, this->get_from_enumReturnOut(0));
135
136 // eventOut
137 this->component.set_eventOut_OutputPort(0, this->get_from_eventOut(0));
138
139 // noArgsOut
140 this->component.set_noArgsOut_OutputPort(TypedPortIndex::TYPED, this->get_from_noArgsOut(TypedPortIndex::TYPED));
141
142 // noArgsReturnOut
143 this->component.set_noArgsReturnOut_OutputPort(0, this->get_from_noArgsReturnOut(0));
144
145 // primitiveArgsOut
146 this->component.set_primitiveArgsOut_OutputPort(TypedPortIndex::TYPED,
147 this->get_from_primitiveArgsOut(TypedPortIndex::TYPED));
148
149 // primitiveReturnOut
150 this->component.set_primitiveReturnOut_OutputPort(0, this->get_from_primitiveReturnOut(0));
151
152 // stringArgsOut
153 this->component.set_stringArgsOut_OutputPort(TypedPortIndex::TYPED,
154 this->get_from_stringArgsOut(TypedPortIndex::TYPED));
155
156 // structArgsOut
157 this->component.set_structArgsOut_OutputPort(TypedPortIndex::TYPED,
158 this->get_from_structArgsOut(TypedPortIndex::TYPED));
159
160 // structReturnOut
161 this->component.set_structReturnOut_OutputPort(0, this->get_from_structReturnOut(0));
162
163 // textEventOut
164 this->component.set_textEventOut_OutputPort(0, this->get_from_textEventOut(0));
165
166 // tlmOut
167 this->component.set_tlmOut_OutputPort(0, this->get_from_tlmOut(0));
168
169 // ----------------------------------------------------------------------
170 // Connect special ports
171 // ----------------------------------------------------------------------
172
173 // prmGetOut
174 this->component.set_prmGetOut_OutputPort(0, this->get_from_prmGetIn(0));
175
176 // ----------------------------------------------------------------------
177 // Connect serial output ports
178 // ----------------------------------------------------------------------
179
180 this->component.set_noArgsOut_OutputPort(TypedPortIndex::SERIAL,
181 this->get_from_serialOut(SerialPortIndex::NO_ARGS));
182
183 this->component.set_primitiveArgsOut_OutputPort(TypedPortIndex::SERIAL,
184 this->get_from_serialOut(SerialPortIndex::PRIMITIVE));
185
186 this->component.set_stringArgsOut_OutputPort(TypedPortIndex::SERIAL,
187 this->get_from_serialOut(SerialPortIndex::STRING));
188
189 this->component.set_enumArgsOut_OutputPort(TypedPortIndex::SERIAL, this->get_from_serialOut(SerialPortIndex::ENUM));
190
191 this->component.set_arrayArgsOut_OutputPort(TypedPortIndex::SERIAL,
192 this->get_from_serialOut(SerialPortIndex::ARRAY));
193
194 this->component.set_structArgsOut_OutputPort(TypedPortIndex::SERIAL,
195 this->get_from_serialOut(SerialPortIndex::STRUCT));
196
197 this->component.set_serialOut_OutputPort(SerialPortIndex::NO_ARGS,
198 this->get_from_noArgsOut(TypedPortIndex::SERIAL));
199
200 this->component.set_serialOut_OutputPort(SerialPortIndex::PRIMITIVE,
201 this->get_from_primitiveArgsOut(TypedPortIndex::SERIAL));
202
203 this->component.set_serialOut_OutputPort(SerialPortIndex::STRING,
204 this->get_from_stringArgsOut(TypedPortIndex::SERIAL));
205
206 this->component.set_serialOut_OutputPort(SerialPortIndex::ENUM, this->get_from_enumArgsOut(TypedPortIndex::SERIAL));
207
208 this->component.set_serialOut_OutputPort(SerialPortIndex::ARRAY,
209 this->get_from_arrayArgsOut(TypedPortIndex::SERIAL));
210
211 this->component.set_serialOut_OutputPort(SerialPortIndex::STRUCT,
212 this->get_from_structArgsOut(TypedPortIndex::SERIAL));
213
214 // ----------------------------------------------------------------------
215 // Connect serial input ports
216 // ----------------------------------------------------------------------
217
218 // serialGuarded
219 for (NATIVE_INT_TYPE i = 0; i < 6; ++i) {
220 this->connect_to_serialGuarded(i, this->component.get_serialGuarded_InputPort(i));
221 }
222
223 // serialSync
224 for (NATIVE_INT_TYPE i = 0; i < 6; ++i) {
225 this->connect_to_serialSync(i, this->component.get_serialSync_InputPort(i));
226 }
227}
228
229void Tester ::connectPrmSetIn() {
230 // prmSetOut
231 this->component.set_prmSetOut_OutputPort(0, this->get_from_prmSetIn(0));
232}
233
234void Tester ::connectTimeGetOut() {
235 // timeGetOut
236 this->component.set_timeGetOut_OutputPort(0, this->get_from_timeGetOut(0));
237}
238
239void Tester ::connectSpecialPortsSerial() {
240 // cmdResponseOut
241 this->component.set_cmdResponseOut_OutputPort(0, this->get_from_serialOut(0));
242
243 // cmdRegOut
244 this->component.set_cmdRegOut_OutputPort(0, this->get_from_serialOut(0));
245
246 // eventOut
247 this->component.set_eventOut_OutputPort(0, this->get_from_serialOut(0));
248
249 // textEventOut
250 this->component.set_textEventOut_OutputPort(0, this->get_from_serialOut(0));
251
252 // tlmOut
253 this->component.set_tlmOut_OutputPort(0, this->get_from_serialOut(0));
254
255 // prmSetOut
256 this->component.set_prmSetOut_OutputPort(0, this->get_from_serialOut(0));
257
258 // timeGetOut
259 this->component.set_timeGetOut_OutputPort(0, this->get_from_serialOut(0));
260}
261
262void Tester ::setPrmValid(Fw::ParamValid valid) {
263 this->prmValid = valid;
264}
265
266void Tester ::checkSerializeStatusSuccess() {
267 ASSERT_EQ(component.serializeStatus, Fw::FW_SERIALIZE_OK);
268}
269
270void Tester ::checkSerializeStatusBufferEmpty() {
271 ASSERT_EQ(component.serializeStatus, Fw::FW_DESERIALIZE_BUFFER_EMPTY);
272}
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
@ FW_DESERIALIZE_BUFFER_EMPTY
Deserialization buffer was empty when trying to read more data.
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.