[autotest] audio_helper: raise ValueError in frequency comparison
If the recorded data is too small to be meaningful, we should raise
error instead of saying playback and recorded data does not match.
BUG=chromium:530956
TEST=run audio_AudioBasicBluetoothPlayback test for 10 times and see the
test result.
Change-Id: I70bf8b817302ab39baf0e3c79f1e8c8aca4048c9
Reviewed-on: https://chromium-review.googlesource.com/301572
Commit-Ready: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
diff --git a/client/cros/audio/audio_helper.py b/client/cros/audio/audio_helper.py
index 202e4b2..0e87b4d 100644
--- a/client/cros/audio/audio_helper.py
+++ b/client/cros/audio/audio_helper.py
@@ -830,6 +830,8 @@
golden_data_frequency: golden data frequency.
equal: A bool containing comparing result.
+ @raises: ValueError if the test data RMS is too small to be meaningful.
+
"""
result_dict = dict()
golden_data_stat = get_one_channel_stat(golden_data, golden_data_format)
@@ -843,11 +845,10 @@
abs(result_dict['test_data_frequency'] -
result_dict['golden_data_frequency']) < _FREQUENCY_DIFF_THRESHOLD
) else False
- if test_data_stat.rms < _MEANINGFUL_RMS_THRESHOLD:
- logging.error('Recorded RMS %f is too small to be meaningful.',
- test_data_stat.rms)
- result_dict['equal'] = False
logging.debug('result_dict: %r', result_dict)
+ if test_data_stat.rms < _MEANINGFUL_RMS_THRESHOLD:
+ raise ValueError('Recorded RMS %f is too small to be meaningful.',
+ test_data_stat.rms)
return result_dict