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

#!/bin/sh
#回显命令执行及其参数
set -x
#cd 到utils执行sys_info.sh 后,然后通过cd -到当前目录
cd ../../utils
. ./sys_info.sh
cd -

#Test user id

#判断用户是否root 用户
#linux-t916:~ # whoami
#root

if [ `whoami` != 'root' ]; then
    echo "You must be the superuser to run this script" >$2
    exit 1
fi
#判断是否centos
#distro=`cat /etc/redhat-release | cut -b 1-6`
case $distro in
    "centos")
		#安装下面三个包
        yum install gcc -y
        yum install gcc-c++ -y
        yum install wget -y
		#检查安装上面三个包是否成功
        print_info $? install-package
		#下载tar包
        wget http://192.168.1.107/boost_1_63_0.tar.gz
		#解压tar包
        tar -zxvf boost_1_63_0.tar.gz
		#进入目录,分先后执行两个脚本文件,并通过print_info 打印编译boost的结果
        cd boost_1_63_0
        sudo ./bootstrap.sh
        ./b2 install
        print_info $? install-boost
        ;;
esac
#新建一个文件,并通过chmod 修改这个文件的权限,最后通过cat 让这个文件中输入内容
touch test_boost.cpp
chmod 777 test_boost.cpp
cat <<EOF >> test_boost.cpp
#include <boost/version.hpp>
#include <boost/config.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
    using boost::lexical_cast;
    int a=lexical_cast<int>("123456");
    double b=lexical_cast<double>("123.456");
    std::cout << a << std::endl;
    std::cout << b << std::endl;
    return 0;
}
EOF
#通过gcc 编译这个c++ 文件
g++ -Wall -o test_boost test_boost.cpp
#执行这个c++ 编译后生产的目标文件
./test_boost >> boost.log
#通过查找输出的log来决定c++ 是否执行成功
str=`grep -Po "123456" boost.log`
TCID="boost1.63.0 -test"
#查找到目标字符串后,认为boost 库执行成功
if [ "$str" != "" ]; then
    lava-test-case $TCID --result pass
else
    lava-test-case $TCID --result fail
fi
#删除包
yum remove gcc gcc-c++ -y
print_info $? remove-gcc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值