openpilot v0.7.8 release

This commit is contained in:
Vehicle Researcher
2020-08-13 00:37:05 +00:00
parent f370bf5ba6
commit 0aa4867be4
147 changed files with 3679 additions and 2713 deletions
+43 -36
View File
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
import os
import time
import threading
import _thread
import signal
import sys
import subprocess
import cereal.messaging as messaging
import selfdrive.manager as manager
from common.basedir import BASEDIR
from common.params import Params
from selfdrive.test.helpers import set_params_enabled
def cputime_total(ct):
return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem
@@ -15,7 +15,7 @@ def cputime_total(ct):
def print_cpu_usage(first_proc, last_proc):
procs = [
("selfdrive.controls.controlsd", 59.46),
("selfdrive.controls.controlsd", 66.15),
("selfdrive.locationd.locationd", 34.38),
("./loggerd", 33.90),
("selfdrive.controls.plannerd", 19.77),
@@ -39,7 +39,7 @@ def print_cpu_usage(first_proc, last_proc):
("./logcatd", 0),
]
r = 0
r = True
dt = (last_proc.logMonoTime - first_proc.logMonoTime) / 1e9
result = "------------------------------------------------\n"
for proc_name, normal_cpu_usage in procs:
@@ -50,47 +50,54 @@ def print_cpu_usage(first_proc, last_proc):
cpu_usage = cpu_time / dt * 100.
if cpu_usage > max(normal_cpu_usage * 1.1, normal_cpu_usage + 5.0):
result += f"Warning {proc_name} using more CPU than normal\n"
r = 1
r = False
elif cpu_usage < min(normal_cpu_usage * 0.3, max(normal_cpu_usage - 1.0, 0.0)):
result += f"Warning {proc_name} using less CPU than normal\n"
r = 1
r = False
result += f"{proc_name.ljust(35)} {cpu_usage:.2f}%\n"
except IndexError:
result += f"{proc_name.ljust(35)} NO METRICS FOUND\n"
r = 1
r = False
result += "------------------------------------------------\n"
print(result)
return r
return_code = 1
def test_thread():
global return_code
proc_sock = messaging.sub_sock('procLog', conflate=True)
def test_cpu_usage():
cpu_ok = False
# wait until everything's started and get first sample
time.sleep(30)
first_proc = messaging.recv_sock(proc_sock, wait=True)
# start manager
manager_path = os.path.join(BASEDIR, "selfdrive/manager.py")
manager_proc = subprocess.Popen(["python", manager_path])
try:
proc_sock = messaging.sub_sock('procLog', conflate=True, timeout=2000)
# run for a minute and get last sample
time.sleep(60)
last_proc = messaging.recv_sock(proc_sock, wait=True)
# wait until everything's started and get first sample
start_time = time.monotonic()
while time.monotonic() - start_time < 120:
if Params().get("CarParams") is not None:
break
time.sleep(2)
first_proc = messaging.recv_sock(proc_sock, wait=True)
if first_proc is None:
raise Exception("\n\nTEST FAILED: progLog recv timed out\n\n")
running = manager.get_running()
all_running = all(p in running and running[p].is_alive() for p in manager.car_started_processes)
return_code = print_cpu_usage(first_proc, last_proc)
if not all_running:
return_code = 1
_thread.interrupt_main()
# run for a minute and get last sample
time.sleep(60)
last_proc = messaging.recv_sock(proc_sock, wait=True)
cpu_ok = print_cpu_usage(first_proc, last_proc)
finally:
manager_proc.terminate()
ret = manager_proc.wait(20)
if ret is None:
manager_proc.kill()
return cpu_ok
if __name__ == "__main__":
set_params_enabled()
Params().delete("CarParams")
# setup signal handler to exit with test status
def handle_exit(sig, frame):
sys.exit(return_code)
signal.signal(signal.SIGINT, handle_exit)
# start manager and test thread
t = threading.Thread(target=test_thread)
t.daemon = True
t.start()
manager.main()
passed = False
try:
passed = test_cpu_usage()
finally:
sys.exit(int(not passed))