Fix test_time_to_onroad (#32423)

* this star doesn't make sense

* only docs for now

* flip

* fix spotty test_time_to_onroad.py

* better

fix

fix

fix

fix

* already there -_-

* we can fp again
pull/32426/head
Shane Smiskol 12 months ago committed by GitHub
parent d0d44a51a0
commit 46eda64177
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      selfdrive/test/test_time_to_onroad.py

@ -4,11 +4,14 @@ import pytest
import time import time
import subprocess import subprocess
from cereal import car
import cereal.messaging as messaging import cereal.messaging as messaging
from openpilot.common.basedir import BASEDIR from openpilot.common.basedir import BASEDIR
from openpilot.common.timeout import Timeout from openpilot.common.timeout import Timeout
from openpilot.selfdrive.test.helpers import set_params_enabled from openpilot.selfdrive.test.helpers import set_params_enabled
EventName = car.CarEvent.EventName
@pytest.mark.tici @pytest.mark.tici
def test_time_to_onroad(): def test_time_to_onroad():
@ -18,7 +21,7 @@ def test_time_to_onroad():
proc = subprocess.Popen(["python", manager_path]) proc = subprocess.Popen(["python", manager_path])
start_time = time.monotonic() start_time = time.monotonic()
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents', 'sendcan']) sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents'])
try: try:
# wait for onroad. timeout assumes panda is up to date # wait for onroad. timeout assumes panda is up to date
with Timeout(10, "timed out waiting to go onroad"): with Timeout(10, "timed out waiting to go onroad"):
@ -28,15 +31,14 @@ def test_time_to_onroad():
# wait for engageability # wait for engageability
try: try:
with Timeout(10, "timed out waiting for engageable"): with Timeout(10, "timed out waiting for engageable"):
sendcan_frame = None initialized = False
while True: while True:
sm.update(100) sm.update(100)
# sendcan is only sent once we're initialized if sm.seen['onroadEvents'] and not any(EventName.controlsInitializing == e.name for e in sm['onroadEvents']):
if sm.seen['controlsState'] and sendcan_frame is None: initialized = True
sendcan_frame = sm.frame
if sendcan_frame is not None and sm.recv_frame['sendcan'] > sendcan_frame: if initialized:
sm.update(100) sm.update(100)
assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}" assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}"
break break

Loading…
Cancel
Save