From 201092d6aae2c1603f135d9bbbe8c6a663b9b055 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 13 Jan 2024 21:30:05 -0800 Subject: [PATCH 1/3] that's super slow --- tools/replay/tests/test_replay.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/replay/tests/test_replay.cc b/tools/replay/tests/test_replay.cc index 1873daaf4ba1ca..a01e0c2c5bcb17 100644 --- a/tools/replay/tests/test_replay.cc +++ b/tools/replay/tests/test_replay.cc @@ -126,8 +126,6 @@ std::string download_demo_route() { std::string log_path = util::string_format("%s/%s--%d/", data_dir.c_str(), route_name.c_str(), i); util::create_directories(log_path, 0755); REQUIRE(download_to_file(remote_route.at(i).rlog.toStdString(), log_path + "rlog.bz2")); - REQUIRE(download_to_file(remote_route.at(i).driver_cam.toStdString(), log_path + "dcamera.hevc")); - REQUIRE(download_to_file(remote_route.at(i).wide_road_cam.toStdString(), log_path + "ecamera.hevc")); REQUIRE(download_to_file(remote_route.at(i).qcamera.toStdString(), log_path + "qcamera.ts")); } } @@ -139,7 +137,7 @@ std::string download_demo_route() { TEST_CASE("Local route") { std::string data_dir = download_demo_route(); - auto flags = GENERATE(REPLAY_FLAG_DCAM | REPLAY_FLAG_ECAM, REPLAY_FLAG_QCAMERA); + auto flags = GENERATE(0, REPLAY_FLAG_QCAMERA); Route route(DEMO_ROUTE, QString::fromStdString(data_dir)); REQUIRE(route.load()); REQUIRE(route.segments().size() == 2); @@ -149,7 +147,7 @@ TEST_CASE("Local route") { } TEST_CASE("Remote route") { - auto flags = GENERATE(REPLAY_FLAG_DCAM | REPLAY_FLAG_ECAM, REPLAY_FLAG_QCAMERA); + auto flags = GENERATE(0, REPLAY_FLAG_QCAMERA); Route route(DEMO_ROUTE); REQUIRE(route.load()); REQUIRE(route.segments().size() == 13); From b0a2188b5504a3a24673e03037a90f322b2530e3 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 13 Jan 2024 22:08:10 -0800 Subject: [PATCH 2/3] fix startup test --- selfdrive/controls/tests/test_startup.py | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index 6eb803e8aad433..54f73758266647 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import os import time import unittest from parameterized import parameterized @@ -12,6 +13,7 @@ from openpilot.selfdrive.car.mazda.values import CAR as MAZDA from openpilot.selfdrive.controls.lib.events import EVENT_NAME from openpilot.selfdrive.test.helpers import with_processes +from openpilot.selfdrive.manager.process_config import managed_processes EventName = car.CarEvent.EventName Ecu = car.CarParams.Ecu @@ -38,6 +40,9 @@ class TestStartup(unittest.TestCase): + def tearDown(self): + managed_processes['controlsd'].stop() + @parameterized.expand([ # TODO: test EventName.startup for release branches @@ -61,15 +66,11 @@ class TestStartup(unittest.TestCase): (EventName.startupMaster, TOYOTA.COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"), (EventName.startupMaster, TOYOTA.COROLLA, COROLLA_FW_VERSIONS_FUZZY, "toyota"), ]) - @with_processes(['controlsd']) def test_startup_alert(self, expected_event, car_model, fw_versions, brand): - - # TODO: this should be done without any real sockets controls_sock = messaging.sub_sock("controlsState") pm = messaging.PubMaster(['can', 'pandaStates']) params = Params() - params.clear_all() params.put_bool("Passive", False) params.put_bool("OpenpilotEnabledToggle", True) @@ -91,11 +92,13 @@ def test_startup_alert(self, expected_event, car_model, fw_versions, brand): cp.carVin = "1" * 17 cp.carFw = car_fw params.put("CarParamsCache", cp.to_bytes()) + else: + os.environ['SKIP_FW_QUERY'] = '1' - time.sleep(2) # wait for controlsd to be ready + managed_processes['controlsd'].start() + assert pm.wait_for_readers_to_update('can', 5) pm.send('can', can_list_to_can_capnp([[0, 0, b"", 0]])) - time.sleep(0.1) msg = messaging.new_message('pandaStates', 1) msg.pandaStates[0].pandaType = log.PandaState.PandaType.uno @@ -107,18 +110,18 @@ def test_startup_alert(self, expected_event, car_model, fw_versions, brand): else: finger = _FINGERPRINTS[car_model][0] + msgs = [[addr, 0, b'\x00'*length, 0] for addr, length in finger.items()] for _ in range(1000): # controlsd waits for boardd to echo back that it has changed the multiplexing mode if not params.get_bool("ObdMultiplexingChanged"): params.put_bool("ObdMultiplexingChanged", True) - msgs = [[addr, 0, b'\x00'*length, 0] for addr, length in finger.items()] pm.send('can', can_list_to_can_capnp(msgs)) + assert pm.wait_for_readers_to_update('can', 2, dt=0.001) - time.sleep(0.01) - msgs = messaging.drain_sock(controls_sock) - if len(msgs): - event_name = msgs[0].controlsState.alertType.split("/")[0] + ctrls = messaging.drain_sock(controls_sock) + if len(ctrls): + event_name = ctrls[0].controlsState.alertType.split("/")[0] self.assertEqual(EVENT_NAME[expected_event], event_name, f"expected {EVENT_NAME[expected_event]} for '{car_model}', got {event_name}") break From f153b29b491e96f2095345238480baa50da8d064 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 13 Jan 2024 22:12:59 -0800 Subject: [PATCH 3/3] fix --- selfdrive/controls/tests/test_startup.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/selfdrive/controls/tests/test_startup.py b/selfdrive/controls/tests/test_startup.py index 54f73758266647..a93152e84e13dc 100755 --- a/selfdrive/controls/tests/test_startup.py +++ b/selfdrive/controls/tests/test_startup.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import os -import time import unittest from parameterized import parameterized @@ -12,7 +11,6 @@ from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA from openpilot.selfdrive.car.mazda.values import CAR as MAZDA from openpilot.selfdrive.controls.lib.events import EVENT_NAME -from openpilot.selfdrive.test.helpers import with_processes from openpilot.selfdrive.manager.process_config import managed_processes EventName = car.CarEvent.EventName