testing-script/usb20-script/usb20-script.sh
2025-04-15 14:12:57 +08:00

73 lines
1.7 KiB
Bash
Executable File

#/bin/bash
### This script is to check if Expand USB2.0 ports are working fine ###
RET=0
sleep 2
echo " "
echo " "
echo " "
echo "######################################################################################"
echo "########################## Expand USB2.0 Deivce Testing Start ##########################"
dmesg -c > /dev/null
while true
do
read -t20 -s -n1 -p "### Please Insert one USB2.0 Device U-DISK into Expand USB2.0 Port right now , then enter any key to continue. ###" keypress
if [ $? -eq 0 ]; then
echo " "
break
fi
echo " "
done
sleep 3
result=`dmesg | grep "new high-speed USB device" | wc -l`
if [ ${result} -eq 0 ]; then
RET=1
echo "Error Notice: USB2.0 Device U-DISK can not detect at first time from Expand USB2.0 Port."
else
result=`dmesg | grep "Attached SCSI removable disk" | wc -l`
if [ ${result} -eq 0 ]; then
RET=1
echo "Error Notice: USB2.0 Device U-DISK can not detect at second time from Expand USB2.0 Port."
else
echo "### USB2.0 Device U-DISK can detect successfully from Expand USB2.0 Port ###"
result=`fdisk -l /dev/sda | grep "bytes" | grep "sectors" | wc -l`
if [ ${result} -gt 0 ]; then
echo "### USB2.0 Device U-DISK partition info is good from Expand USB2.0 Port ###"
else
RET=1
echo "Error Notice: USB2.0 Device U-DISK partition info is bad from Expand USB2.0 Port"
fi
fi
fi
sleep 1
while true
do
read -t20 -s -n1 -p "### Please Remove one USB2.0 Device U-DISK from Expand USB2.0 Port right now , then enter any key to continue. ###" keypress
if [ $? -eq 0 ]; then
echo " "
break
fi
echo " "
done
dmesg -c > /dev/null
echo "######################################################################################"
echo " "
echo " "
echo " "
sleep 2
return ${RET}