linux c 提高代码质量的几个测试工具
2016-02-29 20:37
232 查看
很多it公司对于软件开发都有严格的分工,这包括设计、测试、服务支持等等。但是,我一直都认为只有开发者才是真正对软件质量负责的人。没有好的软件设计,软件质量基本上是无从谈起。当然,要做到这一点是需要额外的一些工具来进行保证的。因为这一段时间都是在linux上开发的,所以下面涉及到的工具基本上都是基于linux平台的。假设测试的文件名为test.c。
(1)测试代码覆盖率
[cpp] view
plain copy
gcc -fprofile-arcs -ftest-coverage -o test test.c
./test
gcov test.c
(2)代码静态测试
[cpp] view
plain copy
sudo apt-get install splint
splint test.c
(3)内存泄漏测试
[cpp] view
plain copy
sudo apt-get install valgrind
./test
valgrind --tool=memcheck --leak-check=yes ./test
(4)性能测试
[cpp] view
plain copy
gcc test.c -pg -o test
./test
gprof test gmon.out -p
(5)单元测试CUnit-2-0-1
[cpp] view
plain copy
aclocal
autoconf
autoheader
chmod u+x configure
libtoolize
automake --add-missing
./configure
make
因为CUnit-2-0-1中有一个test_cunit代码,所以大家可以直接看看单元测试下是怎么运行和测试的。
上面的几个工具都是linux下测试的几个工具,大家可以根据自己的需要进行灵活的选择。当然,在实际开发中,我们需要把这些工具集成到makefile中,这样可以达到最好的测试效果。
(1)测试代码覆盖率
[cpp] view
plain copy
gcc -fprofile-arcs -ftest-coverage -o test test.c
./test
gcov test.c
(2)代码静态测试
[cpp] view
plain copy
sudo apt-get install splint
splint test.c
(3)内存泄漏测试
[cpp] view
plain copy
sudo apt-get install valgrind
./test
valgrind --tool=memcheck --leak-check=yes ./test
(4)性能测试
[cpp] view
plain copy
gcc test.c -pg -o test
./test
gprof test gmon.out -p
(5)单元测试CUnit-2-0-1
[cpp] view
plain copy
aclocal
autoconf
autoheader
chmod u+x configure
libtoolize
automake --add-missing
./configure
make
因为CUnit-2-0-1中有一个test_cunit代码,所以大家可以直接看看单元测试下是怎么运行和测试的。
上面的几个工具都是linux下测试的几个工具,大家可以根据自己的需要进行灵活的选择。当然,在实际开发中,我们需要把这些工具集成到makefile中,这样可以达到最好的测试效果。
相关文章推荐
- 1_简单的C程序反汇编及分析
- Linux下C++中的内存对齐
- Linux统计文件/目录数量ls -l | grep "^-" | wc -l匹配开头和结尾
- Linux统计文件/目录数量ls -l | grep "^-" | wc -l匹配开头和结尾
- 安装win7和centos6.7双系统 引导加载安装位置问题
- 安装win7和centos6.7双系统 记录
- linux 内核睡眠与唤醒
- Linux 系统性能监控命令详解
- CentOS6.5下解压文件.tar.gz .war .zip
- Linux 交换分区
- Linux系统下修改Eclipse中SVN用户
- Linux Top 命令解析 比较详细
- linux 嵌入式操作系统内核原理和开发总结
- Linux精讲——vim编辑器
- centos 6.5安装 jdk
- linux编程笔记(1)-内存管理介绍
- Red Hat Enterprise Linux Server(RHEL) yum安装软件时This system is not registered with RHN. RHN support will be disabled. 的解决方法(转)
- linux c 多线程编程总结
- linux c 算法总结
- linux c 编程模板总结(二)