2024-06-03 17:19:27 -07:00
|
|
|
#!/usr/bin/env python3
|
2022-06-02 17:23:05 -07:00
|
|
|
import argparse
|
|
|
|
|
import sys
|
2024-05-17 11:01:44 -07:00
|
|
|
import unittest # noqa: TID251
|
2022-06-02 17:23:05 -07:00
|
|
|
|
2024-08-26 17:12:01 -07:00
|
|
|
from opendbc.car.tests.routes import CarTestRoute
|
2023-08-20 20:49:55 -07:00
|
|
|
from openpilot.selfdrive.car.tests.test_models import TestCarModel
|
2024-11-01 18:30:01 -05:00
|
|
|
from openpilot.tools.lib.route import SegmentRange
|
2022-06-02 17:23:05 -07:00
|
|
|
|
|
|
|
|
|
2024-11-02 07:35:39 +08:00
|
|
|
def create_test_models_suite(routes: list[CarTestRoute]) -> unittest.TestSuite:
|
2022-06-02 17:23:05 -07:00
|
|
|
test_suite = unittest.TestSuite()
|
2023-08-09 20:36:49 -07:00
|
|
|
for test_route in routes:
|
2022-06-02 17:23:05 -07:00
|
|
|
# create new test case and discover tests
|
2024-11-02 07:35:39 +08:00
|
|
|
test_case_args = {"platform": test_route.car_model, "test_route": test_route}
|
2022-06-02 17:23:05 -07:00
|
|
|
CarModelTestCase = type("CarModelTestCase", (TestCarModel,), test_case_args)
|
|
|
|
|
test_suite.addTest(unittest.TestLoader().loadTestsFromTestCase(CarModelTestCase))
|
|
|
|
|
return test_suite
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
parser = argparse.ArgumentParser(description="Test any route against common issues with a new car port. " +
|
|
|
|
|
"Uses selfdrive/car/tests/test_models.py")
|
2023-04-10 18:56:49 -07:00
|
|
|
parser.add_argument("route_or_segment_name", help="Specify route to run tests on")
|
2022-06-02 17:23:05 -07:00
|
|
|
parser.add_argument("--car", help="Specify car model for test route")
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
if len(sys.argv) == 1:
|
|
|
|
|
parser.print_help()
|
|
|
|
|
sys.exit()
|
|
|
|
|
|
2024-11-01 18:30:01 -05:00
|
|
|
sr = SegmentRange(args.route_or_segment_name)
|
2024-03-07 14:33:40 -05:00
|
|
|
|
2024-11-01 18:30:01 -05:00
|
|
|
test_routes = [CarTestRoute(sr.route_name, args.car, segment=seg_idx) for seg_idx in sr.seg_idxs]
|
2024-11-02 07:35:39 +08:00
|
|
|
test_suite = create_test_models_suite(test_routes)
|
2022-06-02 17:23:05 -07:00
|
|
|
|
|
|
|
|
unittest.TextTestRunner().run(test_suite)
|