Skip to content

Commit 39cd964

Browse files
committed
test: Init version for test-case
First stage of test cases: check-capture.sh check-ipc-flood.sh check-kmod-load-unload-after-playback.sh check-kmod-load-unload.sh check-pause-resume.sh check-playback.sh check-runtime-pm-status.sh check-sof-logger.sh multiple-pipeline-capture.sh multiple-pipeline-playback.sh simultaneous-playback-capture.sh test-speaker.sh verify-firmware-presence.sh verify-kernel-module-load-probe.sh verify-pcm-list.sh verify-sof-firmware-load.sh verify-tplg-binary.sh volume-basic-test.sh Signed-off-by: Wu, BinX <binx.wu@intel.com> Signed-off-by: Amery Song <chao.song@intel.com> Signed-off-by: Fred Oh <fred.oh@linux.intel.com> Signed-off-by: Kelly Ledford <kelly.ledford@intel.com> Signed-off-by: Libin Yang <libin.yang@linux.intel.com> Signed-off-by: Zhang Keqiao <keqiao.zhang@linux.intel.com> Signed-off-by: Pan Xiuli <xiuli.pan@linux.intel.com>
1 parent 180062e commit 39cd964

18 files changed

+1458
-0
lines changed

test-case/check-capture.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
3+
##
4+
## Case Name: check-capture
5+
## Preconditions:
6+
## N/A
7+
## Description:
8+
## run arecord on each pepeline
9+
## default duration is 10s
10+
## default loop count is 3
11+
## Case step:
12+
## 1. Parse TPLG file to get pipeline with type of "record" and "both"
13+
## 2. Specify the audio parameters
14+
## 3. Run arecord on each pipeline with parameters
15+
## Expect result:
16+
## The return value of arecord is 0
17+
##
18+
19+
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
20+
21+
OPT_OPT_lst['t']='tplg' OPT_DESC_lst['t']='tplg file, default value is env TPLG: $TPLG'
22+
OPT_PARM_lst['t']=1 OPT_VALUE_lst['t']="$TPLG"
23+
24+
OPT_OPT_lst['r']='round' OPT_DESC_lst['r']='round count'
25+
OPT_PARM_lst['r']=1 OPT_VALUE_lst['r']=1
26+
27+
OPT_OPT_lst['d']='duration' OPT_DESC_lst['d']='arecord duration in second'
28+
OPT_PARM_lst['d']=1 OPT_VALUE_lst['d']=10
29+
30+
OPT_OPT_lst['l']='loop' OPT_DESC_lst['l']='loop count'
31+
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=3
32+
33+
OPT_OPT_lst['o']='output' OPT_DESC_lst['o']='output dir'
34+
OPT_PARM_lst['o']=1 OPT_VALUE_lst['o']="$LOG_ROOT/wavs"
35+
36+
OPT_OPT_lst['f']='file' OPT_DESC_lst['f']='file name prefix'
37+
OPT_PARM_lst['f']=1 OPT_VALUE_lst['f']=''
38+
39+
OPT_OPT_lst['s']='sof-logger' OPT_DESC_lst['s']="Open sof-logger trace the data will store at $LOG_ROOT"
40+
OPT_PARM_lst['s']=0 OPT_VALUE_lst['s']=1
41+
42+
func_opt_parse_option $*
43+
44+
tplg=${OPT_VALUE_lst['t']}
45+
round_cnt=${OPT_VALUE_lst['r']}
46+
duration=${OPT_VALUE_lst['d']}
47+
loop_cnt=${OPT_VALUE_lst['l']}
48+
out_dir=${OPT_VALUE_lst['o']}
49+
file_prefix=${OPT_VALUE_lst['f']}
50+
51+
[[ ${OPT_VALUE_lst['s']} -eq 1 ]] && func_lib_start_log_collect
52+
53+
func_lib_setup_kernel_last_line
54+
func_lib_check_sudo
55+
func_pipeline_export $tplg "type:capture,both"
56+
57+
for round in $(seq 1 $round_cnt)
58+
do
59+
for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1))
60+
do
61+
channel=$(func_pipeline_parse_value $idx channel)
62+
rate=$(func_pipeline_parse_value $idx rate)
63+
fmt=$(func_pipeline_parse_value $idx fmt)
64+
dev=$(func_pipeline_parse_value $idx dev)
65+
pcm=$(func_pipeline_parse_value $idx pcm)
66+
type=$(func_pipeline_parse_value $idx type)
67+
68+
# clean up dmesg
69+
sudo dmesg -C
70+
for i in $(seq 1 $loop_cnt)
71+
do
72+
dlogi "Testing: (Round: $round/$round_cnt) (PCM: $pcm [$dev]<$type>) (Loop: $i/$loop_cnt)"
73+
# get the output file
74+
if [[ -z $file_prefix ]]; then
75+
dlogi "no file prefix, use /dev/null as dummy capture output"
76+
file=/dev/null
77+
else
78+
mkdir -p $out_dir
79+
file=$out_dir/${file_prefix}_${dev}_${i}.wav
80+
dlogi "using $file as capture output"
81+
fi
82+
83+
dlogc "arecord -D$dev -r $rate -c $channel -f $fmt -d $duration $file -vv -q"
84+
arecord -D$dev -r $rate -c $channel -f $fmt -d $duration $file -vv -q
85+
if [[ $? -ne 0 ]]; then
86+
dmesg > $LOG_ROOT/arecord_error_${dev}_$i.txt
87+
dloge "arecord on PCM $dev failed at $i/$loop_cnt."
88+
exit 1
89+
fi
90+
dmesg > $LOG_ROOT/arecord_${dev}_$i.txt
91+
done
92+
done
93+
done
94+
95+
sof-kernel-log-check.sh $KERNEL_LAST_LINE
96+
exit $?

test-case/check-ipc-flood.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
##
4+
## Case Name: ipc flood
5+
## Preconditions:
6+
## N/A
7+
## Description:
8+
## check sof debug ipc function can success work
9+
## Case step:
10+
## 1. write target count to ipc_flood_count
11+
## echo 10000 > /sys/kernel/debug/sof/ipc_flood_count
12+
## Expect result:
13+
## without kernel log
14+
##
15+
16+
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
17+
18+
OPT_OPT_lst['c']='cnt' OPT_DESC_lst['c']='ipc loop count'
19+
OPT_PARM_lst['c']=1 OPT_VALUE_lst['c']=10000
20+
21+
OPT_OPT_lst['f']='dfs' OPT_DESC_lst['f']='system dfs file'
22+
OPT_PARM_lst['f']=1 OPT_VALUE_lst['f']="/sys/kernel/debug/sof/ipc_flood_count"
23+
24+
func_opt_parse_option $*
25+
26+
lpc_loop_cnt=${OPT_VALUE_lst['c']}
27+
ipc_flood_dfs=${OPT_VALUE_lst['f']}
28+
29+
[[ ! "$(sof-kernel-dump.sh|grep 'sof-audio'|grep 'Firmware debug build')" ]] && dlogw "${BASH_SOURCE[0]} need debug version firmware" && exit 2
30+
31+
func_lib_setup_kernel_last_line
32+
func_lib_check_sudo
33+
34+
dlogi "Check sof debug fs environment"
35+
[[ "$(sudo file $ipc_flood_dfs|grep 'No such file')" ]] && dlogw "${BASH_SOURCE[0]} need $ipc_flood_dfs to run the test case" && exit 2
36+
dlogi "Checking ipc flood test!"
37+
dlogc "sudo bash -c 'echo $lpc_loop_cnt > $ipc_flood_dfs'"
38+
sudo bash -c "'echo $lpc_loop_cnt > $ipc_flood_dfs'"
39+
40+
sof-kernel-log-check.sh $KERNEL_LAST_LINE
41+
[[ $? -ne 0 ]] && dloge "Catch error in kernel log" && exit 1
42+
43+
dlogi "Dumping test logs!"
44+
dmesg | grep "IPC Flood count" -A 2
45+
46+
exit 0
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
##
4+
## Case Name: check-kmod-load-unload-after-playback
5+
## Preconditions:
6+
## N/A
7+
## Description:
8+
## check kernel module removal/insert process with playback before and after
9+
## Case step:
10+
## 1. enter loop for module remove / insert test
11+
## 2. for each pcm type == playback or both:
12+
## start playback of duration OPT_VALUE_lst['d]'
13+
## 3. check for playback errors
14+
## 4. remove all loaded modules listed in sof_remove.sh
15+
## (only once, not per PCM)
16+
## 5. check for rmmod errors
17+
## 6. check for dmesg errors
18+
## 7. insert all in-tree modules listed in sof_insert.sh
19+
## (only once, not per PCM)
20+
## 8. check for successful sof-firmware boot
21+
## 9. check for dmesg errors
22+
## 10. for each pcm type == playback or both:
23+
## start playback of duration OPT_VALUE_lst['d]'
24+
## 11. check for playback errors
25+
## 12. loop to beginning (max OPT_VALUE_lst['l'])
26+
## Expect result:
27+
## aplay is successful before module removal/insert process per PCM
28+
## removal/insert process is successful (only onc --- not per PCM)
29+
## aplay is succesful after module removal/insert process per PCM
30+
## check kernel log and find no errors
31+
##
32+
33+
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
34+
35+
OPT_OPT_lst['t']='tplg' OPT_DESC_lst['t']='tplg file, default value is env TPLG: $TPLG'
36+
OPT_PARM_lst['t']=1 OPT_VALUE_lst['t']="$TPLG"
37+
38+
OPT_OPT_lst['l']='loop'
39+
OPT_DESC_lst['l']='loop of PCM aplay check - module remove / insert - PCM aplay check'
40+
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=2
41+
42+
OPT_OPT_lst['d']='duration' OPT_DESC_lst['d']='duration of playback process'
43+
OPT_PARM_lst['d']=1 OPT_VALUE_lst['d']=3
44+
45+
OPT_OPT_lst['p']='pulseaudio' OPT_DESC_lst['p']='disable pulseaudio on the test process'
46+
OPT_PARM_lst['p']=0 OPT_VALUE_lst['p']=1
47+
48+
func_opt_parse_option $*
49+
tplg=${OPT_VALUE_lst['t']}
50+
loop_cnt=${OPT_VALUE_lst['l']}
51+
pb_duration=${OPT_VALUE_lst['d']}
52+
53+
func_pipeline_export $tplg "type:playback,both"
54+
55+
func_lib_check_sudo
56+
# overwirte the subscript: test-case LOG_ROOT environment
57+
# so when load the test-case in current script
58+
# the test-case will write the log to the store folder LOG_ROOT
59+
# which is current script log folder
60+
export LOG_ROOT=$LOG_ROOT
61+
62+
if [ ${OPT_VALUE_lst['p']} -eq 1 ];then
63+
func_lib_disable_pulseaudio
64+
fi
65+
66+
$(dirname ${BASH_SOURCE[0]})/check-playback.sh -l 1 -t $tplg -d $pb_duration
67+
ret=$?
68+
[[ $ret -ne 0 ]] && dloge "aplay check failed" && exit $ret
69+
70+
for counter in $(seq 1 $loop_cnt)
71+
do
72+
dlogi "Starting iteration $counter of $loop_cnt"
73+
74+
# logic: if this case disable pulseaudio, the sub case don't need to disable pulseaudio
75+
# if this case don't need to disable pulseaudio, the subcase also don't need to disable pluseaudio
76+
$(dirname ${BASH_SOURCE[0]})/check-kmod-load-unload.sh -l 1 -p
77+
ret=$?
78+
[[ $ret -ne 0 ]] && dloge "kmod reload failed" && exit $ret
79+
80+
$(dirname ${BASH_SOURCE[0]})/check-playback.sh -l 1 -t $tplg -d $pb_duration
81+
ret=$?
82+
[[ $ret -ne 0 ]] && dloge "aplay check failed" && exit $ret
83+
done
84+
85+
# successful exit
86+
exit 0
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
##
4+
## Case Name: check-kmod-load-unload
5+
## Preconditions:
6+
## N/A
7+
## Description:
8+
## check kernel module removal/insert process
9+
## Case step:
10+
## 1. enter loop through the module remove / insert process
11+
## 2. remove all loaded modules listed in sof_remove.sh
12+
## 3. check for rmmod errors
13+
## 4. check for dmesg errors
14+
## 5. insert all in-tree modules listed in sof_insert.sh
15+
## 6. check for successful sof-firmware boot
16+
## 7. check for dmesg errors
17+
## 8. loop to beginning (max OPT_VALUE_lst['r'])
18+
## Expect result:
19+
## kernel module removal / insert process is successful
20+
## check kernel log and find no errors
21+
##
22+
23+
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
24+
25+
OPT_OPT_lst['l']='loop_cnt'
26+
OPT_DESC_lst['l']='remove / insert module loop count -- per device'
27+
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=2
28+
29+
OPT_OPT_lst['p']='pulseaudio' OPT_DESC_lst['p']='disable pulseaudio on the test process'
30+
OPT_PARM_lst['p']=0 OPT_VALUE_lst['p']=1
31+
32+
func_opt_parse_option $*
33+
func_lib_setup_kernel_last_line
34+
35+
loop_cnt=${OPT_VALUE_lst['l']}
36+
usb_audio_module="snd_usb_audio"
37+
kern_log="/var/log/kern.log"
38+
keyword_info=""
39+
40+
PATH="${PATH%%:*}/kmod:$PATH"
41+
func_lib_check_sudo
42+
43+
if [ ${OPT_VALUE_lst['p']} -eq 1 ];then
44+
func_lib_disable_pulseaudio
45+
fi
46+
47+
for idx in $(seq 1 $loop_cnt)
48+
do
49+
dlogi "Starting iteration $idx of $loop_cnt"
50+
## - 1: remove module section
51+
func_lib_setup_kernel_last_line
52+
53+
dlogi "run kmod/sof-kmod-remove.sh"
54+
sudo env "PATH=$PATH" sof_remove.sh
55+
[[ $? -ne 0 ]] && dloge "remove modules error" && exit 1
56+
57+
## - 1a: check for errors after removal
58+
dlogi "checking for general errors after kmod unload with sof-kernel-log-check tool"
59+
sof-kernel-log-check.sh $KERNEL_LAST_LINE
60+
[[ $? -ne 0 ]] && \
61+
dloge "error found after kmod unload is real error, failing" && \
62+
exit 1
63+
64+
func_lib_setup_kernel_last_line
65+
dlogi "run kmod/sof_insert.sh"
66+
sudo env "PATH=$PATH" sof_insert.sh
67+
[[ $? -ne 0 ]] && dloge "insert modules error" && exit
68+
sleep 1
69+
70+
## - 2a: check for errors after insertion
71+
dlogi "checking for general errors after kmod insert with sof-kernel-log-check tool"
72+
sof-kernel-log-check.sh $KERNEL_LAST_LINE
73+
74+
dlogi "checking for fw_boot success"
75+
keyword_info=$(dmesg |grep sof-audio | grep 'boot complete')
76+
[[ ! "$keyword_info" ]] && \
77+
dloge "Error: Boot Complete not found in dmesg, fw_boot empty" && \
78+
exit 1
79+
80+
# successful remove/insert module pass
81+
dlogi "==== completed boot firmware: $idx of $loop_cnt ===="
82+
# pulseaudio deamon will detect the snd_sof_pci device after 3s
83+
# so after 2s snd_sof_pci device will in used status which is block current case logic
84+
# here the logic is to check snd_sof_pci status is not in used status, the max delay is 10s
85+
sleep 1
86+
for i in $(seq 1 10)
87+
do
88+
[[ "X$(awk '/^snd_sof_pci/ {print $3;}' /proc/modules)" == "X0" ]] && break
89+
sleep 1
90+
done
91+
92+
done
93+
94+
exit 0

0 commit comments

Comments
 (0)