/test-definitions/blob/master/auto-test/blktrace/blktrace.sh

#!/bin/sh -e
set -x
#cd 到utils 路径,然后执行这个路径下的两个脚本文件后,通过cd - 返回到当前目录
cd ../../utils
    . ./sys_info.sh
      ./sh-test-lib
cd -
#通过whoami 判断是否是root 用户,如果是root用户,则输出root
if [ `whoami` != 'root' ] ; then
    echo "You must be the superuser to run this script" >&2
    exit 1
fi

version="1.0.5"
from_repo="Estuary"
package="blktrace"
#打印需要安装的包的名字
for P in ${package};do
    echo "$P install"
# Install package
case $distro in
    "centos" )
	#目前看起来只支持centos,则通过yum安装这个包
         yum install -y "$P"
         print_info $? "$P"
         ;;
 esac
# Check the package version && source
#检查包的信息和repo信息是否正确
#首先得到repo信息
 from=$(yum info $P | grep "From repo" | awk '{print $4}')
 if [ "$from" = "$from_repo" ];then
     echo "$P source is $from : [pass]" | tee -a ${RESULT_FILE}
 else
     rmflag=1
     if [ "$from" != "Estuary" ];then
	 #如果repo信息不对,则删除这个包
         yum remove -y $P
         yum install -y $P
         from=$(yum info $P | grep "From repo" | awk '{print $4}')
        if [ "$from" = "$from_repo"  ];then
           echo "$P install  [pass]" | tee -a ${RESULT_FILE}
        else
           echo "$P source is $from : [failed]" | tee -a ${RESULT_FILE}
        fi
     fi
 fi
#得到这个包的版本信息
 vers=$(yum info $P | grep "Version" | awk '{print $3}')
 #判断这个包的版本信息是否相等,本质上就是判断字符串是否相等
 if [ "$vers" = "$version"  ];then
     echo "$P version is $vers : [pass]" | tee -a ${RESULT_FILE}
 else
     echo "$P version is $vers : [failed]" | tee -a ${RESULT_FILE}
 fi
done

#执行blktrace 命令,并输出结果
# Display the blktrace result on screen.
blktrace -d /dev/sda -w 5 -o - |blkparse -i -
print_info $? display

# Output the blktrace result on file.
blktrace -d /dev/sda -w 10 -o trace | blkparse -i -
print_info $? output
#测试完成后删除这个包.
# Remove the blktrace package
yum remove -y "$P"
print_info $? remove

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值