MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / tsm_test

Function tsm_test

tests/DCPS/ThreadStatusManager/main.cpp:188–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188int tsm_test(InternalThreadBuiltinTopicDataDataReader_var itbtd_reader, DDS::WaitSet_var ws)
189{
190 TestThread task;
191
192 if (task.start() != 0) {
193 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: main - failed to start test thread\n"));
194 return EXIT_FAILURE;
195 }
196
197 MonotonicTimePoint thread_start, event1_start, event1_end, event2_start, event2_end, thread_end;
198
199 // Notify the test thread to proceed after reading the thread status in each step
200 if (!read_status(ws, itbtd_reader, thread_start, task, TestThread::TTS_START, "start")) {
201 return EXIT_FAILURE;
202 }
203
204 if (!read_status(ws, itbtd_reader, event1_start, task, TestThread::TTS_E1_BEGIN, "event1 begin", false, EVENT1_DETAIL1, EVENT1_DETAIL2)) {
205 return EXIT_FAILURE;
206 }
207
208 if (!read_status(ws, itbtd_reader, event2_start, task, TestThread::TTS_E2_BEGIN, "event2 begin", false, EVENT2_DETAIL1, EVENT2_DETAIL2)) {
209 return EXIT_FAILURE;
210 }
211
212 if (!read_status(ws, itbtd_reader, event2_end, task, TestThread::TTS_E2_END, "event2 end")) {
213 return EXIT_FAILURE;
214 }
215
216 if (!read_status(ws, itbtd_reader, event1_end, task, TestThread::TTS_E1_END, "event1 end")) {
217 return EXIT_FAILURE;
218 }
219
220 // The thread status sample corresponding to the thread end event is a disposed sample,
221 // so thread_end is just passed here, but its value is not used for anything.
222 if (!read_status(ws, itbtd_reader, thread_end, task, TestThread::TTS_STOP, "stop", true)) {
223 return EXIT_FAILURE;
224 }
225
226 task.wait();
227
228 // Check that the timestamps are in the correct order
229 int ret = EXIT_SUCCESS;
230 if (!(thread_start < event1_start)) {
231 ACE_ERROR((LM_WARNING, "(%P|%t) ERROR: main - thread_start ({%d sec, %u nsec}) should be before event1_start ({%d sec, %u nsec})\n",
232 thread_start.to_idl_struct().sec, thread_start.to_idl_struct().nanosec,
233 event1_start.to_idl_struct().sec, event1_start.to_idl_struct().nanosec));
234 ret = EXIT_FAILURE;
235 }
236 if (!(event1_start < event2_start)) {
237 ACE_ERROR((LM_WARNING, "(%P|%t) ERROR: main - event1_start ({%d sec, %u nsec}) should be before event2_start ({%d sec, %u nsec})\n",
238 event1_start.to_idl_struct().sec, event1_start.to_idl_struct().nanosec,
239 event2_start.to_idl_struct().sec, event2_start.to_idl_struct().nanosec));
240 ret = EXIT_FAILURE;
241 }
242 if (!(event2_start < event2_end)) {
243 ACE_ERROR((LM_WARNING, "(%P|%t) ERROR: main - event2_start ({%d sec, %u nsec}) should be before event2_end ({%d sec, %u nsec})\n",
244 event2_start.to_idl_struct().sec, event2_start.to_idl_struct().nanosec,
245 event2_end.to_idl_struct().sec, event2_end.to_idl_struct().nanosec));

Callers 1

ACE_TMAINFunction · 0.85

Calls 3

read_statusFunction · 0.85
startMethod · 0.65
waitMethod · 0.45

Tested by

no test coverage detected