Files
StarPilot/selfdrive/car/tests/test_car_specific.py
T
firestar5683 7fb15f97ab v16
2026-06-03 22:14:00 -05:00

42 lines
1.7 KiB
Python

from cereal import car
from openpilot.selfdrive.car.cruise_state import should_cancel_stock_cruise, should_flag_cruise_mismatch
def make_cp(brand="hyundai", op_long=True, pcm_cruise=False):
cp = car.CarParams.new_message()
cp.brand = brand
cp.openpilotLongitudinalControl = op_long
cp.pcmCruise = pcm_cruise
return cp
def test_hyundai_openpilot_long_does_not_cancel_active_acc_req_feedback():
cp = make_cp()
assert not should_cancel_stock_cruise(cp, cruise_enabled=True, controls_enabled=True)
assert not should_flag_cruise_mismatch(cp, cruise_enabled=True, controls_enabled=True, effective_pcm_cruise=False)
def test_hyundai_openpilot_long_still_flags_cruise_when_controls_disabled():
cp = make_cp()
assert should_cancel_stock_cruise(cp, cruise_enabled=True, controls_enabled=False)
assert should_flag_cruise_mismatch(cp, cruise_enabled=True, controls_enabled=False, effective_pcm_cruise=False)
def test_non_hyundai_openpilot_long_behavior_is_unchanged():
cp = make_cp(brand="toyota")
assert should_cancel_stock_cruise(cp, cruise_enabled=True, controls_enabled=True)
assert should_flag_cruise_mismatch(cp, cruise_enabled=True, controls_enabled=True, effective_pcm_cruise=False)
def test_pcm_cruise_behavior_is_unchanged():
cp = make_cp(op_long=False, pcm_cruise=True)
assert not should_cancel_stock_cruise(cp, cruise_enabled=True, controls_enabled=True)
assert should_cancel_stock_cruise(cp, cruise_enabled=True, controls_enabled=False)
assert not should_flag_cruise_mismatch(cp, cruise_enabled=True, controls_enabled=True, effective_pcm_cruise=True)
assert should_flag_cruise_mismatch(cp, cruise_enabled=True, controls_enabled=False, effective_pcm_cruise=True)