Chinaunix首页 | 论坛 | 博客
  • 博客访问: 534240
  • 博文数量: 103
  • 博客积分: 2024
  • 博客等级: 上尉
  • 技术积分: 1294
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-08 21:17
文章分类

全部博文(103)

文章存档

2012年(2)

2011年(21)

2010年(80)

分类:

2010-05-31 18:29:56

export RESULT="PASS"

echo -e "-----start testing-----" | tee -a ${OUTPUTFILE}

num=`/usr/bin/getconf _NPROCESSORS_ONLN`
echo -e "cpu num " $num |tee -a ${OUTPUTFILE}

for i in `seq 1 $num` ;do
    echo $i | tee -a ${OUTPUTFILE}
    ./busy 2>&1 |tee -a ${OUTPUTFILE} &
done

echo -e "powertop record" | tee -a ${OUTPUTFILE}
powertop -d -t 60  |tee busy.output |tee -a ${OUTPUTFILE}
echo -e "powertop record finished" | tee -a ${OUTPUTFILE}

# analys
if grep -q "C0 (cpu running)" busy.output ;then
    str=`grep "C0 (cpu running)" busy.output | awk '{print $4}'`
    str=${str%%.*}    
    num=${str##(}
    echo -e "get the num: " $num | tee -a ${OUTPUTFILE}
    if [ $num -lt 95 ];then
        echo -e "the value of C0 is low:" $val | tee -a ${OUTPUTFILE}
        RESULT="FAIL"
    fi
else
    echo -e "can't show C state" |tee -a ${OUTPUTFILE}
    result="FAIL"
fi

if grep -q "P-states (frequencies)" busy.output ;then
    val=`sed -n -e '/P-states/{n;p}' busy.output | awk '{print $3}'`
    val=${val%.*}
    
    echo -e "the value of p-high-state is" $val | tee -a ${OUTPUTFILE}
    if [ $val -lt 95 ];then
        echo -e "the value of p-high-state is low:" $val | tee -a ${OUTPUTFILE}
        RESULT="FAIL"
    fi
else
    echo -e "No P-states " | tee -a ${OUTPUTFILE}
    RESULT="FAIL"
fi

if grep -q "Wakeups-from-idle per second" busy.output ;then
    value=`grep "Wakeups-from-idle per second" busy.output | awk '{print $5}'`
    value=${value%.*}
    echo -e "Wakeup-from-idle per second:" $value | tee -a ${OUTPUTFILE}
    if [ $value -ne 0 ] ;then
        echo -e "the value not equal to 0" | tee -a ${OUTPUTFILE}
        RESULT="FAIL"
    fi
else
    echo -e "No Wakeups-from-idle" | tee -a ${OUTPUTFILE}
    RESULT="FAIL"
fi

echo -e "finish testing" | tee -a ${OUTPUTFILE}

rm -f busy.output
killall busy

if [ "${result}" = "PASS" ]
then
    report_result ${TEST} ${RESULT}
else
    report_result ${TEST} ${RESULT} 1
fi

 
阅读(1010) | 评论(0) | 转发(0) |
0

上一篇:amazing sed

下一篇:shell code 的编写

给主人留下些什么吧!~~