Skip to content

Commit 8bef2f8

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 8bef2f8

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

test-case/check-capture.sh

Lines changed: 22 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,6 +59,7 @@ 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
@@ -72,6 +76,12 @@ do
7276
rate=$(func_pipeline_parse_value "$idx" rate)
7377
fmt=$(func_pipeline_parse_value "$idx" fmt)
7478
dev=$(func_pipeline_parse_value "$idx" dev)
79+
80+
if [[ "$tool" == "tinyalsa" ]]; then
81+
card_nr=$(echo $dev | cut -d ':' -f2 | cut -d ',' -f1)
82+
dev_nr=$(echo $dev | cut -d ',' -f2)
83+
fi
84+
7585
pcm=$(func_pipeline_parse_value "$idx" pcm)
7686
type=$(func_pipeline_parse_value "$idx" type)
7787
snd=$(func_pipeline_parse_value "$idx" snd)
@@ -84,7 +94,7 @@ do
8494
do
8595
for i in $(seq 1 $loop_cnt)
8696
do
87-
dlogi "===== Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
97+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
8898
# get the output file
8999
if [[ -z $file_prefix ]]; then
90100
dlogi "no file prefix, use /dev/null as dummy capture output"
@@ -95,10 +105,17 @@ do
95105
dlogi "using $file as capture output"
96106
fi
97107

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."
108+
if [[ "$tool" == "tinyalsa" ]]; then
109+
format=$( echo "$fmt_elem" | grep '[0-9]\+' -o)
110+
tinycap "$file" -D "$card_nr" -d "$dev_nr" -c "$channel" -t "$duration" -r "$rate" -b "$format"
111+
elif [[ "$tool" == "alsa" ]]; then
112+
if ! arecord_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" -d $duration "$file" -v -q; then
113+
func_lib_lsof_error_dump "$snd"
114+
die "arecord on PCM $dev failed at $i/$loop_cnt."
115+
fi
116+
else
117+
echo "Unknown tool"
118+
exit
102119
fi
103120
done
104121
done

test-case/check-playback.sh

Lines changed: 22 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
@@ -79,6 +84,10 @@ do
7984
rate=$(func_pipeline_parse_value "$idx" rate)
8085
fmts=$(func_pipeline_parse_value "$idx" fmt)
8186
dev=$(func_pipeline_parse_value "$idx" dev)
87+
if [[ "$tool" == "tinyalsa" ]]; then
88+
card_nr=$(echo $dev | cut -d ':' -f2 | cut -d ',' -f1)
89+
dev_nr=$(echo $dev | cut -d ',' -f2)
90+
fi
8291
pcm=$(func_pipeline_parse_value "$idx" pcm)
8392
type=$(func_pipeline_parse_value "$idx" type)
8493
snd=$(func_pipeline_parse_value "$idx" snd)
@@ -91,12 +100,20 @@ do
91100
do
92101
for i in $(seq 1 $loop_cnt)
93102
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" \
103+
dlogi "===== Testing: (Tool: $tool) (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt) ====="
104+
if [[ "$tool" == "tinyalsa" ]]; then
105+
sox -n -r "$rate" -c "$channel" noise.wav synth "$duration" white
106+
tinyplay -D "$card_nr" -d "$dev_nr" -i wav noise.wav
107+
elif [[ "$tool" == "alsa" ]]; then
108+
aplay_opts -D"$dev" -r "$rate" -c "$channel" -f "$fmt_elem" \
96109
-d "$duration" "$file" -v -q || {
97-
func_lib_lsof_error_dump "$snd"
98-
die "aplay on PCM $dev failed at $i/$loop_cnt."
99-
}
110+
func_lib_lsof_error_dump "$snd"
111+
die "aplay on PCM $dev failed at $i/$loop_cnt."
112+
}
113+
else
114+
echo "Unknown tool"
115+
exit
116+
fi
100117
done
101118
done
102119
done

0 commit comments

Comments
 (0)