@@ -184,7 +184,7 @@ def execute_test_case(self, test_case, kill_time=None):
184
184
test_case_kwargs = dict ()
185
185
186
186
if kill_time :
187
- max_execution_time = max (int (kill_time - time .time ()), 5 )
187
+ max_execution_time = max (int (kill_time - time .monotonic ()), 5 )
188
188
cur_execution_time = test_case_kwargs .get ("execution_time" , 1200 )
189
189
test_case_kwargs ["execution_time" ] = min (max_execution_time ,
190
190
cur_execution_time )
@@ -258,16 +258,19 @@ def scan(self, timeout=None):
258
258
:return: None
259
259
"""
260
260
self .configuration .stop_event .clear ()
261
- kill_time = time .time () + (timeout or 0xffffffff )
261
+ if timeout is None :
262
+ kill_time = None
263
+ else :
264
+ kill_time = time .monotonic () + timeout
262
265
log_automotive .debug ("Set kill_time to %s" % time .ctime (kill_time ))
263
- while kill_time > time .time ():
266
+ while kill_time is None or kill_time > time .monotonic ():
264
267
test_case_executed = False
265
268
log_automotive .info ("[i] Scan progress %0.2f" , self .progress ())
266
269
log_automotive .debug ("[i] Scan paths %s" , self .state_paths )
267
270
for p , test_case in product (
268
271
self .state_paths , self .configuration .test_cases ):
269
272
log_automotive .info ("Scan path %s" , p )
270
- terminate = kill_time <= time .time ()
273
+ terminate = kill_time and kill_time <= time .monotonic ()
271
274
if terminate or self .configuration .stop_event .is_set ():
272
275
log_automotive .debug (
273
276
"Execution time exceeded. Terminating scan!" )
0 commit comments