2424if __name__ == "__main__" and platform .system () == "Darwin" :
2525 multiprocessing .set_start_method ('fork' )
2626
27- from rtps_test_utilities import ReturnCode , log_message , no_check , remove_ansi_colors
27+ from rtps_test_utilities import ReturnCode , log_message , basic_check , remove_ansi_colors
2828
2929# This parameter is used to save the samples the Publisher sends.
3030# MAX_SAMPLES_SAVED is the maximum number of samples saved.
@@ -51,16 +51,19 @@ def stop_process(child_process, timeout=30, poll_interval=0.2):
5151 else :
5252 return True # Process already exited
5353
54- start_time = time . time ()
54+ return_value = True
5555
56+ start_time = time .time ()
5657 while child_process .isalive () and (time .time () - start_time < timeout ):
5758 time .sleep (poll_interval )
5859
5960 if child_process .isalive ():
6061 child_process .terminate (force = True )
61- return False # Process was forcefully terminated
62+ return_value = False # Process was forcefully terminated
63+
64+ child_process .expect (pexpect .EOF , timeout = 5 )
6265
63- return True
66+ return return_value
6467
6568def run_subscriber_shape_main (
6669 name_executable : str ,
@@ -138,40 +141,51 @@ def run_subscriber_shape_main(
138141 index = child_sub .expect (
139142 [
140143 'Create topic:' , # index = 0
141- pexpect .TIMEOUT , # index = 1
142- pexpect .EOF # index = 2
144+ re .compile ('not supported' , re .IGNORECASE ), # index = 1
145+ pexpect .TIMEOUT , # index = 2
146+ pexpect .EOF # index = 3
143147 ],
144148 timeout
145149 )
146150
147- if index == 1 or index == 2 :
151+ if index == 2 or index == 3 :
148152 produced_code [produced_code_index ] = ReturnCode .TOPIC_NOT_CREATED
153+ elif index == 1 :
154+ produced_code [produced_code_index ] = ReturnCode .SUB_UNSUPPORTED_FEATURE
149155 elif index == 0 :
150156 # Step 3: Check if the reader is created
151157 log_message (f'Subscriber { subscriber_index } : Waiting for DataReader '
152158 'creation' , verbosity )
153159 index = child_sub .expect (
154160 [
155161 'Create reader for topic:' , # index = 0
156- pexpect .TIMEOUT , # index = 1
157- 'failed to create content filtered topic' # index = 2
162+ 'failed to create content filtered topic' , # index = 1
163+ re .compile ('not supported' , re .IGNORECASE ), # index = 2
164+ pexpect .TIMEOUT , # index = 3
165+ pexpect .EOF # index = 4
166+
158167 ],
159168 timeout
160169 )
161170
162- if index == 1 :
171+ if index == 3 or index == 4 :
163172 produced_code [produced_code_index ] = ReturnCode .READER_NOT_CREATED
164- elif index == 2 :
173+ elif index == 1 :
165174 produced_code [produced_code_index ] = ReturnCode .FILTER_NOT_CREATED
175+ elif index == 2 :
176+ produced_code [produced_code_index ] = ReturnCode .SUB_UNSUPPORTED_FEATURE
166177 elif index == 0 :
167178 # Step 4: Read data or incompatible qos or deadline missed
168179 log_message (f'Subscriber { subscriber_index } : Waiting for data' , verbosity )
169180 index = child_sub .expect (
170181 [
171- '\[[0-9]+\]' , # index = 0
182+ r '\[[0-9]+\]' , # index = 0
172183 'on_requested_incompatible_qos()' , # index = 1
173184 'on_requested_deadline_missed()' , # index = 2
174- pexpect .TIMEOUT , # index = 3
185+ re .compile ('not supported' , re .IGNORECASE ), # index = 3
186+ pexpect .TIMEOUT , # index = 4
187+ pexpect .EOF # index = 5
188+
175189 ],
176190 timeout
177191 )
@@ -180,8 +194,10 @@ def run_subscriber_shape_main(
180194 produced_code [produced_code_index ] = ReturnCode .INCOMPATIBLE_QOS
181195 elif index == 2 :
182196 produced_code [produced_code_index ] = ReturnCode .DEADLINE_MISSED
183- elif index == 3 :
197+ elif index == 4 or index == 5 :
184198 produced_code [produced_code_index ] = ReturnCode .DATA_NOT_RECEIVED
199+ elif index == 3 :
200+ produced_code [produced_code_index ] = ReturnCode .SUB_UNSUPPORTED_FEATURE
185201 elif index == 0 :
186202 # Step 5: Receiving samples
187203 log_message (f'Subscriber { subscriber_index } : Receiving samples' ,
@@ -277,43 +293,54 @@ def run_publisher_shape_main(
277293 index = child_pub .expect (
278294 [
279295 'Create topic:' , # index == 0
280- pexpect .TIMEOUT , # index == 1
281- pexpect .EOF # index == 2
296+ re .compile ('not supported' , re .IGNORECASE ), # index = 1
297+ pexpect .TIMEOUT , # index == 2
298+ pexpect .EOF # index == 3
282299 ],
283300 timeout
284301 )
285302
286- if index == 1 or index == 2 :
303+ if index == 2 or index == 3 :
287304 produced_code [produced_code_index ] = ReturnCode .TOPIC_NOT_CREATED
305+ elif index == 1 :
306+ produced_code [produced_code_index ] = ReturnCode .PUB_UNSUPPORTED_FEATURE
288307 elif index == 0 :
289308 # Step 3: Check if the writer is created
290309 log_message (f'Publisher { publisher_index } : Waiting for DataWriter '
291310 'creation' , verbosity )
292311 index = child_pub .expect (
293312 [
294313 'Create writer for topic' , # index = 0
295- pexpect .TIMEOUT # index = 1
314+ re .compile ('not supported' , re .IGNORECASE ), # index = 1
315+ pexpect .TIMEOUT , # index = 2
316+ pexpect .EOF # index == 3
296317 ],
297318 timeout
298319 )
299- if index == 1 :
320+ if index == 2 or index == 3 :
300321 produced_code [produced_code_index ] = ReturnCode .WRITER_NOT_CREATED
322+ elif index == 1 :
323+ produced_code [produced_code_index ] = ReturnCode .PUB_UNSUPPORTED_FEATURE
301324 elif index == 0 :
302325 # Step 4: Check if the writer matches the reader
303326 log_message (f'Publisher { publisher_index } : Waiting for matching '
304327 'DataReader' , verbosity )
305328 index = child_pub .expect (
306329 [
307330 'on_publication_matched()' , # index = 0
308- pexpect .TIMEOUT , # index = 1
309- 'on_offered_incompatible_qos' # index = 2
331+ 'on_offered_incompatible_qos' , # index = 1
332+ re .compile ('not supported' , re .IGNORECASE ), # index = 2
333+ pexpect .TIMEOUT , # index = 3
334+ pexpect .EOF # index == 4
310335 ],
311336 timeout
312337 )
313- if index == 1 :
338+ if index == 3 or index == 4 :
314339 produced_code [produced_code_index ] = ReturnCode .READER_NOT_MATCHED
315- elif index == 2 :
340+ elif index == 1 :
316341 produced_code [produced_code_index ] = ReturnCode .INCOMPATIBLE_QOS
342+ elif index == 2 :
343+ produced_code [produced_code_index ] = ReturnCode .PUB_UNSUPPORTED_FEATURE
317344 elif index == 0 :
318345 # In the case that the option -w is selected, the Publisher
319346 # saves the samples sent in order, so the Subscriber can check
@@ -324,15 +351,19 @@ def run_publisher_shape_main(
324351 if '-w ' in parameters or parameters .endswith ('-w' ):
325352 # Step 5: Check whether the writer sends the samples
326353 index = child_pub .expect ([
327- '\[[0-9]+\]' , # index = 0
354+ r '\[[0-9]+\]' , # index = 0
328355 'on_offered_deadline_missed()' , # index = 1
329- pexpect .TIMEOUT # index = 2
356+ re .compile ('not supported' , re .IGNORECASE ), # index = 2
357+ pexpect .TIMEOUT , # index = 3
358+ pexpect .EOF # index == 4
330359 ],
331360 timeout )
332361 if index == 1 :
333362 produced_code [produced_code_index ] = ReturnCode .DEADLINE_MISSED
334- elif index == 2 :
363+ elif index == 3 or index == 4 :
335364 produced_code [produced_code_index ] = ReturnCode .DATA_NOT_SENT
365+ elif index == 2 :
366+ produced_code [produced_code_index ] = ReturnCode .PUB_UNSUPPORTED_FEATURE
336367 elif index == 0 :
337368 produced_code [produced_code_index ] = ReturnCode .OK
338369 log_message (f'Publisher { publisher_index } : Sending '
@@ -341,20 +372,24 @@ def run_publisher_shape_main(
341372 for x in range (0 , MAX_SAMPLES_SAVED , 1 ):
342373 # At this point, at least one sample has been printed
343374 # Therefore, that sample is added to samples_sent.
344- pub_string = re .search ('[0-9]+ [0-9]+ \[[0-9]+\]' ,
375+ pub_string = re .search (r '[0-9]+ [0-9]+ \[[0-9]+\]' ,
345376 child_pub .before + child_pub .after )
346377 last_sample = pub_string .group (0 )
347378 samples_sent .put (last_sample )
348379 index = child_pub .expect ([
349- '\[[0-9]+\]' , # index = 0
380+ r '\[[0-9]+\]' , # index = 0
350381 'on_offered_deadline_missed()' , # index = 1
351- pexpect .TIMEOUT # index = 2
382+ re .compile ('not supported' , re .IGNORECASE ), # index = 2
383+ pexpect .TIMEOUT # index = 3
352384 ],
353385 timeout )
354386 if index == 1 :
355387 produced_code [produced_code_index ] = ReturnCode .DEADLINE_MISSED
356388 break
357389 elif index == 2 :
390+ produced_code [produced_code_index ] = ReturnCode .PUB_UNSUPPORTED_FEATURE
391+ break
392+ elif index == 3 :
358393 produced_code [produced_code_index ] = ReturnCode .DATA_NOT_SENT
359394 break
360395 last_sample_saved .put (last_sample )
@@ -811,7 +846,7 @@ def main():
811846 raise RuntimeError ('Cannot process function of '
812847 f'test case: { test_case_name } ' )
813848 else :
814- check_function = no_check
849+ check_function = basic_check
815850
816851 assert (len (parameters ) == len (expected_codes ))
817852
0 commit comments