#!/bin/bash MYDIR=$(dirname $(readlink -f "$0")) if [ $UID -ne 0 ]; then echo "请以root用户身份运行!" echo "提示: sudo -s 或 su root 可以切换到root用户" exit 1 fi ARCH=$(arch) usage() { echo "输入错误!" echo "支持:睡眠(suspend)/休眠(hibernate)/重启(warnboot)/冷重启(coldboot)测试。" echo "用法:./RunTest [suspend/hibernate/warnboot/coldboot] [次数]" echo "例如: 循环300次重启测试: ./RunTest.sh warnboot 300" exit 1 } if [ $# -lt 2 ]; then usage fi info(){ # 获取key所在的行 info_line=`sed -n "/^$1=/p" $2` if [[ -z $info_line ]];then echo "" fi # 返回key对应的value值 echo $info_line|awk -F '=' '{print $2}' } install_ec_tools() { if [ ! -f "/proc/ec_control/resume_timer" ];then cd EcTools insmod ./ec_operation.ko >> /dev/null 2>&1 if [ ! -f "/proc/ec_control/resume_timer" ];then echo "install ec tools ..." make >> $login_user_home/debug.log 2>&1 insmod ./ec_operation.ko >> $login_user_home/debug.log if [ $? -ne 0 ];then echo "ERROR: install ec tools fail" read exit 1 fi else echo "ec tools ready" fi cd $MYDIR fi } set_autorun_uos() { #设置关闭自动更新 echo 设置关闭自动更新 dbus-send --system --dest=com.deepin.lastore --type=method_call /com/deepin/lastore com.deepin.lastore.Updater.SetAutoCheckUpdates boolean:false > /dev/null 2>&1 #设置关闭更新提醒 dbus-send --system --dest=com.deepin.lastore --type=method_call /com/deepin/lastore com.deepin.lastore.Updater.SetUpdateNotify boolean:false > /dev/null 2>&1 # set autologin sed -i 's/^#\(autologin-user=\)$/\1'${login_user_name}'/' /etc/lightdm/lightdm.conf || echo "设置自动登陆失败,请手动设置自动登陆,已经设置请忽略" echo "更改系统设置。。。" su $login_user_name < $login_user_home/.config/autostart/reboot.desktop <' /etc/login.defs | awk '{print $2}') login_user_name=$(cat /etc/passwd | awk -v id="$login_user_id" -F: '{if ($3==id) print $1}') login_user_home=$(cat /etc/passwd | awk -v id="$login_user_id" -F: '{if ($3==id) print $6}') case "$ARCH" in mips64) # ifconfig enp1s0 down > /dev/null 2>&1 # # 关闭WiFi # rfkill block 0 > /dev/null 2>&1 ;; loongarch64) # ifconfig enp1s0 down > /dev/null 2>&1 # # 关闭WiFi # rfkill block 0 > /dev/null 2>&1 ;; aarch64) echo "" # ifconfig enp3s0 down > /dev/null 2>&1 # # 关闭WiFi # rfkill block 0 > /dev/null 2>&1 ;; x86_64) chmod +x ec$ARCH ;; *) echo "未支持 $ARCH 架构,测试未进行!" exit 1 ;; esac date >> $login_user_home/debug.log chmod +x boot_test_v16/*.sh #chmod +x rtc_resume rtc_resume_la # chmod +x mem chmod +x boot_test_v16/ec* if [ $2 -le 0 ]; then echo "输入有误! 循环次数必须大于0 请重新运行" usage fi LOG_FILE=$1`date +%Y%m%d`.log echo "日志文件: ${LOG_FILE}" TIMECTRL=`date '+%s'` sed -i "s#^TIMECTRL=.*#TIMECTRL=$TIMECTRL#" ./boot_test_v16/action.cfg sed -i "s#^LOG=.*#LOG=$LOG_FILE#" ./boot_test_v16/action.cfg sed -i "s#^ACTION=.*#ACTION=$1#" ./boot_test_v16/action.cfg #echo "timesLeft=$2" > ./times.left echo "测试即将开始。。。" case "$1" in ec) #./S3S4.sh echo -ne "read EC version:" master=`echo 111111 | sudo -S ${MYDIR}/ec$ARCH -r -a 0x00` slave=`echo 111111 | sudo -S ${MYDIR}/ec$ARCH -r -a 0x01` test1=`echo 111111 | sudo -S ${MYDIR}/ec$ARCH -r -a 0x02` test2=`echo 111111 | sudo -S ${MYDIR}/ec$ARCH -r -a 0x03` echo "$master:$slave:$test1:$test2" | awk -F':' '{print $1"."$2"."$3$4}' | sed 's/0x//g' #sed 's/0x0//g;s/0x//g' #exit 0 ;; register) $set_autorun chown $login_user_name:$login_user_name $MYDIR -R #./reboot.sh ;; status) chown $login_user_name:$login_user_name $MYDIR -R #./S3S4.sh ;; expression) $set_autorun #./reboot.sh ;; *) usage ;; esac