soundd: fix test for repeating soundsgitt status (#23110)

Co-authored-by: Comma Device <device@comma.ai>
old-commit-hash: 37e2de2244
commatwo_master
Adeeb Shihadeh 3 years ago committed by GitHub
parent 95f54ffb39
commit 7dbffc72c0
  1. 12
      selfdrive/ui/tests/test_soundd.py

@ -18,11 +18,11 @@ SOUNDS = {
AudibleAlert.engage: 197,
AudibleAlert.disengage: 230,
AudibleAlert.refuse: 189,
AudibleAlert.prompt: 217,
AudibleAlert.promptRepeat: 475,
AudibleAlert.prompt: 230,
AudibleAlert.promptRepeat: 468,
AudibleAlert.promptDistracted: 187,
AudibleAlert.warningSoft: 477,
AudibleAlert.warningImmediate: 468,
AudibleAlert.warningSoft: 499,
AudibleAlert.warningImmediate: 496,
}
def get_total_writes():
@ -51,12 +51,13 @@ class TestSoundd(unittest.TestCase):
print(f"testing {alert_sounds[sound]}")
start_writes = get_total_writes()
for _ in range(int(9 / DT_CTRL)):
for i in range(int(10 / DT_CTRL)):
msg = messaging.new_message('deviceState')
msg.deviceState.started = True
pm.send('deviceState', msg)
msg = messaging.new_message('controlsState')
if i < int(6 / DT_CTRL):
msg.controlsState.alertSound = sound
msg.controlsState.alertType = str(sound)
msg.controlsState.alertText1 = "Testing Sounds"
@ -67,6 +68,7 @@ class TestSoundd(unittest.TestCase):
tolerance = expected_writes / 10
actual_writes = get_total_writes() - start_writes
#print(f" expected {expected_writes} writes, got {actual_writes}")
assert abs(expected_writes - actual_writes) <= tolerance, f"{alert_sounds[sound]}: expected {expected_writes} writes, got {actual_writes}"
if __name__ == "__main__":

Loading…
Cancel
Save