Skip to content

Commit f96d4e2

Browse files
committed
TinyAlsa: Add support for testing using tinycap and tinyplay.
Added -T parameter to specify whether to use the TinyASLA or ALSA testing tool. For now, it is only for capturing and playback. The default tool is ALSA. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent e7c456d commit f96d4e2

File tree

2 files changed

+48
-10
lines changed

2 files changed

+48
-10
lines changed

test-case/check-capture.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4848
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
4949
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
5050

51+
OPT_NAME['T']="tool" OPT_DESC['T']="Tool for testing"
52+
OPT_HAS_ARG['T']=1 OPT_VAL['T']="alsa"
53+
5154
func_opt_parse_option "$@"
5255

5356
tplg=${OPT_VAL['t']}
@@ -56,10 +59,16 @@ duration=${OPT_VAL['d']}
5659
loop_cnt=${OPT_VAL['l']}
5760
out_dir=${OPT_VAL['o']}
5861
file_prefix=${OPT_VAL['f']}
62+
tool=${OPT_VAL['T']}
5963

6064
start_test
6165
logger_disabled || func_lib_start_log_collect
6266

67+
if [[ "$tool" == "tinyalsa" ]] || [[ "$tool" != "alsa" ]]; then
68+
echo "Unknown tool"
69+
exit
70+
fi
71+
6372
setup_kernel_check_point
6473
func_lib_check_sudo
6574
func_pipeline_export "$tplg" "type:capture & ${OPT_VAL['S']}"
@@ -72,6 +81,12 @@ do
7281
rate=$(func_pipeline_parse_value "$idx" rate)
7382
fmt=$(func_pipeline_parse_value "$idx" fmt)
7483
dev=$(func_pipeline_parse_value "$idx" dev)
84+
85+
if [[ "$tool" == "tinyalsa" ]]; then
86+
card_nr=$(echo $dev | cut -d ':' -f2 | cut -d ',' -f1)
87+
dev_nr=$(echo $dev | cut -d ',' -f2)
88+
fi
89+
7590
pcm=$(func_pipeline_parse_value "$idx" pcm)
7691
type=$(func_pipeline_parse_value "$idx" type)
7792
snd=$(func_pipeline_parse_value "$idx" snd)
@@ -84,7 +99,7 @@ do
8499
do
85100
for i in $(seq 1 $loop_cnt)
86101
do
87-
dlogi "===== Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
102+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
88103
# get the output file
89104
if [[ -z $file_prefix ]]; then
90105
dlogi "no file prefix, use /dev/null as dummy capture output"
@@ -95,10 +110,14 @@ do
95110
dlogi "using $file as capture output"
96111
fi
97112

98-
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d $duration "$file" -v -q;
99-
then
100-
func_lib_lsof_error_dump "$snd"
101-
die "arecord on PCM $dev failed at $i/$loop_cnt."
113+
if [[ "$tool" == "tinyalsa" ]]; then
114+
format=$( echo "$fmt_elem" | grep '[0-9]\+' -o)
115+
tinycap "$file" -D "$card_nr" -d "$dev_nr" -c "$channel" -t "$duration" -r "$rate" -b "$format"
116+
elif [[ "$tool" == "alsa" ]]; then
117+
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d $duration "$file" -v -q; then
118+
func_lib_lsof_error_dump "$snd"
119+
die "arecord on PCM $dev failed at $i/$loop_cnt."
120+
fi
102121
fi
103122
done
104123
done

test-case/check-playback.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ OPT_HAS_ARG['F']=0 OPT_VAL['F']=0
4545
OPT_NAME['S']='filter_string' OPT_DESC['S']="run this case on specified pipelines"
4646
OPT_HAS_ARG['S']=1 OPT_VAL['S']="id:any"
4747

48+
OPT_NAME['T']='tool' OPT_DESC['T']="Tool for testing"
49+
OPT_HAS_ARG['T']=1 OPT_VAL['T']="alsa"
50+
51+
4852
func_opt_parse_option "$@"
4953

5054
tplg=${OPT_VAL['t']}
5155
round_cnt=${OPT_VAL['r']}
5256
duration=${OPT_VAL['d']}
5357
loop_cnt=${OPT_VAL['l']}
5458
file=${OPT_VAL['f']}
59+
tool=${OPT_VAL['T']}
5560

5661
start_test
5762
logger_disabled || func_lib_start_log_collect
@@ -67,6 +72,11 @@ else
6772
dlogi "using $file as playback source"
6873
fi
6974

75+
if [[ "$tool" == "tinyalsa" ]] || [[ "$tool" != "alsa" ]]; then
76+
echo "Unknown tool"
77+
exit
78+
fi
79+
7080
setup_kernel_check_point
7181
func_lib_check_sudo
7282
func_pipeline_export "$tplg" "type:playback & ${OPT_VAL['S']}"
@@ -79,6 +89,10 @@ do
7989
rate=$(func_pipeline_parse_value "$idx" rate)
8090
fmts=$(func_pipeline_parse_value "$idx" fmt)
8191
dev=$(func_pipeline_parse_value "$idx" dev)
92+
if [[ "$tool" == "tinyalsa" ]]; then
93+
card_nr=$(echo $dev | cut -d ':' -f2 | cut -d ',' -f1)
94+
dev_nr=$(echo $dev | cut -d ',' -f2)
95+
fi
8296
pcm=$(func_pipeline_parse_value "$idx" pcm)
8397
type=$(func_pipeline_parse_value "$idx" type)
8498
snd=$(func_pipeline_parse_value "$idx" snd)
@@ -91,12 +105,17 @@ do
91105
do
92106
for i in $(seq 1 $loop_cnt)
93107
do
94-
dlogi "===== Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
95-
aplay_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" \
108+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
109+
if [[ "$tool" == "tinyalsa" ]]; then
110+
sox -n -r "$rate" -c "$channel" noise.wav synth "$duration" white
111+
tinyplay -D "$card_nr" -d "$dev_nr" -i wav noise.wav
112+
elif [[ "$tool" == "alsa" ]]; then
113+
aplay_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" \
96114
-d "$duration" "$file" -v -q || {
97-
func_lib_lsof_error_dump "$snd"
98-
die "aplay on PCM $dev failed at $i/$loop_cnt."
99-
}
115+
func_lib_lsof_error_dump "$snd"
116+
die "aplay on PCM $dev failed at $i/$loop_cnt."
117+
}
118+
fi
100119
done
101120
done
102121
done

0 commit comments

Comments
 (0)