Skip to content

Commit 3919ac5

Browse files
committed
lib.sh: Reset ALSA settings at set_alsa()
Reset ALSA settings with `alsactl init` and `alsactl restore` at `set_alsa()` before it calls `set_alsa_settings` which runs HW model-specific configuration scripts. This way a test case can expect that the `set_alsa` call will apply the DUT's default ALSA settings as the baseline configuration to avoid side-effects possible after the previous tests execution (either passed, or failed) as well as other unexpected changes. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent 61d513c commit 3919ac5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

case-lib/lib.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,22 @@ reset_sof_volume()
12491249

12501250
set_alsa()
12511251
{
1252+
local alsa_log="${LOG_ROOT}/alsa_setup.log"
1253+
1254+
dlogi "Try to initialize all devices to their default ALSA state (alsactl init)."
1255+
printf '%s\n' '-vv------- ALSA init -------vv-' > "${alsa_log}"
1256+
alsactl -d init >> "${alsa_log}" 2>&1 || rc=$?
1257+
[[ "${rc}" -ne 0 ]] && dlogw "alsactl init error=${rc}"
1258+
printf '%s\n' '-^^------- ALSA init -------^^-' >> "${alsa_log}"
1259+
1260+
dlogi "Restore ALSA defaults from /var/lib/alsa/asound.state"
1261+
printf '%s\n' '-vv------- Restore ALSA defaults -------vv-' >> "${alsa_log}"
1262+
# We don't need in sudo to write our alsa_log file, but to call `alsactl restore`.
1263+
# shellcheck disable=SC2024
1264+
sudo alsactl -d restore >> "${alsa_log}" 2>&1 || rc=$?
1265+
[[ "${rc}" -ne 0 ]] && dlogw "alsactl restore error=${rc}"
1266+
printf '%s\n' '-^^------- Restore ALSA defaults -------^^-' >> "${alsa_log}"
1267+
12521268
reset_sof_volume
12531269

12541270
# If MODEL is defined, set proper gain for the platform

0 commit comments

Comments
 (0)