青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

Codejie's C++ Space

Using C++

Why the inline function can not be covered?


Please have a look the following codes, they include two source files (source.h, source.c), one test file (test_source.c) and one makefile file.

//source.h
 1 #ifndef __SOURCE_H__
 2 #define __SOURCE_H__
 3 
 4 #include <stdio.h>
 5 
 6 inline void inline_test()
 7 {
 8     printf("\nthis is the inline function.");
 9 }
10 
11 void normal_test();
12 
13 #endif

//source.c
1 #include "source.h"
2 
3 void normal_test()
4 {
5     printf("\nThis is a normal function.");
6 }

//test_source.c
 1 #include "source.h"
 2 
 3 void test_inline() 
 4 {
 5     inline_test();
 6 }
 7 
 8 void test_normal()
 9 {
10     normal_test();
11 }
12 
13 int main()
14 {
15     test_inline();
16     test_normal();
17     
18     return 0;
19 }


//makefile
 1 TEST = test_source.o
 2 
 3 TARGET = a.exe
 4 
 5 all: $(TARGET)
 6 
 7 $(TARGET):$(SOURCE) $(TEST)
 8     gcc -Xlinker --allow-multiple-definition $^ -fprofile-arcs -ftest-coverage -o $(TARGET)    
 9 
10 $(SOURCE): %.o:%.c
11     gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
12     gcc -c $< -o $@ -fprofile-arcs -ftest-coverage
13     
14 $(TEST): %.o:%.c
15     gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
16     gcc -c $< -o $@   
17  
18 clean:
19     -rm -rf $(DIR_COVERAGE)
22     -rm -rf *.d *.o *.gcda *.gcno $(TARGET)

...

My purpose is that get the UT line coverage report of source files by running the test file. I guess I should get the below report of line coverage, because I have called every functions of source file in test file, include the inline function and the normal function.

But after run test file, I got the report is just 50%, the inline function has not been covered. Why? Why it is not be covered? I am sure it is called in test file.
OK, Calming down. If it is not covered, there are two reason, one is that the inline function is not be called, of course it is impossible, because we did it. So the root cause must be the second one that gcov/lcov tools do not process those lines of inline function. Have any idea? gcov/lcov tools process all files with compilation parameters '-fprofile-arcs -ftest-coverage', so let's check makefile file again.
Look here, source files have the compilation paraments, but why normal function has been coverage, but inline function not?

$(SOURCE): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@ -fprofile-arcs -ftest-coverage

Thinking again, as we knew, the difference between inline function and normal function is just that inline function will be inserted source code while compiling period. Yes, the answer is here! While compiling, the inline function is put into test file, but the test file has not '-fprofile-arcs -ftest-coverage' paramenter. So, so it was not covered.

$(TEST): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@

To fix it, just add the parameter to test file while compiling. OK, let's update the makefile file like the below line.

$(TEST): %.o:%.c
    gcc -MM -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $<
    gcc -c $< -o $@ -fprofile-arcs -ftest-coverage    

Done, enjoy it!

posted on 2012-09-21 17:45 codejie 閱讀(2887) 評論(2)  編輯 收藏 引用 所屬分類: C++隨筆而已

評論

# re: Why the inline function can not be coveraged? 2012-09-26 19:35 smagle

gcov原理分析詳細可參考:http://sdet.org/?p=212  回復  更多評論   

# re: Why the inline function can not be coveraged?[未登錄] 2012-09-26 22:16 codejie

@smagle
very great article. thanks!  回復  更多評論   

公告

Using C++

導航

統(tǒng)計

留言簿(73)

隨筆分類(513)

積分與排名

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美另类在线观看| 国产精品久久久91| 亚洲午夜视频在线| 亚洲精品久久久久中文字幕欢迎你 | 亚洲国产91| 亚洲精品视频一区二区三区| 亚洲第一中文字幕| 欧美激情综合| 在线视频日韩| 久久久久91| 欧美精品一区二区在线观看| 欧美视频网站| 国产一区二区三区精品欧美日韩一区二区三区 | 在线一区亚洲| 久久国产66| 欧美人在线观看| 国产精品捆绑调教| 亚洲国产精品传媒在线观看| 一本色道久久综合亚洲精品高清 | 一区二区三区亚洲| 一本色道久久综合一区 | 91久久精品一区二区别| 99精品99久久久久久宅男| 性色av一区二区三区| 欧美成人精品h版在线观看| 日韩视频在线一区二区| 久久久成人精品| 亚洲精品久久久久久久久| 亚洲小说春色综合另类电影| 久久蜜桃香蕉精品一区二区三区| 欧美另类一区| 亚洲国产经典视频| 欧美一区激情视频在线观看| 欧美大片国产精品| 午夜精品久久久久久久白皮肤 | 一本色道久久综合亚洲精品不卡| 先锋资源久久| 亚洲电影第三页| 午夜欧美理论片| 欧美日韩三级视频| 亚洲激情午夜| 美女91精品| 久久精品五月| 国产精品久久久一区二区| 亚洲人成绝费网站色www| 久久久在线视频| 亚洲欧美偷拍卡通变态| 蜜臀99久久精品久久久久久软件| 亚洲美女电影在线| 欧美91大片| 亚洲精品日本| 亚洲国产成人在线播放| 久久综合影音| 亚洲成色777777女色窝| 久久先锋影音| 久久久久综合一区二区三区| 国产亚洲观看| 久久久久国色av免费看影院 | 国产欧美日韩在线播放| 亚洲午夜精品久久久久久浪潮| 亚洲国产老妈| 蜜臀久久99精品久久久久久9| 怡红院精品视频| 欧美大片在线看免费观看| 毛片av中文字幕一区二区| 在线日韩中文| 亚洲高清中文字幕| 欧美精品久久久久久久免费观看 | 亚洲一区二区高清| 在线亚洲欧美| 国产精品青草久久| 欧美一区二区三区另类 | 亚洲在线不卡| 黄色成人在线免费| 欧美sm视频| 欧美日本在线视频| 亚洲欧美日韩国产| 欧美一区二区视频在线| 激情六月婷婷久久| 欧美激情视频给我| 欧美r片在线| 免费人成精品欧美精品| 亚洲理伦在线| 亚洲视频999| 一区二区三区亚洲| 亚洲国产精品v| 欧美视频精品在线| 久久最新视频| 欧美日韩国产成人在线免费| 亚洲欧美经典视频| 久久亚洲午夜电影| 亚洲欧美国产三级| 老牛影视一区二区三区| 一区二区三区四区五区视频 | 午夜精品久久久久影视 | 99国产精品久久久久老师| 一区二区免费在线视频| 国产一区二区日韩精品欧美精品| 久久aⅴ国产欧美74aaa| 欧美激情亚洲| 久久综合激情| 欧美日韩精品一区二区在线播放| 欧美在线视屏| 欧美激情精品久久久| 久久婷婷av| 欧美性色综合| 欧美国产精品va在线观看| 国产精品久久一级| 欧美成人免费大片| 国产情人综合久久777777| 91久久夜色精品国产九色| 国产欧美一区二区精品婷婷| 亚洲欧洲日产国产网站| 国内精品视频666| 在线视频欧美日韩| 99国产麻豆精品| 麻豆9191精品国产| 久久久亚洲精品一区二区三区| 欧美日韩在线直播| 亚洲国产成人精品久久久国产成人一区| 欧美二区在线观看| 99精品免费视频| 国产麻豆精品久久一二三| 国产亚洲精品bt天堂精选| 一区二区三区日韩欧美精品| 性欧美激情精品| 欧美成人精品在线| 亚洲一区二区三区四区五区午夜 | 日韩视频一区二区在线观看 | 欧美私人啪啪vps| 免费在线视频一区| 国产精品自在线| 在线中文字幕一区| 亚洲视频在线看| 欧美午夜宅男影院在线观看| 国产精品观看| 亚洲高清久久| 亚洲高清资源| 美日韩精品免费| 亚洲国产综合91精品麻豆| 欧美黄色aaaa| 亚洲福利国产| 亚洲欧洲视频在线| 欧美黄色aaaa| 一区二区三区你懂的| 亚洲香蕉网站| 国产精品影院在线观看| 亚洲欧美综合国产精品一区| 欧美一区二区免费观在线| 国产一区二区av| 久久久久国产精品一区| 欧美韩日一区二区三区| 亚洲精品视频免费观看| 欧美另类变人与禽xxxxx| 亚洲日本va在线观看| 亚洲线精品一区二区三区八戒| 国产精品乱人伦一区二区 | 激情丁香综合| 快播亚洲色图| 欧美亚洲网站| 韩国av一区二区三区在线观看| 亚洲欧美综合v| 久久九九热re6这里有精品| 亚洲成在人线av| 欧美另类高清视频在线| 亚洲在线观看免费| 久久久久久久久蜜桃| 亚洲成色777777女色窝| 欧美另类在线观看| 午夜久久电影网| 欧美激情在线观看| 先锋影音国产一区| 亚洲黄一区二区三区| 欧美日韩岛国| 欧美淫片网站| 亚洲黄色精品| 欧美中文字幕在线播放| 亚洲成色999久久网站| 国产精品高精视频免费| 久久精品一级爱片| 一本久道久久久| 欧美激情a∨在线视频播放| 亚洲欧美国产高清| 国产麻豆精品theporn| 亚洲欧美激情精品一区二区| 亚洲电影第1页| 性欧美精品高清| 亚洲人成毛片在线播放女女| 国产精品久久久久久妇女6080| 久久久久久9| 亚洲视频免费在线观看| 亚洲欧洲视频在线| 国产精品久久一级| 蜜臀久久99精品久久久画质超高清| 中文欧美在线视频| 亚洲国产日韩欧美在线动漫| 久久阴道视频| 久久国产夜色精品鲁鲁99| 一本久久综合亚洲鲁鲁五月天| 亚洲黄色一区|