#!/bin/bash
##########################################
#Script: reboot.sh
#Author: liuxin
#Date: 2020-05-19
#Description:
# 1.adb devices检查是否有此设备,且设备状态为device;
# 2.检查IP地址是否获取成功;
# 3.笔端ping www.baidu.com -t 10
# 4.检查ping包结果,有一次成功即为pas
#Usage: -h 查看帮助
##########################################
function checkDeviceStatus()
{
echo "Testcase 1: 测试设备获取情况"
checkADB=$(adb devices|grep -v attached|awk '{print $NF}')
if [[ $checkADB == "device" ]]
then
echo "PASS:获取设备信息成功"
echo ""
elif [[ $checkADB == "offline" ]]
then
echo "ERROR:adb offline ,请重启adb"
exit
else
echo "ERROR:设备未启动成功"
exit
fi
}
function check_IP()
{
echo "Testcase 2: 测试ip获取情况"
wlan_check=$(adb shell ifconfig |grep wlan0)
if [[ ! -n "$wlan_check" ]]
then
echo "Fail:未找到wlan0"
ifconfig
exit
else
ip_id=$(adb shell ifconfig |grep Bcast|awk '{split($2,t,":");print t[2]}')
if [[ -n $ip_id ]]
then
echo "Pass:获取IP成功"
echo "ip:"$ip_id
echo ""
else
echo "Fail:获取IP结果无效"
ifconfig wlan0
exit
fi
fi
}
function check_Ping()
{
echo "Testcase 3: 测试外网连接情况"
adb shell 'ping -c 5 www.sogou.com' > dic/ping.txt
fail_id=$(grep failure dic/ping.txt)
if [[ -n "$fail_id" ]]
then
echo "Fail:外网连接失败"
echo $fail_id
exit
else
loss_id=$(grep transmitted dic/ping.txt|awk '{print $6}')
if [[ "$loss_id" == "0%" ]]
then
echo "PASS:ping成功,外网连通性正常"
grep transmitted dic/ping.txt
else
echo "Fail:有丢包"
mv dic/ping.txt "dic/ping_"$i".txt"
fi
#grep transmitted dic/ping.txt
fi
}
i=1
while(( $i<=100 ))
do
echo ">>--------------------------<<"
echo ""
echo "Loop "$i",wait for 40s"
adb reboot
sleep 40
echo "Test Start ..."
echo ""
checkDeviceStatus
sleep 2
check_IP
sleep 2
check_Ping
sleep 2
((i++))
echo ""
done
【shell】智能硬件设备重启压力测试脚本
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...