@@ -81,29 +81,35 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
81
81
def prepare_input (self , name ):
82
82
return {'num_samples' : self .num_samples , 'num_iters' : self .num_iters }
83
83
84
+ def run_test_inner (self , data , num_iters ):
85
+ p = subprocess .Popen ([
86
+ data ['path' ],
87
+ "--num-samples={}" .format (data ['num_samples' ]),
88
+ "--num-iters={}" .format (num_iters ), data ['test_name' ]],
89
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
90
+ error_out = p .communicate ()[1 ].split ("\n " )
91
+ result = p .returncode
92
+ if result is None :
93
+ raise RuntimeError ("Expected one line of output" )
94
+ if result != 0 :
95
+ raise RuntimeError ("Process segfaulted" )
96
+ return error_out
97
+
84
98
def run_test (self , data , num_iters ):
85
99
try :
86
- p = subprocess .Popen ([
87
- data ['path' ],
88
- "--num-samples={}" .format (data ['num_samples' ]),
89
- "--num-iters={}" .format (num_iters ), data ['test_name' ]],
90
- stdout = subprocess .PIPE , stderr = subprocess .PIPE )
91
- error_out = p .communicate ()[1 ].split ("\n " )
92
- result = p .returncode
93
- if result is None :
94
- raise RuntimeError ("Expected one line of output" )
95
- if result != 0 :
96
- raise RuntimeError ("Process segfaulted" )
97
- except Exception :
98
- sys .stderr .write ("Child Process Failed! (%s,%s)\n " % (
99
- data ['path' ], data ['test_name' ]))
100
+ args = [data , num_iters ]
101
+ result = perf_test_driver .run_with_timeout (self .run_test_inner ,
102
+ args )
103
+ except Exception , e :
104
+ sys .stderr .write ("Child Process Failed! (%s,%s). Error: %s\n " % (
105
+ data ['path' ], data ['test_name' ], e ))
100
106
sys .stderr .flush ()
101
107
return None
102
108
103
109
try :
104
110
# We grab the second line since swift globals get lazily created in
105
111
# the first iteration.
106
- d = json .loads (error_out [1 ])
112
+ d = json .loads (result [1 ])
107
113
d ['objc_objects' ] = [x for x in d ['objc_objects' ]
108
114
if x not in IGNORABLE_GLOBAL_OBJC_CLASSES ]
109
115
d ['objc_count' ] = len (d ['objc_objects' ])
0 commit comments