summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZixun LI <[email protected]>2026-07-28 19:15:20 +0200
committerZixun LI <[email protected]>2026-07-28 19:15:20 +0200
commita240ee5be90a8d5e45f4f93788e307a1ba840b31 (patch)
tree9d6acaaeefcc515ff77e69771e5f25b965642ada
parent9d9b2ef21c4663e740e687dcc403f9df0add11ce (diff)
test/hil: require exact audio ramp
-rwxr-xr-xtest/hil/hil_test.py22
1 files changed, 6 insertions, 16 deletions
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py
index 58452f64a..922668041 100755
--- a/test/hil/hil_test.py
+++ b/test/hil/hil_test.py
@@ -1672,23 +1672,13 @@ def test_device_audio_test_freertos(board):
assert sample_count > 1024, f'Not enough samples captured: {sample_count}'
# The firmware sends a continuous uint16 ramp. Using ALSA hw: capture bypasses
- # PulseAudio processing, so most adjacent samples should differ by exactly 1.
- total_diffs = sample_count - 1
- one_step = 0
- near_step = 0
- for i in range(total_diffs):
- d = (samples[i + 1] - samples[i]) & 0xFFFF
- if d == 1:
- one_step += 1
- if d in (0, 1, 2, 47, 48, 49):
- near_step += 1
+ # PulseAudio processing, so every adjacent sample must differ by exactly 1.
+ for i in range(sample_count - 1):
+ expected = (samples[i] + 1) & 0xFFFF
+ assert samples[i + 1] == expected, (
+ f'Audio mismatch at sample {i + 1}: expected {expected}, got {samples[i + 1]}')
- one_ratio = one_step / total_diffs
- near_ratio = near_step / total_diffs
- assert one_ratio >= 0.85, f'Unexpected audio pattern (strict ratio={one_ratio:.3f})'
- assert near_ratio >= 0.98, f'Unexpected audio pattern (relaxed ratio={near_ratio:.3f})'
-
- print(f' ALSA {pcm} strict={one_ratio:.3f} relaxed={near_ratio:.3f}', end='')
+ print(f' ALSA {pcm}', end='')
def test_device_hid_generic_inout(board):