mirror of https://github.com/commaai/openpilot.git
Test all of selfdrive/ (#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
This commit is contained in:
parent
81ed1decc9
commit
66ec788005
13
conftest.py
13
conftest.py
|
@ -8,6 +8,19 @@ from openpilot.common.prefix import OpenpilotPrefix
|
||||||
from openpilot.system.manager import manager
|
from openpilot.system.manager import manager
|
||||||
from openpilot.system.hardware import TICI, HARDWARE
|
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):
|
def pytest_sessionstart(session):
|
||||||
# TODO: fix tests and enable test order randomization
|
# TODO: fix tests and enable test order randomization
|
||||||
|
|
|
@ -148,14 +148,7 @@ markers = [
|
||||||
]
|
]
|
||||||
testpaths = [
|
testpaths = [
|
||||||
"common",
|
"common",
|
||||||
"selfdrive/pandad",
|
"selfdrive",
|
||||||
"selfdrive/car",
|
|
||||||
"selfdrive/opcar",
|
|
||||||
"selfdrive/controls",
|
|
||||||
"selfdrive/locationd",
|
|
||||||
"selfdrive/monitoring",
|
|
||||||
"selfdrive/test/longitudinal_maneuvers",
|
|
||||||
"selfdrive/test/process_replay/test_fuzzy.py",
|
|
||||||
"system/updated",
|
"system/updated",
|
||||||
"system/athena",
|
"system/athena",
|
||||||
"system/camerad",
|
"system/camerad",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import random
|
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
|
from openpilot.selfdrive.selfdrived.alertmanager import AlertManager
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,6 @@ class TestAlertManager:
|
||||||
AM.add_many(frame, [alert, ])
|
AM.add_many(frame, [alert, ])
|
||||||
AM.process_alerts(frame, {})
|
AM.process_alerts(frame, {})
|
||||||
|
|
||||||
shown = AM.current_alert is not None
|
shown = AM.current_alert != EmptyAlert
|
||||||
should_show = frame <= show_duration
|
should_show = frame <= show_duration
|
||||||
assert shown == should_show, f"{frame=} {add_duration=} {duration=}"
|
assert shown == should_show, f"{frame=} {add_duration=} {duration=}"
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TestAlerts:
|
||||||
# Create fake objects for callback
|
# Create fake objects for callback
|
||||||
cls.CS = car.CarState.new_message()
|
cls.CS = car.CarState.new_message()
|
||||||
cls.CP = car.CarParams.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)
|
cls.sm = SubMaster(cfg.pubs)
|
||||||
|
|
||||||
def test_events_defined(self):
|
def test_events_defined(self):
|
||||||
|
|
|
@ -4,8 +4,7 @@ import sys
|
||||||
|
|
||||||
from openpilot.common.prefix import OpenpilotPrefix
|
from openpilot.common.prefix import OpenpilotPrefix
|
||||||
|
|
||||||
|
|
||||||
with OpenpilotPrefix():
|
with OpenpilotPrefix():
|
||||||
ret = subprocess.call(sys.argv[1:])
|
ret = subprocess.call(sys.argv[1:])
|
||||||
|
|
||||||
exit(ret)
|
sys.exit(ret)
|
||||||
|
|
|
@ -466,7 +466,7 @@ CONFIGS = [
|
||||||
"longitudinalPlan", "livePose", "liveParameters", "radarState",
|
"longitudinalPlan", "livePose", "liveParameters", "radarState",
|
||||||
"modelV2", "driverCameraState", "roadCameraState", "wideRoadCameraState", "managerState",
|
"modelV2", "driverCameraState", "roadCameraState", "wideRoadCameraState", "managerState",
|
||||||
"liveTorqueParameters", "accelerometer", "gyroscope", "carOutput",
|
"liveTorqueParameters", "accelerometer", "gyroscope", "carOutput",
|
||||||
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance",
|
"gpsLocationExternal", "gpsLocation", "controlsState", "carControl", "driverAssistance", "alertDebug",
|
||||||
],
|
],
|
||||||
subs=["selfdriveState", "onroadEvents"],
|
subs=["selfdriveState", "onroadEvents"],
|
||||||
ignore=["logMonoTime"],
|
ignore=["logMonoTime"],
|
||||||
|
|
|
@ -11,6 +11,7 @@ int main(int argc, char **argv) {
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QString language_file = "main_test_en";
|
QString language_file = "main_test_en";
|
||||||
|
// FIXME: pytest-cpp considers this print as a test case
|
||||||
qDebug() << "Loading language:" << language_file;
|
qDebug() << "Loading language:" << language_file;
|
||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
|
|
Loading…
Reference in New Issue