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

Function test_setup

tests/DCPS/QueryCondition/QueryConditionTest.cpp:169–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167};
168
169bool test_setup(const MessageTypeSupport_var& ts, const Publisher_var& pub,
170 const Subscriber_var& sub, const char* topicName, DataWriter_var& dw,
171 DataReader_var& dr)
172{
173 CORBA::String_var typeName = ts->get_type_name();
174 DDS::DomainParticipant_var dp = pub->get_participant();
175 Topic_var topic = dp->create_topic(topicName, typeName,
176 TOPIC_QOS_DEFAULT, 0,
177 DEFAULT_STATUS_MASK);
178 if (!topic) {
179 cerr << "ERROR: test_setup: create_topic failed" << endl;
180 return false;
181 }
182
183 DataWriterQos dw_qos;
184 pub->get_default_datawriter_qos(dw_qos);
185 dw_qos.history.kind = KEEP_ALL_HISTORY_QOS;
186 dw = pub->create_datawriter(topic, dw_qos, 0, DEFAULT_STATUS_MASK);
187 if (!dw) {
188 cerr << "ERROR: test_setup: create_datawriter failed" << endl;
189 return false;
190 }
191
192 DDS::Topic_var reader_topic = topic;
193 DDS::DomainParticipant_var sub_participant = sub->get_participant();
194 if (sub_participant != dp) {
195 reader_topic = sub_participant->create_topic(topicName, typeName, TOPIC_QOS_DEFAULT, 0, 0);
196 if (!topic) {
197 cerr << "ERROR: test_setup: create_topic for reader failed" << endl;
198 return false;
199 }
200 }
201
202 DataReaderQos dr_qos;
203 sub->get_default_datareader_qos(dr_qos);
204 dr_qos.history.kind = KEEP_ALL_HISTORY_QOS;
205 dr = sub->create_datareader(reader_topic, dr_qos, 0, DEFAULT_STATUS_MASK);
206 if (!dr) {
207 cerr << "ERROR: test_setup: create_datareader failed" << endl;
208 return false;
209 }
210
211 StatusCondition_var dw_sc = dw->get_statuscondition();
212 dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
213 WaitSet_var ws = new WaitSet;
214 ws->attach_condition(dw_sc);
215 Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
216 ConditionSeq active;
217 if (ws->wait(active, infinite) != DDS::RETCODE_OK) {
218 return false;
219 }
220 ws->detach_condition(dw_sc);
221 return true;
222}
223
224bool complex_test_setup(const MessageTypeSupport_var& ts, const Publisher_var& pub,
225 const Subscriber_var& sub, const char* topicName, DataWriter_var& dw,

Callers 4

run_filtering_testFunction · 0.85
run_sorting_testFunction · 0.85

Calls 12

set_enabled_statusesMethod · 0.80
attach_conditionMethod · 0.80
detach_conditionMethod · 0.80
get_type_nameMethod · 0.45
get_participantMethod · 0.45
create_topicMethod · 0.45
create_datawriterMethod · 0.45
create_datareaderMethod · 0.45
get_statusconditionMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected