@@ -118,48 +118,44 @@ TEST_F(TestPubSub, publish_and_receive) {
118118
119119 ASSERT_EQ (rmw_publish (pub, &ros_message, NULL ), RMW_RET_OK );
120120
121- void * aux_ptr;
122- do {
123- aux_ptr = sub->data ;
124- rmw_subscriptions_t subscriptions;
125- subscriptions.subscribers = &aux_ptr;
126- subscriptions.subscriber_count = 1 ;
121+ rmw_subscriptions_t subscriptions;
122+ subscriptions.subscribers = &sub->data ;
123+ subscriptions.subscriber_count = 1 ;
127124
128- rmw_guard_conditions_t guard_conditions;
129- guard_conditions.guard_condition_count = 0 ;
125+ rmw_guard_conditions_t guard_conditions;
126+ guard_conditions.guard_condition_count = 0 ;
130127
131- rmw_services_t services;
132- services.service_count = 0 ;
128+ rmw_services_t services;
129+ services.service_count = 0 ;
133130
134- rmw_clients_t clients;
135- clients.client_count = 0 ;
131+ rmw_clients_t clients;
132+ clients.client_count = 0 ;
136133
137- rmw_events_t * events = NULL ;
138- rmw_wait_set_t * wait_set = NULL ;
139- rmw_time_t wait_timeout;
134+ rmw_events_t * events = NULL ;
135+ rmw_wait_set_t * wait_set = NULL ;
136+ rmw_time_t wait_timeout;
140137
138+ wait_timeout.sec = 1 ;
141139
142- wait_timeout.sec = 1 ;
140+ rmw_ret_t ret = rmw_wait (
141+ &subscriptions,
142+ &guard_conditions,
143+ &services,
144+ &clients,
145+ events,
146+ wait_set,
147+ &wait_timeout
148+ );
143149
144- // TODO(pablogs9): Ensure here that the wait works the first time with the Micro XRCE-DDS run session until data message update
145- rmw_ret_t ret = rmw_wait (
146- &subscriptions,
147- &guard_conditions,
148- &services,
149- &clients,
150- events,
151- wait_set,
152- &wait_timeout
153- );
154- } while (aux_ptr == NULL );
150+ ASSERT_NE ((void *)subscriptions.subscribers [0 ], (void *)NULL );
155151
156152 rosidl_runtime_c__String read_ros_message;
157153 char buff[100 ];
158154 read_ros_message.data = buff;
159155 read_ros_message.capacity = sizeof (buff);
160156 read_ros_message.size = 0 ;
161157
162- bool taken;
158+ bool taken = false ;
163159 ASSERT_EQ (
164160 rmw_take_with_info (
165161 sub,
@@ -168,6 +164,7 @@ TEST_F(TestPubSub, publish_and_receive) {
168164 NULL ,
169165 NULL
170166 ), RMW_RET_OK );
167+
171168 ASSERT_EQ (taken, true );
172169 ASSERT_EQ (strcmp (content, read_ros_message.data ), 0 );
173170 ASSERT_EQ (strcmp (ros_message.data , read_ros_message.data ), 0 );
0 commit comments