Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions test-case/stress-reboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

##
## Case Name: stress test reboot
## Preconditions:
## N/A
## Description:
## run reboot for the stress test
## default duration is 10s
## default loop count is 3
## Case step:
## 1. check system status is correct
## 2. wait for the Random value
## 3. trigger for the reboot
## Expect result:
## Test execute without report error in the LOG
##

source $(dirname ${BASH_SOURCE[0]})/../case-lib/lib.sh

OPT_OPT_lst['l']='loop' OPT_DESC_lst['l']='loop count'
OPT_PARM_lst['l']=1 OPT_VALUE_lst['l']=5

func_opt_parse_option $*

func_lib_check_sudo
func_lib_trigger_stress

loop_count=${OPT_VALUE_lst['l']}

[[ $loop_count -le 0 ]] && exit 0
# write the orig & status count to the status file
echo $loop_count >> $STRESS_STATUS_LOG
count=$(head -n 1 $STRESS_STATUS_LOG|awk '{print $1;}')
# because write record by desc
current=$[ $count - $loop_count + 1 ]

dlogi "Round: $current/$count"|tee -a $STRESS_OUTPUT_LOG

# verify-pcm-list.sh & verify-tplg-binary.sh need TPLG file
export TPLG=$(sof-get-default-tplg.sh)

declare -a verify_lst
verify_lst=(${verify_lst[*]} "verify-firmware-presence.sh")
verify_lst=(${verify_lst[*]} "verify-kernel-module-load-probe.sh")
verify_lst=(${verify_lst[*]} "verify-pcm-list.sh")
verify_lst=(${verify_lst[*]} "verify-sof-firmware-load.sh")
verify_lst=(${verify_lst[*]} "verify-tplg-binary.sh")

# here will write double line into $STRESS_OUTPUT_LOG
# because for the 1st round those information write by nohup command redirect
# but after system reboot the nohup redirect is missing
dlogi "Check status begin"|tee -a $STRESS_OUTPUT_LOG
for i in ${verify_lst[*]}
do
$(dirname ${BASH_SOURCE[0]})/$i
if [ $? -ne 0 ];then
# last line add failed keyword
sed -i '$s/$/ fail/' $STRESS_STATUS_LOG
dlogi "$i: fail" |tee -a $STRESS_OUTPUT_LOG

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you hijack the dlog* cmd to wrap the |tee -a $STRESS_OUTPUT_LOG when STRESS_OUTPUT_LOG is defined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the good idea, I will try it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check with #5 , I don't think here need to modify
because when run from remote, the nohup command will handle all output
from the local it don't need to handle it

here use tee command because after system reboot,
the nohup command is miss, Because current script is run in rc.local which called by root permission

exit 1
else
# last line add pass keyword
dlogi "$i: pass" |tee -a $STRESS_OUTPUT_LOG
fi
done
dlogi "Status check finished"
sed -i '$s/$/ pass/' $STRESS_STATUS_LOG

# run the script for the next round
loop_count=$[ $loop_count - 1 ]

# Store the environment for the next round load this script
dlogi "Setup the environment for next round bootup" |tee -a $STRESS_OUTPUT_LOG

declare -A exp_lst
exp_lst['TPLG']=$TPLG
exp_lst['LOG_ROOT']=$LOG_ROOT
# just keep the last dmesg bootup kernel line for the success
exp_lst['DMESG_LOG_START_LINE']=$(wc -l /var/log/kern.log|awk '{print $1;}')

for key in ${!exp_lst[@]}
do
sudo sof-boot-once.sh export $key=${exp_lst[$key]}
done

# run this script for next boot up round
dlogi "sof-boot-onece.sh ${BASH_SOURCE[0]} -l $loop_count" |tee -a $STRESS_OUTPUT_LOG

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dlogi "sof-boot-onece.sh ${BASH_SOURCE[0]} -l $loop_count" |tee -a $STRESS_OUTPUT_LOG
dlogc "sof-boot-onece.sh ${BASH_SOURCE[0]} -l $loop_count" |tee -a $STRESS_OUTPUT_LOG

sudo sof-boot-once.sh ${BASH_SOURCE[0]} -l $loop_count

# template delay before reboot
sleep 1s

sudo reboot