Pytest: consistent hardware state for tici tests (#31279)
* consistent hardware * consistent hardware * moved * this too * ruff * s * duplicated --------- Co-authored-by: Comma Device <device@comma.ai> old-commit-hash: 0277fc5548bc87a17ae34b914df0593d034e5e94
This commit is contained in:
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@@ -208,7 +208,7 @@ node {
|
||||
deviceStage("tici", "tici-common", ["UNSAFE=1"], [
|
||||
["build", "cd selfdrive/manager && ./build.py"],
|
||||
["test pandad", "pytest selfdrive/boardd/tests/test_pandad.py", ["panda/", "selfdrive/boardd/"]],
|
||||
["test power draw", "./system/hardware/tici/tests/test_power_draw.py"],
|
||||
["test power draw", "pytest -s system/hardware/tici/tests/test_power_draw.py"],
|
||||
["test encoder", "LD_LIBRARY_PATH=/usr/local/lib pytest system/loggerd/tests/test_encoder.py"],
|
||||
["test pigeond", "pytest system/sensord/tests/test_pigeond.py"],
|
||||
["test manager", "pytest selfdrive/manager/test/test_manager.py"],
|
||||
|
||||
18
conftest.py
18
conftest.py
@@ -4,7 +4,7 @@ import random
|
||||
|
||||
from openpilot.common.prefix import OpenpilotPrefix
|
||||
from openpilot.selfdrive.manager import manager
|
||||
from openpilot.system.hardware import TICI
|
||||
from openpilot.system.hardware import TICI, HARDWARE
|
||||
|
||||
|
||||
def pytest_sessionstart(session):
|
||||
@@ -57,12 +57,24 @@ def openpilot_class_fixture():
|
||||
os.environ.update(starting_env)
|
||||
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def tici_setup_fixture():
|
||||
"""Ensure a consistent state for tests on-device"""
|
||||
HARDWARE.initialize_hardware()
|
||||
HARDWARE.set_power_save(False)
|
||||
os.system("pkill -9 -f athena")
|
||||
os.system("rm /dev/shm/*")
|
||||
|
||||
|
||||
@pytest.hookimpl(tryfirst=True)
|
||||
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)
|
||||
if "tici" in item.keywords:
|
||||
if not TICI:
|
||||
item.add_marker(skipper)
|
||||
else:
|
||||
item.fixturenames.append('tici_setup_fixture')
|
||||
|
||||
if "xdist_group_class_property" in item.keywords:
|
||||
class_property_name = item.get_closest_marker('xdist_group_class_property').args[0]
|
||||
|
||||
@@ -112,17 +112,11 @@ class TestOnroad(unittest.TestCase):
|
||||
|
||||
# setup env
|
||||
params = Params()
|
||||
if "CI" in os.environ:
|
||||
params.clear_all()
|
||||
params.remove("CurrentRoute")
|
||||
set_params_enabled()
|
||||
os.environ['TESTING_CLOSET'] = '1'
|
||||
if os.path.exists(Paths.log_root()):
|
||||
shutil.rmtree(Paths.log_root())
|
||||
os.system("rm /dev/shm/*")
|
||||
|
||||
# Make sure athena isn't running
|
||||
os.system("pkill -9 -f athena")
|
||||
|
||||
# start manager and run openpilot for a minute
|
||||
proc = None
|
||||
@@ -429,4 +423,4 @@ class TestOnroad(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
pytest.main()
|
||||
|
||||
@@ -12,11 +12,6 @@ HARDWARE = Tici()
|
||||
@pytest.mark.tici
|
||||
class TestHardware(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
HARDWARE.initialize_hardware()
|
||||
HARDWARE.set_power_save(False)
|
||||
|
||||
def test_power_save_time(self):
|
||||
ts = []
|
||||
for _ in range(5):
|
||||
@@ -30,4 +25,4 @@ class TestHardware(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
pytest.main()
|
||||
|
||||
@@ -11,7 +11,6 @@ import cereal.messaging as messaging
|
||||
from cereal.services import SERVICE_LIST
|
||||
from openpilot.common.mock import mock_messages
|
||||
from openpilot.selfdrive.car.car_helpers import write_car_param
|
||||
from openpilot.system.hardware import HARDWARE
|
||||
from openpilot.system.hardware.tici.power_monitor import get_power
|
||||
from openpilot.selfdrive.manager.process_config import managed_processes
|
||||
from openpilot.selfdrive.manager.manager import manager_cleanup
|
||||
@@ -41,8 +40,6 @@ PROCS = [
|
||||
class TestPowerDraw(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
HARDWARE.initialize_hardware()
|
||||
HARDWARE.set_power_save(False)
|
||||
write_car_param()
|
||||
|
||||
# wait a bit for power save to disable
|
||||
@@ -88,4 +85,4 @@ class TestPowerDraw(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
pytest.main()
|
||||
|
||||
Reference in New Issue
Block a user