Skip to content

Commit 606d849

Browse files
Bin-QAxiulipan
authored andcommitted
Test Case: Add check suspend resume test
Add new Test Case for the suspend resume Signed-off-by: Wu, BinX <binx.wu@intel.com>
1 parent dba6bb5 commit 606d849

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

test-case/check-suspend-resume.sh

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 suspend/resume status
5+
## Preconditions:
6+
## N/A
7+
## Description:
8+
## Run the suspend/resume command to check device status
9+
## Case step:
10+
## 1. switch suspend/resume operation
11+
## 2. use rtcwake -m mem command to do suspend/resume
12+
## 3. check command return value
13+
## 4. check dmesg errors
14+
## 5. check wakeup increase
15+
## Expect result:
16+
## suspend/resume recover
17+
## check kernel log and find no errors
18+
##
19+
20+
source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh
21+
22+
random_min=3 # wait time should >= 3 for other device wakeup from sleep
23+
random_max=20
24+
25+
OPT_OPT_lst['l']='loop' OPT_DESC_lst['l']='loop count'
26+
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=5
27+
28+
OPT_OPT_lst['t']='type' OPT_DESC_lst['t']="suspend/resume type from /sys/power/mem_sleep"
29+
OPT_PARM_lst['t']=1 OPT_VALUE_lst['t']=""
30+
31+
OPT_OPT_lst['s']='sleep' OPT_DESC_lst['s']='suspend/resume command:rtcwake sleep duration'
32+
OPT_PARM_lst['s']=1 OPT_VALUE_lst['s']=5
33+
34+
OPT_OPT_lst['w']='wait' OPT_DESC_lst['w']='idle time after suspend/resume wakeup'
35+
OPT_PARM_lst['w']=1 OPT_VALUE_lst['w']=5
36+
37+
OPT_OPT_lst['r']='random' OPT_DESC_lst['r']="Randomly setup wait/sleep time, range is [$random_min-$random_max], this option will overwrite s & w option"
38+
OPT_PARM_lst['r']=0 OPT_VALUE_lst['r']=0
39+
40+
func_opt_parse_option $*
41+
func_lib_check_sudo
42+
func_lib_setup_kernel_last_line
43+
44+
type=${OPT_VALUE_lst['t']}
45+
# switch type
46+
if [ "$type" ]; then
47+
# check for type value effect
48+
[[ ! "$(cat /sys/power/mem_sleep|grep $type)" ]] && dloge "useless type option" && exit 2
49+
dlogc "sudo bash -c 'echo $type > /sys/power/mem_sleep'"
50+
sudo bash -c "'echo $type > /sys/power/mem_sleep'"
51+
fi
52+
dlogi "Current suspend/resume type mode: $(cat /sys/power/mem_sleep)"
53+
54+
loop_count=${OPT_VALUE_lst['l']}
55+
declare -a sleep_lst wait_lst
56+
57+
if [ ${OPT_VALUE_lst['r']} -eq 1 ]; then
58+
# create random number list
59+
for i in $(seq 1 $loop_count)
60+
do
61+
sleep_lst[$i]=$(func_lib_get_random $random_max $random_min)
62+
wait_lst[$i]=$(func_lib_get_random $random_max $random_min)
63+
done
64+
else
65+
for i in $(seq 1 $loop_count)
66+
do
67+
sleep_lst[$i]=${OPT_VALUE_lst['s']}
68+
wait_lst[$i]=${OPT_VALUE_lst['w']}
69+
done
70+
fi
71+
72+
for i in $(seq 1 $loop_count)
73+
do
74+
dlogi "Round($i/$loop_count)"
75+
# cleanup dmesg befor run case
76+
sudo dmesg --clear
77+
sleep_count=$(cat /sys/power/wakeup_count)
78+
dlogc "Run the command: rtcwake -m mem -s ${sleep_lst[$i]}"
79+
sudo rtcwake -m mem -s ${sleep_lst[$i]}
80+
[[ $? -ne 0 ]] && dloge "rtcwake return value error" && exit 1
81+
dlogc "sleep for ${wait_lst[$i]}"
82+
sleep ${wait_lst[$i]}
83+
dlogi "Check for the kernel log status"
84+
wake_count=$(cat /sys/power/wakeup_count)
85+
# sof-kernel-log-check script parameter number is 0/Non-Number will force check from dmesg
86+
sof-kernel-log-check.sh 0
87+
[[ $? -ne 0 ]] && dloge "Catch dmesg error" && exit 1
88+
# check wakeup count correct
89+
[[ $wake_count -le $sleep_count ]] && dloge "suspend/resume didn't happen, because /sys/power/wakeup_count does not increase" && exit 1
90+
done
91+
92+
# check full log
93+
sof-kernel-log-check.sh $KERNEL_LAST_LINE
94+
exit $?

0 commit comments

Comments
 (0)