-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathcheck-kmod-load-unload.sh
More file actions
executable file
·121 lines (101 loc) · 4.04 KB
/
check-kmod-load-unload.sh
File metadata and controls
executable file
·121 lines (101 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -e
##
## Case Name: check-kmod-load-unload
## Preconditions:
## N/A
## Description:
## check kernel module removal/insert process
## Case step:
## 1. enter loop through the module remove / insert process
## 2. remove all loaded modules listed in sof_remove.sh
## 3. check for rmmod errors
## 4. check for dmesg errors
## 5. insert all in-tree modules listed in sof_insert.sh
## 6. check for successful sof-firmware boot
## 7. check for dmesg errors
## 8. loop to beginning (max OPT_VAL['r'])
## Expect result:
## kernel module removal / insert process is successful
## check kernel log and find no errors
##
TOPDIR="$(dirname "${BASH_SOURCE[0]}")"/..
TOPDIR=$(cd "$TOPDIR" && pwd)
# shellcheck source=case-lib/lib.sh
source "${TOPDIR}"/case-lib/lib.sh
OPT_NAME['l']='loop_cnt'
OPT_DESC['l']='remove / insert module loop count -- per device'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=2
OPT_NAME['p']='pulseaudio' OPT_DESC['p']='disable pulseaudio on the test process'
OPT_HAS_ARG['p']=0 OPT_VAL['p']=1
func_opt_parse_option "$@"
setup_kernel_check_point
start_test
save_alsa_state
loop_cnt=${OPT_VAL['l']}
PATH="${PATH%%:*}/kmod:$PATH"
func_lib_check_sudo 'unloading modules'
if [ ${OPT_VAL['p']} -eq 1 ];then
func_lib_disable_pulseaudio
fi
for idx in $(seq 1 $loop_cnt)
do
dlogi "===== Starting iteration $idx of $loop_cnt ====="
## - 1: remove module section
setup_kernel_check_point
# After module removal, it takes about 10s for "aplay -l" to show
# device list, within this 10s, it shows "no soundcard found". Here
# we wait dsp status to workaround this.
dlogi "wait dsp power status to become suspended"
for i in $(seq 1 15)
do
# Here we pass a hardcoded 0 to python script, and need to ensure
# DSP is the first audio pci device in 'lspci', this is true unless
# we have a third-party pci sound card installed.
if [[ $(sof-dump-status.py --dsp_status 0) == "unsupported" ]]; then
dlogi "platform doesn't support runtime pm, skip waiting"
break
fi
[[ $(sof-dump-status.py --dsp_status 0) == "suspended" ]] && break
sleep 1
if [ "$i" -eq 15 ]; then
die "dsp is not suspended after 15s, end test"
fi
done
dlogi "run kmod/sof-kmod-remove.sh"
"$TOPDIR"/tools/kmod/sof_remove.sh || die "remove modules error"
## - 1a: check for errors after removal
dlogi "checking for general errors after kmod unload with sof-kernel-log-check tool"
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" ||
die "error found after kmod unload is real error, failing"
setup_kernel_check_point
dlogi "run kmod/sof_insert.sh"
"$TOPDIR"/tools/kmod/sof_insert.sh || die "insert modules error"
## - 2a: check for errors after insertion
dlogi "checking for general errors after kmod insert with sof-kernel-log-check tool"
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT" ||
die "Found error(s) in kernel log after module insertion"
dlogi "checking if firmware is loaded successfully"
if poll_wait_for 1 "$MAX_WAIT_FW_LOADING" sof_firmware_boot_complete --since=@"$KERNEL_CHECKPOINT"; then
grep_firmware_info_in_logs --since=@"$KERNEL_CHECKPOINT"
else
die "Failed to load firmware after module insertion"
fi
# successful remove/insert module pass
dlogi "==== firmware boot complete: $idx of $loop_cnt ===="
# After the last module insertion, it still takes about 10s for 'aplay -l' to show device
# list. We need to wait before aplay can function. Here, wait dsp status to suspend to
# avoid influence on next test case.
i=0
while dsp_status=$(sof-dump-status.py --dsp_status 0); do
# ignore platforms that do not support runtime pm
if [[ "$dsp_status" == 'unsupported' ]] ||
[[ "$dsp_status" == 'suspended' ]]; then
break
fi
if [ "$((i++))" -ge 15 ]; then
die "After 15s DSP status is: $dsp_status"
fi
sleep 1
done
done