Files
sunnypilot/system/hardware/tici/tests/test_hardware.py
Adeeb Shihadeh d92c9aef23 tici: speedup power save setting (#29100)
* speedup

* update type

---------

Co-authored-by: Comma Device <device@comma.ai>
2023-07-22 17:15:58 -07:00

32 lines
612 B
Python
Executable File

#!/usr/bin/env python3
import time
import unittest
import numpy as np
from system.hardware import TICI
from system.hardware.tici.hardware import Tici
HARDWARE = Tici()
class TestHardware(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not TICI:
raise unittest.SkipTest
def test_power_save_time(self):
ts = []
for _ in range(5):
for on in (True, False):
st = time.monotonic()
HARDWARE.set_power_save(on)
ts.append(time.monotonic() - st)
assert 0.1 < np.mean(ts) < 0.2
assert max(ts) < 0.3
if __name__ == "__main__":
unittest.main()