|
|
|
@ -9,6 +9,7 @@ from parameterized import parameterized_class |
|
|
|
|
|
|
|
|
|
from cereal import log, car |
|
|
|
|
from openpilot.common.basedir import BASEDIR |
|
|
|
|
from openpilot.common.params import Params |
|
|
|
|
from openpilot.common.realtime import DT_CTRL |
|
|
|
|
from openpilot.selfdrive.car.fingerprints import all_known_cars |
|
|
|
|
from openpilot.selfdrive.car.car_helpers import FRAME_FINGERPRINT, interfaces |
|
|
|
@ -16,6 +17,7 @@ from openpilot.selfdrive.car.gm.values import CAR as GM |
|
|
|
|
from openpilot.selfdrive.car.honda.values import CAR as HONDA, HONDA_BOSCH |
|
|
|
|
from openpilot.selfdrive.car.hyundai.values import CAR as HYUNDAI |
|
|
|
|
from openpilot.selfdrive.car.tests.routes import non_tested_cars, routes, CarTestRoute |
|
|
|
|
from openpilot.selfdrive.controls.controlsd import Controls |
|
|
|
|
from openpilot.selfdrive.test.openpilotci import get_url |
|
|
|
|
from openpilot.tools.lib.logreader import LogReader |
|
|
|
|
from openpilot.tools.lib.route import Route, SegmentName, RouteName |
|
|
|
@ -23,6 +25,7 @@ from openpilot.tools.lib.route import Route, SegmentName, RouteName |
|
|
|
|
from panda.tests.libpanda import libpanda_py |
|
|
|
|
from openpilot.selfdrive.test.helpers import SKIP_ENV_VAR |
|
|
|
|
|
|
|
|
|
EventName = car.CarEvent.EventName |
|
|
|
|
PandaType = log.PandaState.PandaType |
|
|
|
|
SafetyModel = car.CarParams.SafetyModel |
|
|
|
|
|
|
|
|
@ -163,9 +166,11 @@ class TestCarModelBase(unittest.TestCase): |
|
|
|
|
del cls.can_msgs |
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
|
self.CI = self.CarInterface(self.CP, self.CarController, self.CarState) |
|
|
|
|
self.CI = self.CarInterface(self.CP.copy(), self.CarController, self.CarState) |
|
|
|
|
assert self.CI |
|
|
|
|
|
|
|
|
|
Params().put_bool("OpenpilotEnabledToggle", self.openpilot_enabled) |
|
|
|
|
|
|
|
|
|
# TODO: check safetyModel is in release panda build |
|
|
|
|
self.safety = libpanda_py.libpanda |
|
|
|
|
|
|
|
|
@ -315,6 +320,8 @@ class TestCarModelBase(unittest.TestCase): |
|
|
|
|
controls_allowed_prev = False |
|
|
|
|
CS_prev = car.CarState.new_message() |
|
|
|
|
checks = defaultdict(lambda: 0) |
|
|
|
|
controlsd = Controls(CI=self.CI) |
|
|
|
|
controlsd.initialized = True |
|
|
|
|
for idx, can in enumerate(self.can_msgs): |
|
|
|
|
CS = self.CI.update(CC, (can.as_builder().to_bytes(), )) |
|
|
|
|
for msg in filter(lambda m: m.src in range(64), can.can): |
|
|
|
@ -359,7 +366,10 @@ class TestCarModelBase(unittest.TestCase): |
|
|
|
|
checks['cruiseState'] += CS.cruiseState.enabled != self.safety.get_cruise_engaged_prev() |
|
|
|
|
else: |
|
|
|
|
# Check for enable events on rising edge of controls allowed |
|
|
|
|
button_enable = any(evt.enable for evt in CS.events) |
|
|
|
|
controlsd.update_events(CS) |
|
|
|
|
controlsd.CS_prev = CS |
|
|
|
|
button_enable = (any(evt.enable for evt in CS.events) and |
|
|
|
|
not any(evt == EventName.pedalPressed for evt in controlsd.events.names)) |
|
|
|
|
mismatch = button_enable != (self.safety.get_controls_allowed() and not controls_allowed_prev) |
|
|
|
|
checks['controlsAllowed'] += mismatch |
|
|
|
|
controls_allowed_prev = self.safety.get_controls_allowed() |
|
|
|
|