下载此文档

代码覆盖率测试.doc


文档分类:资格/认证考试 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍
代码覆盖率测试
2007-8-21
larkguo@
摘要:同gprof一样gcov是 GNU 编译器工具包所提供的一种测试工具,用来检测代码的覆盖率,能标识出每个函数甚至代码行被执行了多少次。本文以C语言实例讲解linux下gcov用法,相关代码见《C语言多线程内存管理模块》。
编译
编译时使用-fprofile-arcs -ftest-coverage选项:
[******@asterisk1 mm]# make CFLAGS+=-fprofile-arcs CFLAGS+=-ftest-coverage LDFLAGS+=-fprofile-arcs LDFLAGS+=-ftest-coverage
cc -fprofile-arcs -ftest-coverage -c -o
cc -fprofile-arcs -ftest-coverage -c -o
gcc -o mm -fprofile-arcs -ftest-coverage
:
[******@asterisk1 mm]# ll
total 76
-rw-r--r-- 1 root root 311 Aug 16 18:00
-rw-r--r-- 1 root root 580 Aug 21 19:24
-rw-r--r-- 1 root root 1884 Aug 21 19:24
-rw-r--r-- 1 root root 415 Aug 21 19:23 Makefile
-rwxr-xr-x 1 root root 20299 Aug 21 19:24 mm
-rw-r--r-- 1 root root 8829 May 18 10:14
-rw-r--r-- 1 root root 9692 Aug 21 19:24
-rw-r--r-- 1 root root 2132 Jun 19 14:43
-rw-r--r-- 1 root root 9888 Aug 21 19:24
执行
[******@asterisk1 mm]# ./mm
LEAK DETAIL:
6 bytes allocated in main at line 15 of
......
6 bytes allocated in main at line 15 of
6010 bytes allocated in 1001 allocations
LEAK SUMMARY:
6010 bytes in 1001 allocations in file ''
6010 bytes allocated in 1001 allocations
:
[******@asterisk1 mm]# ll
total 84
-rw-r--r-- 1 root root 311 Aug 16 18:00
-rw-r--r-- 1 ro

代码覆盖率测试 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人wxc6688
  • 文件大小48 KB
  • 时间2018-06-10
最近更新