mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 21:14:01 +08:00
Add sensord test to Jenkins (#24524)
* Add sensord test to Jenkins
* add second configuration
* add other configs too
* rename
* move into existing HW tests
old-commit-hash: 822ea1fbd9
This commit is contained in:
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@@ -124,6 +124,7 @@ pipeline {
|
||||
["test boardd loopback", "python selfdrive/boardd/tests/test_boardd_loopback.py"],
|
||||
["test loggerd", "python selfdrive/loggerd/tests/test_loggerd.py"],
|
||||
["test encoder", "LD_LIBRARY_PATH=/usr/local/lib python selfdrive/loggerd/tests/test_encoder.py"],
|
||||
["test sensord", "python selfdrive/sensord/test/test_sensord.py"],
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
0
selfdrive/sensord/test/__init__.py
Normal file
0
selfdrive/sensord/test/__init__.py
Normal file
78
selfdrive/sensord/test/test_sensord.py
Executable file
78
selfdrive/sensord/test/test_sensord.py
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from selfdrive.hardware import TICI
|
||||
from selfdrive.test.helpers import with_processes
|
||||
|
||||
TEST_TIMESPAN = 10
|
||||
|
||||
SENSOR_CONFIGURATIONS = (
|
||||
{
|
||||
('bmx055', 'acceleration'),
|
||||
('bmx055', 'gyroUncalibrated'),
|
||||
('bmx055', 'magneticUncalibrated'),
|
||||
('bmx055', 'temperature'),
|
||||
('lsm6ds3', 'acceleration'),
|
||||
('lsm6ds3', 'gyroUncalibrated'),
|
||||
('lsm6ds3', 'temperature'),
|
||||
('rpr0521', 'light'),
|
||||
},
|
||||
{
|
||||
('lsm6ds3', 'acceleration'),
|
||||
('lsm6ds3', 'gyroUncalibrated'),
|
||||
('lsm6ds3', 'temperature'),
|
||||
('mmc5603nj', 'magneticUncalibrated'),
|
||||
('rpr0521', 'light'),
|
||||
},
|
||||
{
|
||||
('bmx055', 'acceleration'),
|
||||
('bmx055', 'gyroUncalibrated'),
|
||||
('bmx055', 'magneticUncalibrated'),
|
||||
('bmx055', 'temperature'),
|
||||
('lsm6ds3trc', 'acceleration'),
|
||||
('lsm6ds3trc', 'gyroUncalibrated'),
|
||||
('lsm6ds3trc', 'temperature'),
|
||||
('rpr0521', 'light'),
|
||||
},
|
||||
{
|
||||
('lsm6ds3trc', 'acceleration'),
|
||||
('lsm6ds3trc', 'gyroUncalibrated'),
|
||||
('lsm6ds3trc', 'temperature'),
|
||||
('mmc5603nj', 'magneticUncalibrated'),
|
||||
('rpr0521', 'light'),
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class TestSensord(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
if not TICI:
|
||||
raise unittest.SkipTest
|
||||
|
||||
@with_processes(['sensord'])
|
||||
def test_sensors_present(self):
|
||||
sensor_events = messaging.sub_sock("sensorEvents", timeout=0.1)
|
||||
|
||||
start_time_sec = time.time()
|
||||
events = []
|
||||
while time.time() - start_time_sec < TEST_TIMESPAN:
|
||||
events += messaging.drain_sock(sensor_events)
|
||||
time.sleep(0.01)
|
||||
|
||||
seen = set()
|
||||
for event in events:
|
||||
for measurement in event.sensorEvents:
|
||||
# Filter out unset events
|
||||
if measurement.version == 0:
|
||||
continue
|
||||
seen.add((str(measurement.source), measurement.which()))
|
||||
|
||||
self.assertIn(seen, SENSOR_CONFIGURATIONS)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user