Pytest: tici mark for skipping on-device tests (#30412)

* mark tici

* not those ones

* missed that one

* add those

* add pypoetry

* oops
old-commit-hash: aec7cea30d
testing-closet
Justin Newberry 1 year ago committed by GitHub
parent 7bd8c5425b
commit 3027a428cb
  1. 8
      conftest.py
  2. 3
      pyproject.toml
  3. 1
      release/files_common
  4. 6
      selfdrive/boardd/tests/test_pandad.py
  5. 2
      selfdrive/manager/test/test_manager.py
  6. 1
      selfdrive/modeld/tests/test_modeld.py
  7. 6
      selfdrive/navd/tests/test_map_renderer.py
  8. 2
      selfdrive/test/test_onroad.py
  9. 2
      selfdrive/test/test_time_to_onroad.py
  10. 2
      selfdrive/test/test_updated.py
  11. 6
      system/camerad/test/test_camerad.py
  12. 7
      system/hardware/tici/tests/test_hardware.py
  13. 9
      system/hardware/tici/tests/test_power_draw.py
  14. 8
      system/loggerd/tests/test_encoder.py
  15. 6
      system/sensord/rawgps/test_rawgps.py
  16. 7
      system/sensord/tests/test_pigeond.py
  17. 6
      system/sensord/tests/test_sensord.py
  18. 6
      tools/gpstest/test_gps.py
  19. 6
      tools/gpstest/test_gps_qcom.py

@ -2,6 +2,7 @@ import os
import pytest import pytest
from openpilot.common.prefix import OpenpilotPrefix from openpilot.common.prefix import OpenpilotPrefix
from openpilot.system.hardware import TICI
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
@ -31,3 +32,10 @@ def openpilot_class_fixture():
os.environ.clear() os.environ.clear()
os.environ.update(starting_env) os.environ.update(starting_env)
def pytest_collection_modifyitems(config, items):
skipper = pytest.mark.skip(reason="Skipping tici test on PC")
for item in items:
if not TICI and "tici" in item.keywords:
item.add_marker(skipper)

@ -5,7 +5,8 @@ addopts = "--ignore=openpilot/ --ignore=cereal/ --ignore=opendbc/ --ignore=panda
python_files = "test_*.py" python_files = "test_*.py"
#timeout = "30" # you get this long by default #timeout = "30" # you get this long by default
markers = [ markers = [
"slow: tests that take awhile to run and can be skipped with -m 'not slow'" "slow: tests that take awhile to run and can be skipped with -m 'not slow'",
"tici: tests that are only meant to run on the C3/C3X",
] ]
testpaths = [ testpaths = [
"common", "common",

@ -6,6 +6,7 @@ launch_openpilot.sh
Jenkinsfile Jenkinsfile
SConstruct SConstruct
pyproject.toml
README.md README.md
RELEASES.md RELEASES.md

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import pytest
import time import time
import unittest import unittest
@ -8,17 +9,16 @@ from cereal import log
from openpilot.common.gpio import gpio_set, gpio_init from openpilot.common.gpio import gpio_set, gpio_init
from panda import Panda, PandaDFU, PandaProtocolMismatch from panda import Panda, PandaDFU, PandaProtocolMismatch
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.system.hardware import HARDWARE, PC from openpilot.system.hardware import HARDWARE
from openpilot.system.hardware.tici.pins import GPIO from openpilot.system.hardware.tici.pins import GPIO
HERE = os.path.dirname(os.path.realpath(__file__)) HERE = os.path.dirname(os.path.realpath(__file__))
@pytest.mark.tici
class TestPandad(unittest.TestCase): class TestPandad(unittest.TestCase):
def setUp(self): def setUp(self):
if PC:
raise unittest.SkipTest("needs a panda")
# ensure panda is up # ensure panda is up
if len(Panda.list()) == 0: if len(Panda.list()) == 0:
self._run_test(60) self._run_test(60)

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import pytest
import signal import signal
import time import time
import unittest import unittest
@ -17,6 +18,7 @@ MAX_STARTUP_TIME = 3
BLACKLIST_PROCS = ['manage_athenad', 'pandad', 'pigeond'] BLACKLIST_PROCS = ['manage_athenad', 'pandad', 'pigeond']
@pytest.mark.tici
class TestManager(unittest.TestCase): class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
os.environ['PASSIVE'] = '0' os.environ['PASSIVE'] = '0'

@ -13,6 +13,7 @@ from openpilot.selfdrive.test.process_replay.vision_meta import meta_from_camera
IMG = np.zeros(int(tici_f_frame_size[0]*tici_f_frame_size[1]*(3/2)), dtype=np.uint8) IMG = np.zeros(int(tici_f_frame_size[0]*tici_f_frame_size[1]*(3/2)), dtype=np.uint8)
IMG_BYTES = IMG.flatten().tobytes() IMG_BYTES = IMG.flatten().tobytes()
class TestModeld(unittest.TestCase): class TestModeld(unittest.TestCase):
def setUp(self): def setUp(self):

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import numpy as np import numpy as np
import os import os
import pytest
import unittest import unittest
import requests import requests
import threading import threading
@ -10,7 +11,6 @@ import cereal.messaging as messaging
from typing import Any from typing import Any
from cereal.visionipc import VisionIpcClient, VisionStreamType from cereal.visionipc import VisionIpcClient, VisionStreamType
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.system.hardware import TICI
LLK_DECIMATION = 10 LLK_DECIMATION = 10
CACHE_PATH = "/data/mbgl-cache-navd.db" CACHE_PATH = "/data/mbgl-cache-navd.db"
@ -189,10 +189,8 @@ class TestMapRenderer(unittest.TestCase):
self._run_test(True, LOCATION2_REPEATED) self._run_test(True, LOCATION2_REPEATED)
@pytest.mark.tici
def test_render_time_distribution(self): def test_render_time_distribution(self):
if not TICI:
raise unittest.SkipTest
self._setup_test() self._setup_test()
# from location1 -> location2 and back # from location1 -> location2 and back
locations = np.array([*np.linspace(LOCATION1, LOCATION2, 2000), *np.linspace(LOCATION2, LOCATION1, 2000)]).tolist() locations = np.array([*np.linspace(LOCATION1, LOCATION2, 2000), *np.linspace(LOCATION2, LOCATION1, 2000)]).tolist()

@ -5,6 +5,7 @@ import json
import os import os
import pathlib import pathlib
import psutil import psutil
import pytest
import shutil import shutil
import subprocess import subprocess
import time import time
@ -98,6 +99,7 @@ def cputime_total(ct):
return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem return ct.cpuUser + ct.cpuSystem + ct.cpuChildrenUser + ct.cpuChildrenSystem
@pytest.mark.tici
class TestOnroad(unittest.TestCase): class TestOnroad(unittest.TestCase):
@classmethod @classmethod

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import pytest
import time import time
import subprocess import subprocess
@ -9,6 +10,7 @@ from openpilot.common.timeout import Timeout
from openpilot.selfdrive.test.helpers import set_params_enabled from openpilot.selfdrive.test.helpers import set_params_enabled
@pytest.mark.tici
def test_time_to_onroad(): def test_time_to_onroad():
# launch # launch
set_params_enabled() set_params_enabled()

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import datetime import datetime
import os import os
import pytest
import time import time
import tempfile import tempfile
import unittest import unittest
@ -13,6 +14,7 @@ from openpilot.common.basedir import BASEDIR
from openpilot.common.params import Params from openpilot.common.params import Params
@pytest.mark.tici
class TestUpdated(unittest.TestCase): class TestUpdated(unittest.TestCase):
def setUp(self): def setUp(self):

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import time import time
import unittest import unittest
import numpy as np import numpy as np
@ -8,7 +9,6 @@ import cereal.messaging as messaging
from cereal import log from cereal import log
from cereal.services import SERVICE_LIST from cereal.services import SERVICE_LIST
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.system.hardware import TICI
TEST_TIMESPAN = 30 TEST_TIMESPAN = 30
LAG_FRAME_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 0.5, # ARs use synced pulses for frame starts LAG_FRAME_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 0.5, # ARs use synced pulses for frame starts
@ -19,12 +19,10 @@ FRAME_DELTA_TOLERANCE = {log.FrameData.ImageSensor.ar0231: 1.0,
CAMERAS = ('roadCameraState', 'driverCameraState', 'wideRoadCameraState') CAMERAS = ('roadCameraState', 'driverCameraState', 'wideRoadCameraState')
@pytest.mark.tici
class TestCamerad(unittest.TestCase): class TestCamerad(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
# run camerad and record logs # run camerad and record logs
managed_processes['camerad'].start() managed_processes['camerad'].start()
time.sleep(3) time.sleep(3)

@ -1,20 +1,19 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import time import time
import unittest import unittest
import numpy as np import numpy as np
from openpilot.system.hardware import TICI
from openpilot.system.hardware.tici.hardware import Tici from openpilot.system.hardware.tici.hardware import Tici
HARDWARE = Tici() HARDWARE = Tici()
@pytest.mark.tici
class TestHardware(unittest.TestCase): class TestHardware(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
HARDWARE.initialize_hardware() HARDWARE.initialize_hardware()
HARDWARE.set_power_save(False) HARDWARE.set_power_save(False)

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import unittest import unittest
import time import time
import threading import threading
@ -9,7 +10,7 @@ from typing import List
import cereal.messaging as messaging import cereal.messaging as messaging
from cereal.services import SERVICE_LIST from cereal.services import SERVICE_LIST
from openpilot.system.hardware import HARDWARE, TICI from openpilot.system.hardware import HARDWARE
from openpilot.system.hardware.tici.power_monitor import get_power from openpilot.system.hardware.tici.power_monitor import get_power
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.selfdrive.manager.manager import manager_cleanup from openpilot.selfdrive.manager.manager import manager_cleanup
@ -44,13 +45,9 @@ def send_llk_msg(done):
time.sleep(1/20.) time.sleep(1/20.)
@pytest.mark.tici
class TestPowerDraw(unittest.TestCase): class TestPowerDraw(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
def setUp(self): def setUp(self):
HARDWARE.initialize_hardware() HARDWARE.initialize_hardware()
HARDWARE.set_power_save(False) HARDWARE.set_power_save(False)

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import math import math
import os import os
import pytest
import random import random
import shutil import shutil
import subprocess import subprocess
@ -31,14 +32,9 @@ CAMERAS = [
FILE_SIZE_TOLERANCE = 0.5 FILE_SIZE_TOLERANCE = 0.5
@pytest.mark.tici # TODO: all of loggerd should work on PC
class TestEncoder(unittest.TestCase): class TestEncoder(unittest.TestCase):
# TODO: all of loggerd should work on PC
@classmethod
def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
def setUp(self): def setUp(self):
self._clear_logs() self._clear_logs()
os.environ["LOGGERD_TEST"] = "1" os.environ["LOGGERD_TEST"] = "1"

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import pytest
import json import json
import time import time
import datetime import datetime
@ -7,19 +8,16 @@ import unittest
import subprocess import subprocess
import cereal.messaging as messaging import cereal.messaging as messaging
from openpilot.system.hardware import TICI
from openpilot.system.sensord.rawgps.rawgpsd import at_cmd, wait_for_modem from openpilot.system.sensord.rawgps.rawgpsd import at_cmd, wait_for_modem
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
GOOD_SIGNAL = bool(int(os.getenv("GOOD_SIGNAL", '0'))) GOOD_SIGNAL = bool(int(os.getenv("GOOD_SIGNAL", '0')))
@pytest.mark.tici
class TestRawgpsd(unittest.TestCase): class TestRawgpsd(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
os.system("sudo systemctl start systemd-resolved") os.system("sudo systemctl start systemd-resolved")
os.system("sudo systemctl restart ModemManager lte") os.system("sudo systemctl restart ModemManager lte")
wait_for_modem() wait_for_modem()

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import time import time
import unittest import unittest
@ -7,16 +8,12 @@ from cereal.services import SERVICE_LIST
from openpilot.common.gpio import gpio_read from openpilot.common.gpio import gpio_read
from openpilot.selfdrive.test.helpers import with_processes from openpilot.selfdrive.test.helpers import with_processes
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.system.hardware import TICI
from openpilot.system.hardware.tici.pins import GPIO from openpilot.system.hardware.tici.pins import GPIO
# TODO: test TTFF when we have good A-GNSS # TODO: test TTFF when we have good A-GNSS
@pytest.mark.tici
class TestPigeond(unittest.TestCase): class TestPigeond(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
def tearDown(self): def tearDown(self):
managed_processes['pigeond'].stop() managed_processes['pigeond'].stop()

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import pytest
import time import time
import unittest import unittest
import numpy as np import numpy as np
@ -10,7 +11,6 @@ from cereal import log
from cereal.services import SERVICE_LIST from cereal.services import SERVICE_LIST
from openpilot.common.gpio import get_irqs_for_action from openpilot.common.gpio import get_irqs_for_action
from openpilot.common.timeout import Timeout from openpilot.common.timeout import Timeout
from openpilot.system.hardware import TICI
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
BMX = { BMX = {
@ -98,12 +98,10 @@ def read_sensor_events(duration_sec):
return {k: v for k, v in events.items() if len(v) > 0} return {k: v for k, v in events.items() if len(v) > 0}
@pytest.mark.tici
class TestSensord(unittest.TestCase): class TestSensord(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
# enable LSM self test # enable LSM self test
os.environ["LSM_SELF_TEST"] = "1" os.environ["LSM_SELF_TEST"] = "1"

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import time import time
import unittest import unittest
import struct import struct
@ -6,7 +7,6 @@ import struct
from openpilot.common.params import Params from openpilot.common.params import Params
import cereal.messaging as messaging import cereal.messaging as messaging
import openpilot.system.sensord.pigeond as pd import openpilot.system.sensord.pigeond as pd
from openpilot.system.hardware import TICI
from openpilot.selfdrive.test.helpers import with_processes from openpilot.selfdrive.test.helpers import with_processes
@ -107,12 +107,10 @@ def verify_time_to_first_fix(pigeon):
assert ttff < 40, f"Time to first fix > 40s, {ttff}" assert ttff < 40, f"Time to first fix > 40s, {ttff}"
@pytest.mark.tici
class TestGPS(unittest.TestCase): class TestGPS(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
ublox_available = Params().get_bool("UbloxAvailable") ublox_available = Params().get_bool("UbloxAvailable")
if not ublox_available: if not ublox_available:
raise unittest.SkipTest raise unittest.SkipTest

@ -1,10 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import pytest
import time import time
import unittest import unittest
import subprocess as sp import subprocess as sp
from openpilot.common.params import Params from openpilot.common.params import Params
from openpilot.system.hardware import TICI
import cereal.messaging as messaging import cereal.messaging as messaging
from openpilot.selfdrive.manager.process_config import managed_processes from openpilot.selfdrive.manager.process_config import managed_processes
@ -30,12 +30,10 @@ def wait_for_location(socket, timeout):
continue continue
@pytest.mark.tici
class TestGPS(unittest.TestCase): class TestGPS(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
ublox_available = Params().get_bool("UbloxAvailable") ublox_available = Params().get_bool("UbloxAvailable")
if ublox_available: if ublox_available:
raise unittest.SkipTest raise unittest.SkipTest

Loading…
Cancel
Save