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

Function read_status

tests/DCPS/ThreadStatusManager/main.cpp:123–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123bool read_status(DDS::WaitSet_var ws, InternalThreadBuiltinTopicDataDataReader_var dr, MonotonicTimePoint& timestamp,
124 TestThread& task, TestThread::TestThreadState new_state, const char* status,
125 bool thread_end = false, int expected_detail1 = 0, int expected_detail2 = 0)
126{
127 const DDS::Duration_t infinite = {DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC};
128 DDS::ConditionSeq active;
129 bool found = false;
130
131 while (!found) {
132 DDS::ReturnCode_t rc = ws->wait(active, infinite);
133 if (rc != DDS::RETCODE_OK) {
134 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: read_status - failed to wait\n"));
135 break;
136 }
137
138 DDS::InstanceHandle_t prev_handle = DDS::HANDLE_NIL;
139 while (!found && rc == DDS::RETCODE_OK) {
140 InternalThreadBuiltinTopicDataSeq datas;
141 DDS::SampleInfoSeq infos;
142 rc = dr->read_next_instance(datas, infos, DDS::LENGTH_UNLIMITED, prev_handle,
143 DDS::NOT_READ_SAMPLE_STATE, DDS::ANY_VIEW_STATE, DDS::ANY_INSTANCE_STATE);
144 if (rc == DDS::RETCODE_OK) {
145 if (datas.length() != 1u) {
146 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expect 1 sample, received %u for instance key \"%C\"\n",
147 datas.length(), datas[0].thread_id.in()));
148 }
149 prev_handle = infos[0].instance_handle;
150 const String thread_id = datas[0].thread_id.in();
151 if (thread_id.find(task.id()) != String::npos) {
152 found = true;
153 if (!thread_end) {
154 timestamp = MonotonicTimePoint(datas[0].monotonic_timestamp);
155 if (!infos[0].valid_data) {
156 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expected valid data but received invalid\n"));
157 }
158 if (datas[0].detail1 != expected_detail1) {
159 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expected detail1 (%d) != received detail1 (%d)\n",
160 expected_detail1, datas[0].detail1));
161 }
162 if (datas[0].detail2 != expected_detail2) {
163 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expected detail2 (%d) != received detail2 (%d)\n",
164 expected_detail2, datas[0].detail2));
165 }
166 } else {
167 if (infos[0].valid_data) {
168 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expected invalid data but received valid\n"));
169 }
170 if (infos[0].instance_state != DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE) {
171 ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: read_status - expect instance_state NOT_ALIVE_DISPOSED, received %C\n",
172 InstanceState::instance_state_string(infos[0].instance_state)));
173 }
174 }
175 }
176 }
177 }
178 }
179
180 if (!found) {

Callers 1

tsm_testFunction · 0.85

Calls 7

read_next_instanceMethod · 0.80
set_stateMethod · 0.80
waitMethod · 0.45
lengthMethod · 0.45
inMethod · 0.45
findMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected