Skip to content

Commit 107aeb3

Browse files
committed
alsa: Add common setup_alsa in ALSA tests
All tests using ALSA now use a common setup function, setup_alsa, which checks locale, resets volume to 0dB, verifies whether $MODEL has been set and runs set_alsa_settings. Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
1 parent f9f2401 commit 107aeb3

33 files changed

+79
-28
lines changed

case-lib/lib.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,24 @@ restore_settings_via_alsactl()
12311231
alsactl restore --file="$ALSACTL_STATE_FILE_PATH" --pedantic --no-init-fallback --no-ucm
12321232
}
12331233

1234+
# One-stop shop to initialise alsa-related stuff for tests using it.
1235+
setup_alsa()
1236+
{
1237+
check_locale_for_alsabat
1238+
1239+
# reset sof volume to 0dB
1240+
reset_sof_volume
1241+
1242+
# If MODEL is defined, set proper gain for the platform
1243+
if [ -z "$MODEL" ]; then
1244+
# treat as warning only
1245+
dlogw "NO MODEL is defined. Please define MODEL to run MODEL-based settings configuration"
1246+
else
1247+
#dlogi "apply alsa settings for alsa_settings/MODEL.sh"
1248+
set_alsa_settings "$MODEL"
1249+
fi
1250+
}
1251+
12341252
# check-alsabat.sh need to run optimum alsa control settings
12351253
# param1: platform name
12361254
set_alsa_settings()

test-case/check-alsabat.sh

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,7 @@ then
8181
exit 2
8282
fi
8383

84-
check_locale_for_alsabat
85-
86-
# reset sof volume to 0dB
87-
reset_sof_volume
88-
89-
# If MODEL is defined, set proper gain for the platform
90-
if [ -z "$MODEL" ]; then
91-
# treat as warning only
92-
dlogw "NO MODEL is defined. Please define MODEL to run alsa_settings/MODEL.sh"
93-
else
94-
#dlogi "apply alsa settings for alsa_settings/MODEL.sh"
95-
set_alsa_settings "$MODEL"
96-
fi
84+
setup_alsa
9785

9886
logger_disabled || func_lib_start_log_collect
9987

test-case/check-audio-equalizer.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ sofcard=${SOFCARD:-0}
4444

4545
start_test
4646
setup_kernel_check_point
47+
setup_alsa
4748

4849
# Test equalizer
4950
func_test_eq()

test-case/check-capture.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ start_test
6161
logger_disabled || func_lib_start_log_collect
6262

6363
setup_kernel_check_point
64+
setup_alsa
6465
func_lib_check_sudo
6566
func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}"
6667

test-case/check-fw-echo-reference.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if [ "$PIPELINE_COUNT" != "2" ]; then
5050
die "Only detect $PIPELINE_COUNT pipeline(s) from topology, but two are needed"
5151
fi
5252

53-
check_locale_for_alsabat
53+
setup_alsa
5454

5555
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
5656
do

test-case/check-keyword-detection.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ duration=${OPT_VAL['d']}
5656
start_test
5757
logger_disabled || func_lib_start_log_collect
5858

59+
setup_alsa
60+
5961
func_pipeline_export "$tplg" "kpb:any"
6062

6163
if test "$PIPELINE_COUNT" != "1"; then

test-case/check-kmod-load-unload-after-playback.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ pb_duration=${OPT_VAL['d']}
5656

5757
start_test
5858

59+
setup_alsa
60+
5961
func_pipeline_export "$tplg" "type:playback"
6062

6163
func_lib_check_sudo

test-case/check-kmod-load-unload.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ setup_kernel_check_point
4040

4141
start_test
4242

43+
setup_alsa
44+
4345
loop_cnt=${OPT_VAL['l']}
4446

4547
PATH="${PATH%%:*}/kmod:$PATH"

test-case/check-pause-release-suspend-resume.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ logger_disabled || func_lib_start_log_collect
117117

118118
setup_kernel_check_point
119119

120+
setup_alsa
121+
120122
dlogi "Entering audio stream expect script with: $cmd -D $pcm -r $rate -c $channel -f $fmt -vv -i $dummy_file -q"
121123
dlogi "Will enter suspend-resume cycle during paused period of audio stream process"
122124

test-case/check-pause-resume.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ esac
8080

8181
logger_disabled || func_lib_start_log_collect
8282

83+
setup_alsa
84+
8385
[[ -z $file_name ]] && file_name=$dummy_file
8486

8587
func_pipeline_export "$tplg" "type:$test_mode & ${OPT_VAL['S']}"

0 commit comments

Comments
 (0)