Centos下配置单元测试工具gtest
2023-09-14 08:59:08 时间
gtest是google提供的一个非常强大的单元测试工具,下载地址:https://code.google.com/p/googletest
我下载的是gtest-1.6.0.拷贝到Centos系统上面。参考:http://blog.csdn.net/butterflydog/article/details/7005045
配置过程如下:
1、解压gtest-1.6.0
2、查看文件内容,找到make文件,进行make,生成一个测试程序,包含gtest_main.a文件
3、测试程序运行如下:
4、新建一个文件夹,gtest_program,将gtest-1.6.0中的include文件拷过来。
5、在gtest_program中新建一个lib文件夹,将gtest-1.60中的make文件夹中新生成的gtest_main.a文件拷贝过来。
6、编写Makefile,一定要记得修改GTEST_DIR为自己的路径名。如下:
1 # Points to the root of Google Test, relative to where this file is. 2 # Remember to tweak this if you move this file. 3 GTEST_DIR = /home/anker/gtest_program 4 5 # Where to find user code. 6 USER_DIR = ./ 7 8 # Flags passed to the preprocessor. 9 CPPFLAGS += -I$(GTEST_DIR)/include 10 11 # Flags passed to the C++ compiler. 12 CXXFLAGS += -g -Wall -Wextra 13 14 # All Google Test headers. Usually you shouldn't change this 15 # definition. 16 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \ 17 $(GTEST_DIR)/include/gtest/internal/*.h 18 19 20 21 FINALOBJS = $(patsubst ./%.cpp, ./%.o, $(wildcard ./*.cpp)) 22 FINALOBJS += $(patsubst ./%.cc, ./%.o, $(wildcard ./*.cc)) 23 24 MODULE=Sample 25 26 TEST=${MODULE}UnitTest 27 #if there are any modules that you mocked, add their obj name to MOCKOBJS, so 28 #they can be rebuilt 29 #MOCKOBJS += $(TEST) $(BASEDIR) 30 # House-keeping build targets. 31 32 all : $(TEST) 33 34 $(TEST): MOCK $(FINALOBJS) 35 $(CXX) $(CXXFLAGS) -lpthread $(FINALOBJS) -o $@ $(GTEST_DIR)/lib/gtest_main.a 36 37 %.o:%.cpp 38 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -g -c -o $@ {1}lt; 39 MOCK: 40 rm -rf $(MOCKOBJS) 41 clean: 42 rm -f $(FINALOBJS) $(TEST) 43
7、测试结果如下:
参考:http://www.cnblogs.com/chutianyao/archive/2012/12/01.html
相关文章
- CentOS 7重置账户密码
- CentOS 7 安装 MySQL「建议收藏」
- Centos 7安装nginx并配置https[通俗易懂]
- centos7配置本地yum源_centos 本地yum源配置
- centos dhcp服务器配置_dhcp server什么意思
- 如何在 CentOS 7上安装和使用 FFmpeg
- centos升级gcc至4.8
- Centos vsftpd 配置web目录
- centos救援模式
- CentOS系统下Redis安装和自启动配置的步骤
- Linux CentOS 6.5 卸载、tar安装MySQL的教程
- CentOS 服务器安全配置策略
- CentOS 6.3下安装部署Oracle服务器图文教程
- 使用commit方式构建具有sshd服务的centos镜像详解架构师
- 结果简单易用:Linux Centos系统效果尝鲜(linuxcenos)
- 卸载CentOS上的MySQL服务(centos卸载mysql)
- CentOS 6.6 发布
- CentOS 6.5编译安装Nginx1.10.2+MySQL5.5.52+PHP5.5.38
- centos下fail2ban安装与配置详解
- CentOS下DB2数据库安装过程详解