@@ -5,24 +5,51 @@ import time
55import signal
66import subprocess
77
8+ ASAN_LOG_PREFIX = '/asan-output.log'
9+ TSAN_LOG_PREFIX = '/tsan-output.log'
10+
11+
12+ def check_sanitizer_log_is_valid (pid , prefix ):
13+ filename = f'{ prefix } .{ pid } '
14+ if not os .path .exists (filename ) or os .path .getsize (filename ) == 0 :
15+ return True
16+
17+ with open (filename , 'r' ) as asan_log :
18+ print (f'Found non-empty { filename } log:' )
19+ print (asan_log .read ())
20+ return False
21+
22+
23+ def asan_log_is_valid (pid ):
24+ # ASAN_OPITONS was set to this log_prefix in docker-compose.yml
25+ return check_sanitizer_log_is_valid (pid , ASAN_LOG_PREFIX )
26+
27+
28+ def tsan_log_is_valid (pid ):
29+ # TSAN_OPITONS was set to this log_prefix in docker-compose.yml
30+ return check_sanitizer_log_is_valid (pid , TSAN_LOG_PREFIX )
31+
832
933def get_odyssey_pids ():
10- print (subprocess .check_output ('ps aux | grep odyssey' , shell = True ).decode ('utf-8' ))
34+ print (subprocess .check_output (
35+ 'ps aux | grep odyssey' , shell = True ).decode ('utf-8' ))
1136
1237 try :
1338 return list (map (int , subprocess .check_output (['pgrep' , 'odyssey' ]).split ()))
1439 except subprocess .CalledProcessError :
1540 # non-zero exit code means that there is no odyssey pids
1641 return []
1742
43+
1844def terminate_gracefully (pid , timeout ):
1945 try :
2046 os .kill (pid , signal .SIGTERM )
2147 except ProcessLookupError :
2248 print (f'Process { pid } already finished or doesnt ever existed' )
2349 return
2450
25- print (f'Waiting { timeout } seconds to { pid } finish after SIGTERM...' , end = '' )
51+ print (f'Waiting { timeout } seconds to {
52+ pid } finish after SIGTERM...' , end = '' )
2653
2754 start = time .time ()
2855 finished = False
@@ -56,10 +83,15 @@ def main():
5683 for pid in pids :
5784 if not terminate_gracefully (pid , timeout ):
5885 print (f'Process { pid } didnt finish within { timeout } seconds' )
59- print (subprocess .check_output (['gdb' , '-p' , str (pid ), '--batch' , '-ex' , 't a a bt' , '-ex' , 'source /gdb.py' , 'mmcoro all bt' ]))
86+ print (subprocess .check_output (
87+ ['gdb' , '-p' , str (pid ), '--batch' , '-ex' , 't a a bt' , '-ex' , 'source /gdb.py' , 'mmcoro all bt' ]))
88+ exit (1 )
89+
90+ if not asan_log_is_valid (pid ) or not tsan_log_is_valid (pid ):
6091 exit (1 )
6192
6293 exit (0 )
6394
95+
6496if __name__ == "__main__" :
6597 main ()
0 commit comments