#!/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
test-definitions/blob/master/auto-test/boost/boost.sh
最新推荐文章于 2018-09-19 23:37:15 发布