@@ -51,9 +51,7 @@ class CLASSNAME (TestPublisherFixtureSpecial, RMW_IMPLEMENTATION) : public ::tes
5151
5252 void SetUp ()
5353 {
54- is_fastdds = (std::string (rmw_get_implementation_identifier ()).find (" rmw_fastrtps" ) == 0 );
55- is_cyclonedds = (std::string (rmw_get_implementation_identifier ()).find (" rmw_cyclonedds" ) == 0 );
56- is_connextdds = (std::string (rmw_get_implementation_identifier ()).find (" rmw_connextdds" ) == 0 );
54+ bool is_fastdds = (std::string (rmw_get_implementation_identifier ()).find (" rmw_fastrtps" ) == 0 );
5755
5856 if (is_fastdds) {
5957 // By default, fastdds use intraprocess mode in this scenario. But this leads to high-speed
@@ -100,13 +98,24 @@ class CLASSNAME (TestPublisherFixtureSpecial, RMW_IMPLEMENTATION) : public ::tes
10098 delete this ->context_ptr ;
10199 EXPECT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
102100 }
103-
104- protected:
105- bool is_fastdds;
106- bool is_cyclonedds;
107- bool is_connextdds;
108101};
109102
103+ #define INIT_SUBSCRIPTION (idx ) \
104+ rcl_subscription_t subscription ## idx = rcl_get_zero_initialized_subscription(); \
105+ ret = rcl_subscription_init( \
106+ &subscription ## idx, \
107+ this ->node_ptr, \
108+ ts, \
109+ topic_name, \
110+ &subscription_options); \
111+ ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string().str; \
112+ OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT ( \
113+ { \
114+ ret = rcl_subscription_fini (&subscription ## idx, this ->node_ptr ); \
115+ EXPECT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ; \
116+ });
117+
118+ #define ONE_MEGABYTE (1024 * 1024 )
110119
111120TEST_F (CLASSNAME(TestPublisherFixtureSpecial, RMW_IMPLEMENTATION), test_wait_for_all_acked) {
112121 rcl_ret_t ret;
@@ -129,29 +138,12 @@ TEST_F(CLASSNAME(TestPublisherFixtureSpecial, RMW_IMPLEMENTATION), test_wait_for
129138 subscription_options.qos .depth = 1 ;
130139 subscription_options.qos .reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
131140
132- #define INIT_SUBSCRIPTION (idx ) \
133- rcl_subscription_t subscription ## idx = rcl_get_zero_initialized_subscription (); \
134- ret = rcl_subscription_init ( \
135- &subscription ## idx, \
136- this ->node_ptr , \
137- ts, \
138- topic_name, \
139- &subscription_options); \
140- ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ; \
141- OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT ( \
142- { \
143- ret = rcl_subscription_fini (&subscription ## idx, this ->node_ptr ); \
144- EXPECT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ; \
145- });
146-
147141 INIT_SUBSCRIPTION (1 )
148142 INIT_SUBSCRIPTION (2 )
149143 INIT_SUBSCRIPTION (3 )
150144
151145 ASSERT_TRUE (wait_for_established_subscription (&publisher, 10 , 100 ));
152146
153- // Prepare 1MB message
154- #define ONE_MEGABYTE (1024 * 1024 )
155147 char test_string[ONE_MEGABYTE];
156148 memset (test_string, ' a' , ONE_MEGABYTE);
157149 test_string[ONE_MEGABYTE - 1 ] = ' \0 ' ;
@@ -179,13 +171,8 @@ TEST_F(CLASSNAME(TestPublisherFixtureSpecial, RMW_IMPLEMENTATION), test_wait_for
179171 ret = rcl_publisher_wait_for_all_acked (
180172 &publisher,
181173 RCL_MS_TO_NS (500 ));
174+ EXPECT_TRUE (ret == RCL_RET_OK || ret == RCL_RET_TIMEOUT);
182175
183- if (is_cyclonedds) {
184- // cyclonedds use sync publish, so above scenario cannot lead to timeout.
185- EXPECT_EQ (RCL_RET_OK, ret);
186- } else {
187- EXPECT_EQ (RCL_RET_TIMEOUT, ret);
188- }
189176 ret = rcl_publisher_wait_for_all_acked (&publisher, -1 );
190177 EXPECT_EQ (RCL_RET_OK, ret);
191178}
@@ -210,57 +197,6 @@ TEST_F(
210197 EXPECT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
211198 });
212199
213- rcl_subscription_options_t subscription_options = rcl_subscription_get_default_options ();
214- subscription_options.qos .depth = 1 ;
215- subscription_options.qos .reliability = RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT;
216-
217- #define INIT_SUBSCRIPTION (idx ) \
218- rcl_subscription_t subscription ## idx = rcl_get_zero_initialized_subscription (); \
219- ret = rcl_subscription_init ( \
220- &subscription ## idx, \
221- this ->node_ptr , \
222- ts, \
223- topic_name, \
224- &subscription_options); \
225- ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ; \
226- OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT ( \
227- { \
228- ret = rcl_subscription_fini (&subscription ## idx, this ->node_ptr ); \
229- EXPECT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ; \
230- });
231-
232- INIT_SUBSCRIPTION (1 )
233- INIT_SUBSCRIPTION (2 )
234- INIT_SUBSCRIPTION (3 )
235-
236- ASSERT_TRUE (wait_for_established_subscription (&publisher, 10 , 100 ));
237-
238- // Prepare 1MB message
239- #define ONE_MEGABYTE (1024 * 1024 )
240- char test_string[ONE_MEGABYTE];
241- memset (test_string, ' a' , ONE_MEGABYTE);
242- test_string[ONE_MEGABYTE - 1 ] = ' \0 ' ;
243- test_msgs__msg__Strings msg;
244- test_msgs__msg__Strings__init (&msg);
245- ASSERT_TRUE (rosidl_runtime_c__String__assign (&msg.string_value , test_string));
246- OSRF_TESTING_TOOLS_CPP_SCOPE_EXIT (
247- {
248- test_msgs__msg__Strings__fini (&msg);
249- });
250-
251- ret = rcl_publish (&publisher, &msg, nullptr );
252- ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
253-
254- ASSERT_TRUE (wait_for_subscription_to_be_ready (&subscription1, context_ptr, 10 , 100 ));
255- ASSERT_TRUE (wait_for_subscription_to_be_ready (&subscription2, context_ptr, 10 , 100 ));
256- ASSERT_TRUE (wait_for_subscription_to_be_ready (&subscription3, context_ptr, 10 , 100 ));
257-
258- int i = 0 ;
259- for (; i < 500 ; i++) {
260- ret = rcl_publish (&publisher, &msg, nullptr );
261- ASSERT_EQ (RCL_RET_OK, ret) << rcl_get_error_string ().str ;
262- }
263-
264200 ret = rcl_publisher_wait_for_all_acked (
265201 &publisher,
266202 RCL_MS_TO_NS (500 ));
0 commit comments