#!/bin/sh # #This script is to test sata devices on target # result=0 devpath="" satainfo="" SD=`ls -l /dev/sd[^0-9] | awk '{print $5 $6 "," $10}'` if [ -z "$SD" ]; then echo "FAIL: find sata device" exit 1 else echo "PASS: find sata device" fi HDPARM=`which hdparm` if [ -z $HDPARM ]; then result=$? echo "FAIL: find hdparm" fi echo "PASS: find hdparm" for s in $SD do devpath=`echo "$s" | awk -F "," '{print "/sys/dev/block/" $1 ":" $2}'` satainfo=`ls -l $devpath | grep sata` if [ -z "$satainfo" ] ; then continue fi s=`echo "$s" | awk -F "," '{print $3}'` echo "testing $s" $HDPARM -I $s if [ $? -ne 0 ]; then result=$? echo "FAIL: $HDPARM -I $s Detailed/current information directly from $s" else echo "PASS: $HDPARM -I $s Detailed/current information directly from $s" fi $HDPARM -tT $s if [ $? -ne 0 ]; then result=$? echo "FAIL: $HDPARM -tT $s Perform device/cache read timings on $s" else echo "PASS: $HDPARM -tT $s Perform device/cache read timings on $s" fi mkdir -p /mnt/sata_tmp for partition in `ls "$s"[1-9]` do mount "$partition" /mnt/sata_tmp if [ $? -ne 0 ]; then result=$? echo "FAIL: Mount $s" else echo "PASS: Mount $s" dd if=/dev/urandom of=/mnt/sata_tmp/writefile bs=1M count=50 if [ $? -ne 0 ]; then result=$? echo "FAIL: write test on $s" else echo "PASS: write test on $s" rm -f /mnt/sata_tmp/writefile fi dd if=$s of=/mnt/sata_tmp/readfile bs=1M count=10 if [ $? -ne 0 ]; then result=$? echo "FAIL: read test on $s" else echo "PASS: read test on $s" rm -f /mnt/sata_tmp/readfile fi umount /mnt/sata_tmp fi done rm -fr /mnt/sata_tmp done exit $result