@ -9,33 +9,47 @@ import cereal.messaging as messaging
from cereal . services import service_list
from common . basedir import BASEDIR
from common . timeout import Timeout
from selfdrive . hardware import TICI
from selfdrive . loggerd . config import ROOT
from selfdrive . test . helpers import set_params_enabled
from tools . lib . logreader import LogReader
PROCS = [
( " selfdrive.controls.controlsd " , 47.0 ) ,
( " ./loggerd " , 45.0 ) ,
( " selfdrive.locationd.locationd " , 32.8 ) ,
( " selfdrive.controls.plannerd " , 20.0 ) ,
( " ./_ui " , 15.0 ) ,
( " selfdrive.locationd.paramsd " , 9.1 ) ,
( " ./camerad " , 7.07 ) ,
( " ./_sensord " , 6.17 ) ,
( " selfdrive.controls.radard " , 5.67 ) ,
( " ./_modeld " , 4.48 ) ,
( " ./boardd " , 3.63 ) ,
( " ./_dmonitoringmodeld " , 2.67 ) ,
( " selfdrive.thermald.thermald " , 2.41 ) ,
( " selfdrive.locationd.calibrationd " , 2.0 ) ,
( " selfdrive.monitoring.dmonitoringd " , 1.90 ) ,
( " ./proclogd " , 1.54 ) ,
( " selfdrive.logmessaged " , 0.2 ) ,
( " ./clocksd " , 0.02 ) ,
( " ./ubloxd " , 0.02 ) ,
( " selfdrive.tombstoned " , 0 ) ,
( " ./logcatd " , 0 ) ,
]
# Baseline CPU usage by process
PROCS = {
" selfdrive.controls.controlsd " : 47.0 ,
" ./loggerd " : 45.0 ,
" selfdrive.locationd.locationd " : 32.8 ,
" selfdrive.controls.plannerd " : 20.0 ,
" ./_ui " : 15.0 ,
" selfdrive.locationd.paramsd " : 9.1 ,
" ./camerad " : 7.07 ,
" ./_sensord " : 6.17 ,
" selfdrive.controls.radard " : 5.67 ,
" ./_modeld " : 4.48 ,
" ./boardd " : 3.63 ,
" ./_dmonitoringmodeld " : 2.67 ,
" selfdrive.thermald.thermald " : 2.41 ,
" selfdrive.locationd.calibrationd " : 2.0 ,
" selfdrive.monitoring.dmonitoringd " : 1.90 ,
" ./proclogd " : 1.54 ,
" selfdrive.logmessaged " : 0.2 ,
" ./clocksd " : 0.02 ,
" ./ubloxd " : 0.02 ,
" selfdrive.tombstoned " : 0 ,
" ./logcatd " : 0 ,
}
if TICI :
PROCS . update ( {
" ./loggerd " : 55.0 ,
" selfdrive.controls.controlsd " : 26.0 ,
" ./camerad " : 20.0 ,
" selfdrive.locationd.locationd " : 21.0 ,
" selfdrive.controls.plannerd " : 12.0 ,
" selfdrive.locationd.paramsd " : 5.0 ,
" ./_dmonitoringmodeld " : 10.0 ,
" selfdrive.thermald.thermald " : 1.5 ,
} )
def cputime_total ( ct ) :
@ -49,7 +63,7 @@ def check_cpu_usage(first_proc, last_proc):
r = True
dt = ( last_proc . logMonoTime - first_proc . logMonoTime ) / 1e9
for proc_name , normal_cpu_usage in PROCS :
for proc_name , normal_cpu_usage in PROCS . items ( ) :
first , last = None , None
try :
first = [ p for p in first_proc . procLog . procs if proc_name in p . cmdline ] [ 0 ]
@ -82,7 +96,10 @@ class TestOnroad(unittest.TestCase):
os . environ [ ' FINGERPRINT ' ] = " TOYOTA COROLLA TSS2 2019 "
set_params_enabled ( )
initial_segments = set ( Path ( ROOT ) . iterdir ( ) )
logger_root = Path ( ROOT )
initial_segments = set ( )
if logger_root . exists ( ) :
initial_segments = set ( Path ( ROOT ) . iterdir ( ) )
# start manager and run openpilot for a minute
try :
@ -98,7 +115,9 @@ class TestOnroad(unittest.TestCase):
cls . segments = [ ]
with Timeout ( 300 , " timed out waiting for logs " ) :
while len ( cls . segments ) < 3 :
new_paths = set ( Path ( ROOT ) . iterdir ( ) ) - initial_segments
new_paths = set ( )
if logger_root . exists ( ) :
new_paths = set ( logger_root . iterdir ( ) ) - initial_segments
segs = [ p for p in new_paths if " -- " in str ( p ) ]
cls . segments = sorted ( segs , key = lambda s : int ( str ( s ) . rsplit ( ' -- ' ) [ - 1 ] ) )
time . sleep ( 5 )