脚本基本实现逻辑为:重启开关机去判断是否识别到TP模组的VID PID和检测eGTouchD的服务是否跑起来,
如果有识别到设备并且服务有跑起来,则打印一次字符串detecte_success到创建的文件sdcard/det_usb_eGTouchD.log中,最后统计当前测试的重启次数,然后执行重启操作;
如果识别不到或者服务没起来,则打印字符串detecte_fail到创建的文件sdcard/det_usb_eGTouchD.log中,并且打印当前设备的dmesg和logcat到当前时间下创建的sdcard/XXXX.log文件中,
最后统计当前测试的重启次数,然后执行重启操作。
后续可以通过查看sdcard/det_usb_eGTouchD.log知道脚本执行的测试结果。
具体操作说明:
脚本文件:usbtp_det.sh
然后执行以下:
1、把usbtp_det.sh文件push 进入system/bin/目录:
C:\Users\Administrator>adb root
C:\Users\Administrator>adb remount
C:\Users\Administrator>adb push usbtp_det.sh system/bin/
C:\Users\Administrator>adb shell chmod 755 system/bin/usbtp_det.sh
C:\Users\Administrator>adb shell sync
2、在system/bin/lowmem_manage.sh 加入以下指令,注意加在文件最后一行,要在机器起来之后再去执行脚本:
source usbtp_det.sh
然后重启机器即可进入自动开关机测试TP的概率性失效问题。
如果需要停止测试,需要在重启之前拔掉TP设备,并且在开机起来后2分钟内查看在sdcard目录对应的测试记录文件
det_usb_eGTouchD.log或者把它pull出来查看,或者注释掉lowmem_manage.sh中的source usbtp_det.sh来停止测试。
【包括测试次数记录文件:det_usb_eGTouchD.log和dmesg、logcat的log文件等】
注意:检测设备或者服务失败才会去抓取对应log的打印,检测成功则无log打印文件生成。
#!/bin/bash
D_NAME=sdcard/det_usb_eGTouchD.log
DETECTE_SUCCESS=detecte_success
DETECTE_FAIL=detecte_fail
DATE=`date +%Y-%m-%d_%H_%M_%S`
DMESG_LOG=dmesg
LOGCAT_LOG=logcat
INPUT_LOG=cat_input
#create file to write
if [ ! -f "$D_NAME" ]; then
echo "log file will creat."
touch ${D_NAME}
else
echo "log file already exists."
fi
#retry 5
count=0
while [[ $count -lt 5 ]]
do
let count++
#service detection
if [ "$(lsusb |grep 0eef:c000)" ] && [ "$(ps | grep eGTouchD |wc -l)" -eq "1" ]; then
echo "Current TP driver and service eGTouchD startup success."
setprop persist.sys.tp.logprint 0
sleep 1
break
else
echo "Current TP driver and service eGTouchD startup failed."
setprop persist.sys.tp.logprint 1
sleep 1
fi
done
#print log
gtdetecte_tp=`getprop persist.sys.tp.logprint`
if [ "$gtdetecte_tp" != "0" ] ; then
sleep 110
echo "${DETECTE_FAIL}"
echo $DETECTE_FAIL >> ${D_NAME}
dmesg >> sdcard/${DMESG_LOG}_${DATE}.log &
logcat -v time >> sdcard/${LOGCAT_LOG}_${DATE}.log &
cat proc/bus/input/devices >> sdcard/${INPUT_LOG}_${DATE}.log &
else
sleep 5
echo "${DETECTE_SUCCESS}"
echo $DETECTE_SUCCESS >> ${D_NAME}
fi
#count
OPS_NUMBER=$(grep -nr "detecte" ${D_NAME} | wc -l)
#OPS_NUMBER=$(cat ${D_NAME} | grep "detecte" | wc -l)
echo "********************" >> ${D_NAME}
echo "Count current restarts..."
echo "Current test times" >> ${D_NAME}
echo $OPS_NUMBER >> ${D_NAME}
echo "********************" >> ${D_NAME}
#setting reboot ops
setprop persist.sys.tp.reboot 1
gtdetecte_reboot=`getprop persist.sys.tp.reboot`
if [ "$gtdetecte_reboot" != "0" ] ; then
echo "5s after will reboot."
sleep 5
reboot
else
echo "No reboot."
sleep 5
fi