Skip to content

Commit 66ec788

Browse files
authoredOct 4, 2024
Test all of selfdrive/ (commaai#33575)
* test selfdrived! * exit() is for interactive sessions * fix * comments * more * test all of selfdrive/ * ignore what we used to * fix test_alerts * fix test_alertmanager.py
1 parent 81ed1de commit 66ec788

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed
 

‎conftest.py

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
from openpilot.system.manager import manager
99
from openpilot.system.hardware import TICI, HARDWARE
1010

11+
# TODO: pytest-cpp doesn't support FAIL, and we need to create test translations in sessionstart
12+
# pending https://github.com/pytest-dev/pytest-cpp/pull/147
13+
collect_ignore = [
14+
"selfdrive/ui/tests/test_translations",
15+
"selfdrive/test/process_replay/test_processes.py",
16+
"selfdrive/test/process_replay/test_regen.py",
17+
"selfdrive/test/test_time_to_onroad.py",
18+
]
19+
collect_ignore_glob = [
20+
"selfdrive/debug/*.py",
21+
"selfdrive/modeld/*.py",
22+
]
23+
1124

1225
def pytest_sessionstart(session):
1326
# TODO: fix tests and enable test order randomization

‎pyproject.toml

+1-8
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,7 @@ markers = [
148148
]
149149
testpaths = [
150150
"common",
151-
"selfdrive/pandad",
152-
"selfdrive/car",
153-
"selfdrive/opcar",
154-
"selfdrive/controls",
155-
"selfdrive/locationd",
156-
"selfdrive/monitoring",
157-
"selfdrive/test/longitudinal_maneuvers",
158-
"selfdrive/test/process_replay/test_fuzzy.py",
151+
"selfdrive",
159152
"system/updated",
160153
"system/athena",
161154
"system/camerad",

‎selfdrive/selfdrived/tests/test_alertmanager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import random
22

3-
from openpilot.selfdrive.selfdrived.events import Alert, EVENTS
3+
from openpilot.selfdrive.selfdrived.events import Alert, EmptyAlert, EVENTS
44
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager
55

66

@@ -34,6 +34,6 @@ def test_duration(self):
3434
AM.add_many(frame, [alert, ])
3535
AM.process_alerts(frame, {})
3636

37-
shown = AM.current_alert is not None
37+
shown = AM.current_alert != EmptyAlert
3838
should_show = frame <= show_duration
3939
assert shown == should_show, f"{frame=} {add_duration=} {duration=}"

‎selfdrive/selfdrived/tests/test_alerts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setup_class(cls):
3333
# Create fake objects for callback
3434
cls.CS = car.CarState.new_message()
3535
cls.CP = car.CarParams.new_message()
36-
cfg = [c for c in CONFIGS if c.proc_name == 'controlsd'][0]
36+
cfg = [c for c in CONFIGS if c.proc_name == 'selfdrived'][0]
3737
cls.sm = SubMaster(cfg.pubs)
3838

3939
def test_events_defined(self):

‎selfdrive/test/cpp_harness.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
from openpilot.common.prefix import OpenpilotPrefix
66

7-
87
with OpenpilotPrefix():
98
ret = subprocess.call(sys.argv[1:])
109

11-
exit(ret)
10+
sys.exit(ret)

‎selfdrive/test/process_replay/process_replay.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ def selfdrived_config_callback(params, cfg, lr):
466466
"longitudinalPlan", "livePose", "liveParameters", "radarState",
467467
"modelV2", "driverCameraState", "roadCameraState", "wideRoadCameraState", "managerState",
468468
"liveTorqueParameters", "accelerometer", "gyroscope", "carOutput",
469-
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance",
469+
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance", "alertDebug",
470470
],
471471
subs=["selfdriveState", "onroadEvents"],
472472
ignore=["logMonoTime"],

‎selfdrive/ui/tests/test_runner.cc

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ int main(int argc, char **argv) {
1111
QApplication app(argc, argv);
1212

1313
QString language_file = "main_test_en";
14+
// FIXME: pytest-cpp considers this print as a test case
1415
qDebug() << "Loading language:" << language_file;
1516

1617
QTranslator translator;

0 commit comments

Comments
 (0)
Please sign in to comment.