aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhalechang <whalechang@google.com>2022-05-24 09:11:50 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-27 15:16:37 +0000
commita07d539c263dccff47d2b1df7d9947441f98a0bf (patch)
tree83ec67a50f89935c0d93996affbe481e4d67080a
parent1d732b5dc137efdc593418cc76a1a8c094395739 (diff)
downloadautotest-a07d539c263dccff47d2b1df7d9947441f98a0bf.tar.gz
autotest: audio_AudioInputGain: remove this test
Since we already have audio.UIInput.gain, we can remove this test. BUG=b:233504696 TEST=None Change-Id: I8f4cc0ce5ff34b8272e53a3cd809bf226d876270 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/3662350 Auto-Submit: Ching Yun Chang <whalechang@google.com> Commit-Queue: Ching Yun Chang <whalechang@google.com> Tested-by: Ching Yun Chang <whalechang@google.com> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
-rw-r--r--client/site_tests/audio_AudioInputGain/audio_AudioInputGain.py155
-rw-r--r--client/site_tests/audio_AudioInputGain/control27
2 files changed, 0 insertions, 182 deletions
diff --git a/client/site_tests/audio_AudioInputGain/audio_AudioInputGain.py b/client/site_tests/audio_AudioInputGain/audio_AudioInputGain.py
deleted file mode 100644
index 56739c3b8e..0000000000
--- a/client/site_tests/audio_AudioInputGain/audio_AudioInputGain.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# Lint as: python2, python3
-# Copyright 2020 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import collections
-import logging
-import os
-import time
-
-from autotest_lib.client.bin import utils
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib.cros import chrome
-from autotest_lib.client.cros import constants as cros_constants
-from autotest_lib.client.cros.audio import audio_helper
-from autotest_lib.client.cros.audio import audio_test_data
-from autotest_lib.client.cros.audio import check_quality
-from autotest_lib.client.cros.audio import cmd_utils
-from autotest_lib.client.cros.audio import cras_utils
-from autotest_lib.client.cros.audio import sox_utils
-from autotest_lib.client.cros.multimedia import audio_facade
-
-
-CheckQualityArgsClass = collections.namedtuple(
- 'args_type', ['filename', 'rate', 'channel', 'bit_width'])
-
-
-class audio_AudioInputGain(audio_helper.cras_rms_test):
- """Verifies input capture gain of chrome.audio API."""
- version = 1
-
- ALOOP_CRAS_NODE_TYPE = 'ALSA_LOOPBACK'
- ALOOP_MODULE_NAME = 'snd-aloop'
- CAPTURE_DURATION = 1
- # 25: -20 dB
- # 75: 10 dB
- # Expected gain: 10 * sqrt(10)
- LOW_GAIN = 25
- HIGH_GAIN = 75
- EXPECTED_GAIN = 31.62
- FREQ_TOLERANCE = 1
- SECOND_PEAK_RATIO_TOLERANCE = 0.05
- GAIN_TOLERANCE = 10
-
- def run_once(self):
- """Entry point of this test."""
- def cras_playback_record(gain_level):
- """Do capture record at CRAS level.
-
- @param gain_level: The input gain level.
-
- @returns: A string for the recorded file path.
-
- """
- # Sine raw file lasts 5 seconds
- raw_path = os.path.join(self.bindir, '5SEC.raw')
- raw_file = audio_test_data.GenerateAudioTestData(
- path=raw_path,
- duration_secs=5,
- frequencies=[440, 440],
- volume_scale=0.05)
-
- recorded_file = os.path.join(self.resultsdir,
- 'cras_recorded_%d.raw' % gain_level)
-
- # Note: we've found that a couple of seconds after Chrome is up,
- # there may be a ~30-second-long output stream sourced from
- # "What's New In Your Chromebook", and it plays no sound.
- # Just ignore it and continue testing.
- p = cmd_utils.popen(cras_utils.playback_cmd(raw_file.path))
- try:
- cras_utils.capture(recorded_file,
- duration=self.CAPTURE_DURATION)
- # Make sure the audio is still playing.
- if p.poll() != None:
- raise error.TestError('playback stopped')
- finally:
- cmd_utils.kill_or_log_returncode(p)
- raw_file.delete()
- return recorded_file
-
- # Check CRAS server is alive. If not, restart it and wait a second to
- # get server ready.
- if utils.get_service_pid('cras') == 0:
- logging.debug('CRAS server is down. Restart it.')
- utils.start_service('cras', ignore_status=True)
- time.sleep(1)
-
- utils.load_module(self.ALOOP_MODULE_NAME)
-
- try:
- with chrome.Chrome(
- extension_paths=[cros_constants.AUDIO_TEST_EXTENSION],
- autotest_ext=True) as cr:
- audio_facade_local = audio_facade.AudioFacadeLocal(cr)
- # Chrome will select nodes after created. Sleep for a while
- # before setting nodes to make sure the nodes will not be
- # switched by Chrome later.
- time.sleep(10)
- audio_facade_local.set_chrome_active_node_type(
- self.ALOOP_CRAS_NODE_TYPE, self.ALOOP_CRAS_NODE_TYPE)
-
- rms_value = []
- for gain in [self.LOW_GAIN, self.HIGH_GAIN]:
- logging.debug('Start testing loopback with gain %d.', gain)
- audio_facade_local.set_chrome_active_input_gain(gain)
- recorded_file = cras_playback_record(gain)
- args = CheckQualityArgsClass(filename=recorded_file,
- rate=48000,
- channel=1,
- bit_width=16)
- raw_data, rate = check_quality.read_audio_file(args)
- checker = check_quality.QualityChecker(raw_data, rate)
- # The highest frequency recorded would be near 24 Khz
- # as the max sample rate is 48000 in our tests.
- # So let's set ignore_high_freq to be 48000.
- checker.do_spectral_analysis(ignore_high_freq=48000,
- check_quality=False,
- quality_params=None)
- spectra = checker._spectrals
- primary_freq = float(spectra[0][0][0])
- if abs(primary_freq - 440.0) > self.FREQ_TOLERANCE:
- raise error.TestFail(
- 'Primary freq is beyond the expectation: '
- 'got %.2f, expected 440.00, tolerance %f' %
- (primary_freq, self.FREQ_TOLERANCE))
-
- if len(spectra[0]) > 1:
- peak_ratio = (float(spectra[0][1][1]) /
- float(spectra[0][0][1]))
- if peak_ratio > self.SECOND_PEAK_RATIO_TOLERANCE:
- raise error.TestFail(
- 'The second peak is not negligible: '
- 'f %.2f, peak_ratio %f (tolerance %f)' %
- (float(spectra[0][1][0]),
- peak_ratio,
- self.SECOND_PEAK_RATIO_TOLERANCE))
-
- sox_stat = sox_utils.get_stat(input=recorded_file,
- channels=1,
- bits=16,
- rate=48000)
- rms_value.append(float(sox_stat.rms))
- logging.debug('signal RMS from sox = %f', rms_value[-1])
-
- gain = rms_value[1] / rms_value[0]
- if abs(gain - self.EXPECTED_GAIN) > self.GAIN_TOLERANCE:
- raise error.TestFail(
- 'Gain is beyond the expectation: '
- 'got %.2f, expected %.2f, tolerance %f' %
- (gain, self.EXPECTED_GAIN, self.GAIN_TOLERANCE))
- finally:
- utils.stop_service('cras', ignore_status=True)
- utils.unload_module(self.ALOOP_MODULE_NAME)
- utils.start_service('cras', ignore_status=True)
diff --git a/client/site_tests/audio_AudioInputGain/control b/client/site_tests/audio_AudioInputGain/control
deleted file mode 100644
index 951a559186..0000000000
--- a/client/site_tests/audio_AudioInputGain/control
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-AUTHOR = 'The Chromium OS Audio Team, chromeos-audio@google.com'
-NAME = 'audio_AudioInputGain'
-PURPOSE = 'Test that the input capture gain is controllable.'
-CRITERIA = '''
-Control the input capture gain by chrome.audio API, and check the actual gain
-from the recorded wave of ALSA loopback.
-'''
-ATTRIBUTES = 'suite:audio_essential, suite:infra_qual, suite:py3-beta'
-TIME = 'SHORT'
-TEST_CATEGORY = 'Functional'
-TEST_CLASS = 'audio'
-TEST_TYPE = 'client'
-DEPENDENCIES = ''
-PY_VERSION = 3
-
-DOC = '''
-Test that the input capture gain is controllable.
-
-NOTE: For this test kernel config is required to have CONFIG_SND_ALOOP=m which
-makes snd-aloop is manually probeable.
-'''
-
-job.run_test('audio_AudioInputGain')