You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
5 years ago
|
#!/usr/bin/env python3
|
||
|
import unittest
|
||
5 years ago
|
import importlib
|
||
5 years ago
|
from selfdrive.car.fingerprints import all_known_cars
|
||
|
from selfdrive.car.car_helpers import interfaces
|
||
|
from selfdrive.car.fingerprints import _FINGERPRINTS as FINGERPRINTS
|
||
|
|
||
5 years ago
|
from cereal import car
|
||
|
|
||
5 years ago
|
|
||
5 years ago
|
class TestCarInterfaces(unittest.TestCase):
|
||
|
def test_car_interfaces(self):
|
||
5 years ago
|
all_cars = all_known_cars()
|
||
|
|
||
5 years ago
|
for car_name in all_cars:
|
||
|
fingerprint = FINGERPRINTS[car_name][0]
|
||
5 years ago
|
|
||
5 years ago
|
CarInterface, CarController, CarState = interfaces[car_name]
|
||
5 years ago
|
fingerprints = {
|
||
|
0: fingerprint,
|
||
|
1: fingerprint,
|
||
|
2: fingerprint,
|
||
|
}
|
||
|
|
||
|
car_fw = []
|
||
|
|
||
|
for has_relay in [True, False]:
|
||
5 years ago
|
car_params = CarInterface.get_params(car_name, fingerprints, has_relay, car_fw)
|
||
5 years ago
|
car_interface = CarInterface(car_params, CarController, CarState)
|
||
5 years ago
|
assert car_params
|
||
|
assert car_interface
|
||
|
|
||
5 years ago
|
# Run car interface once
|
||
|
CC = car.CarControl.new_message()
|
||
|
car_interface.update(CC, [])
|
||
5 years ago
|
car_interface.apply(CC)
|
||
5 years ago
|
|
||
|
# Test radar interface
|
||
|
RadarInterface = importlib.import_module('selfdrive.car.%s.radar_interface' % car_params.carName).RadarInterface
|
||
|
radar_interface = RadarInterface(car_params)
|
||
|
assert radar_interface
|
||
|
|
||
5 years ago
|
# Run radar interface once
|
||
5 years ago
|
radar_interface.update([])
|
||
|
if hasattr(radar_interface, '_update') and hasattr(radar_interface, 'trigger_msg'):
|
||
|
radar_interface._update([radar_interface.trigger_msg])
|
||
5 years ago
|
|
||
|
if __name__ == "__main__":
|
||
|
unittest.main()
|