Skip to content

Commit

Permalink
Test all of selfdrive/ (#33575)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sshane authored Oct 4, 2024
1 parent 81ed1de commit 66ec788
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
13 changes: 13 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
from openpilot.system.manager import manager
from openpilot.system.hardware import TICI, HARDWARE

# TODO: pytest-cpp doesn't support FAIL, and we need to create test translations in sessionstart
# pending https://github.com/pytest-dev/pytest-cpp/pull/147
collect_ignore = [
"selfdrive/ui/tests/test_translations",
"selfdrive/test/process_replay/test_processes.py",
"selfdrive/test/process_replay/test_regen.py",
"selfdrive/test/test_time_to_onroad.py",
]
collect_ignore_glob = [
"selfdrive/debug/*.py",
"selfdrive/modeld/*.py",
]


def pytest_sessionstart(session):
# TODO: fix tests and enable test order randomization
Expand Down
9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,7 @@ markers = [
]
testpaths = [
"common",
"selfdrive/pandad",
"selfdrive/car",
"selfdrive/opcar",
"selfdrive/controls",
"selfdrive/locationd",
"selfdrive/monitoring",
"selfdrive/test/longitudinal_maneuvers",
"selfdrive/test/process_replay/test_fuzzy.py",
"selfdrive",
"system/updated",
"system/athena",
"system/camerad",
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/selfdrived/tests/test_alertmanager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random

from openpilot.selfdrive.selfdrived.events import Alert, EVENTS
from openpilot.selfdrive.selfdrived.events import Alert, EmptyAlert, EVENTS
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager


Expand Down Expand Up @@ -34,6 +34,6 @@ def test_duration(self):
AM.add_many(frame, [alert, ])
AM.process_alerts(frame, {})

shown = AM.current_alert is not None
shown = AM.current_alert != EmptyAlert
should_show = frame <= show_duration
assert shown == should_show, f"{frame=} {add_duration=} {duration=}"
2 changes: 1 addition & 1 deletion selfdrive/selfdrived/tests/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setup_class(cls):
# Create fake objects for callback
cls.CS = car.CarState.new_message()
cls.CP = car.CarParams.new_message()
cfg = [c for c in CONFIGS if c.proc_name == 'controlsd'][0]
cfg = [c for c in CONFIGS if c.proc_name == 'selfdrived'][0]
cls.sm = SubMaster(cfg.pubs)

def test_events_defined(self):
Expand Down
3 changes: 1 addition & 2 deletions selfdrive/test/cpp_harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

from openpilot.common.prefix import OpenpilotPrefix


with OpenpilotPrefix():
ret = subprocess.call(sys.argv[1:])

exit(ret)
sys.exit(ret)
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/process_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def selfdrived_config_callback(params, cfg, lr):
"longitudinalPlan", "livePose", "liveParameters", "radarState",
"modelV2", "driverCameraState", "roadCameraState", "wideRoadCameraState", "managerState",
"liveTorqueParameters", "accelerometer", "gyroscope", "carOutput",
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance",
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance", "alertDebug",
],
subs=["selfdriveState", "onroadEvents"],
ignore=["logMonoTime"],
Expand Down
1 change: 1 addition & 0 deletions selfdrive/ui/tests/test_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int main(int argc, char **argv) {
QApplication app(argc, argv);

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

QTranslator translator;
Expand Down

0 comments on commit 66ec788

Please sign in to comment.