mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-17 15:22:10 +08:00
fix car test routes typing (#31773)
* Fix typing * and fix test_car_model * fix old-commit-hash: a919d27afc9a225978737e86241adbdba336bbdd
This commit is contained in:
@@ -10,6 +10,7 @@ from openpilot.selfdrive.car.nissan.values import CAR as NISSAN
|
||||
from openpilot.selfdrive.car.mazda.values import CAR as MAZDA
|
||||
from openpilot.selfdrive.car.subaru.values import CAR as SUBARU
|
||||
from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA
|
||||
from openpilot.selfdrive.car.values import Platform
|
||||
from openpilot.selfdrive.car.volkswagen.values import CAR as VOLKSWAGEN
|
||||
from openpilot.selfdrive.car.tesla.values import CAR as TESLA
|
||||
from openpilot.selfdrive.car.body.values import CAR as COMMA
|
||||
@@ -29,7 +30,7 @@ non_tested_cars = [
|
||||
|
||||
class CarTestRoute(NamedTuple):
|
||||
route: str
|
||||
car_model: str | None
|
||||
car_model: Platform | None
|
||||
segment: int | None = None
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ from openpilot.selfdrive.car.fingerprints import all_known_cars
|
||||
from openpilot.selfdrive.car.car_helpers import FRAME_FINGERPRINT, interfaces
|
||||
from openpilot.selfdrive.car.honda.values import CAR as HONDA, HondaFlags
|
||||
from openpilot.selfdrive.car.tests.routes import non_tested_cars, routes, CarTestRoute
|
||||
from openpilot.selfdrive.car.values import PLATFORMS, Platform
|
||||
from openpilot.selfdrive.controls.controlsd import Controls
|
||||
from openpilot.selfdrive.test.helpers import read_segment_list
|
||||
from openpilot.system.hardware.hw import DEFAULT_DOWNLOAD_CACHE_ROOT
|
||||
@@ -64,7 +65,7 @@ def get_test_cases() -> list[tuple[str, CarTestRoute | None]]:
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.shared_download_cache
|
||||
class TestCarModelBase(unittest.TestCase):
|
||||
car_model: str | None = None
|
||||
platform: Platform | None = None
|
||||
test_route: CarTestRoute | None = None
|
||||
test_route_on_bucket: bool = True # whether the route is on the preserved CI bucket
|
||||
|
||||
@@ -93,8 +94,8 @@ class TestCarModelBase(unittest.TestCase):
|
||||
car_fw = msg.carParams.carFw
|
||||
if msg.carParams.openpilotLongitudinalControl:
|
||||
experimental_long = True
|
||||
if cls.car_model is None and not cls.ci:
|
||||
cls.car_model = msg.carParams.carFingerprint
|
||||
if cls.platform is None and not cls.ci:
|
||||
cls.platform = PLATFORMS.get(msg.carParams.carFingerprint)
|
||||
|
||||
# Log which can frame the panda safety mode left ELM327, for CAN validity checks
|
||||
elif msg.which() == 'pandaStates':
|
||||
@@ -155,15 +156,11 @@ class TestCarModelBase(unittest.TestCase):
|
||||
if cls.__name__ == 'TestCarModel' or cls.__name__.endswith('Base'):
|
||||
raise unittest.SkipTest
|
||||
|
||||
if 'FILTER' in os.environ:
|
||||
if not cls.car_model.startswith(tuple(os.environ.get('FILTER').split(','))):
|
||||
raise unittest.SkipTest
|
||||
|
||||
if cls.test_route is None:
|
||||
if cls.car_model in non_tested_cars:
|
||||
print(f"Skipping tests for {cls.car_model}: missing route")
|
||||
if cls.platform in non_tested_cars:
|
||||
print(f"Skipping tests for {cls.platform}: missing route")
|
||||
raise unittest.SkipTest
|
||||
raise Exception(f"missing test route for {cls.car_model}")
|
||||
raise Exception(f"missing test route for {cls.platform}")
|
||||
|
||||
car_fw, can_msgs, experimental_long = cls.get_testing_data()
|
||||
|
||||
@@ -172,10 +169,10 @@ class TestCarModelBase(unittest.TestCase):
|
||||
|
||||
cls.can_msgs = sorted(can_msgs, key=lambda msg: msg.logMonoTime)
|
||||
|
||||
cls.CarInterface, cls.CarController, cls.CarState = interfaces[cls.car_model]
|
||||
cls.CP = cls.CarInterface.get_params(cls.car_model, cls.fingerprint, car_fw, experimental_long, docs=False)
|
||||
cls.CarInterface, cls.CarController, cls.CarState = interfaces[cls.platform]
|
||||
cls.CP = cls.CarInterface.get_params(cls.platform, cls.fingerprint, car_fw, experimental_long, docs=False)
|
||||
assert cls.CP
|
||||
assert cls.CP.carFingerprint == cls.car_model
|
||||
assert cls.CP.carFingerprint == cls.platform
|
||||
|
||||
os.environ["COMMA_CACHE"] = DEFAULT_DOWNLOAD_CACHE_ROOT
|
||||
|
||||
@@ -478,7 +475,7 @@ class TestCarModelBase(unittest.TestCase):
|
||||
"This is fine to fail for WIP car ports, just let us know and we can upload your routes to the CI bucket.")
|
||||
|
||||
|
||||
@parameterized_class(('car_model', 'test_route'), get_test_cases())
|
||||
@parameterized_class(('platform', 'test_route'), get_test_cases())
|
||||
@pytest.mark.xdist_group_class_property('test_route')
|
||||
class TestCarModel(TestCarModelBase):
|
||||
pass
|
||||
|
||||
@@ -5,6 +5,7 @@ import unittest
|
||||
|
||||
from openpilot.selfdrive.car.tests.routes import CarTestRoute
|
||||
from openpilot.selfdrive.car.tests.test_models import TestCarModel
|
||||
from openpilot.selfdrive.car.values import PLATFORMS
|
||||
from openpilot.tools.lib.route import SegmentName
|
||||
|
||||
|
||||
@@ -31,7 +32,10 @@ if __name__ == "__main__":
|
||||
|
||||
route_or_segment_name = SegmentName(args.route_or_segment_name.strip(), allow_route_name=True)
|
||||
segment_num = route_or_segment_name.segment_num if route_or_segment_name.segment_num != -1 else None
|
||||
test_route = CarTestRoute(route_or_segment_name.route_name.canonical_name, args.car, segment=segment_num)
|
||||
|
||||
platform = PLATFORMS.get(args.car)
|
||||
|
||||
test_route = CarTestRoute(route_or_segment_name.route_name.canonical_name, platform, segment=segment_num)
|
||||
test_suite = create_test_models_suite([test_route], ci=args.ci)
|
||||
|
||||
unittest.TextTestRunner().run(test_suite)
|
||||
|
||||
Reference in New Issue
Block a user