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

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>
            亚洲一区二区在线播放| 日韩视频免费观看高清完整版| 在线性视频日韩欧美| 亚洲国产色一区| 久久综合色影院| 亚洲国内在线| 亚洲精品免费一区二区三区| 欧美人成免费网站| 亚洲午夜激情网页| 欧美一级大片在线免费观看| 国产一区观看| 欧美黄色aa电影| 欧美激情第8页| 亚洲欧美国内爽妇网| 亚洲伊人伊色伊影伊综合网| 国产又爽又黄的激情精品视频| 久久综合九色99| 免费一区二区三区| 亚洲精品裸体| 亚洲视频香蕉人妖| 亚洲一级片在线看| 国产亚洲一本大道中文在线| 麻豆精品在线播放| 欧美人与性动交cc0o| 午夜欧美电影在线观看| 久久久一区二区| 一道本一区二区| 欧美在线啊v一区| 亚洲美女黄色| 欧美一区二区三区婷婷月色 | 老司机一区二区| 欧美成在线视频| 欧美在线观看一二区| 久久琪琪电影院| 午夜精品国产| 欧美福利电影网| 久久国产主播| 欧美日韩一区二区三区高清| 久久一区中文字幕| 国产精品乱看| 亚洲国产精品一区二区尤物区| 国产精品久久久久久影院8一贰佰| 狂野欧美一区| 国产精品一区久久| 日韩视频一区二区三区在线播放免费观看 | 先锋影音久久久| 亚洲精品中文字幕有码专区| 久久丁香综合五月国产三级网站| 9色porny自拍视频一区二区| 久久久久久亚洲综合影院红桃| 亚洲在线一区二区三区| 欧美成人免费大片| 巨胸喷奶水www久久久免费动漫| 国产精品高清一区二区三区| 亚洲国产精品一区| 亚洲国产精品va在线看黑人| 欧美一区二区免费观在线| 亚洲欧美另类久久久精品2019| 欧美激情一区二区三区四区| 欧美国产一区二区在线观看| 在线观看亚洲精品| 久久黄色影院| 鲁大师影院一区二区三区| 国产一区二区视频在线观看| 午夜在线精品| 久久久久国产精品一区| 国产日本欧美一区二区三区在线 | 亚洲电影免费观看高清完整版在线观看| 国产日韩三区| 欧美在线亚洲| 久久在线视频| 国语自产偷拍精品视频偷| 亚洲一区国产视频| 在线综合视频| 欧美精品久久久久久久| 欧美在线观看你懂的| 国产日韩欧美另类| 亚洲欧美成人网| 亚洲性色视频| 欧美性理论片在线观看片免费| 亚洲福利视频二区| 亚洲欧洲另类| 欧美jizz19性欧美| 欧美xart系列在线观看| 国产日韩在线不卡| 亚洲欧美一区二区原创| 亚洲欧美卡通另类91av| 国产精品久久久久久久久久免费| 亚洲电影有码| 一区二区三区回区在观看免费视频 | 欧美日韩中文字幕综合视频| 亚洲看片网站| 亚洲欧美日韩国产综合| 国产精品欧美一区二区三区奶水 | 亚洲视频一起| 国产精品久久福利| 亚洲男女毛片无遮挡| 久久九九免费视频| 亚洲国产精品va在线观看黑人 | 欧美国产综合| 亚洲精品乱码久久久久久蜜桃麻豆 | 久久国产精品毛片| 国产精品成人av性教育| 一区二区三区色| 欧美一区1区三区3区公司| 国产日韩在线亚洲字幕中文| 久久精品国产亚洲一区二区| 欧美成人亚洲| 一本色道88久久加勒比精品| 欧美a级理论片| 欧美亚洲综合另类| 欧美大胆人体视频| 一区二区黄色| 国产精品成人久久久久| 久久精品免费观看| 亚洲毛片一区| 久久www免费人成看片高清| 伊甸园精品99久久久久久| 欧美精品在线观看| 亚洲美女精品成人在线视频| 另类欧美日韩国产在线| 一本色道久久88综合日韩精品| 国产精品普通话对白| 久久久午夜电影| 夜夜爽www精品| 久久亚洲欧美国产精品乐播| 99re这里只有精品6| 国产午夜精品一区二区三区视频 | 欧美高清视频一区二区三区在线观看| 亚洲精品一区二区三区在线观看| 国产精品久久久久久久9999| 久久免费99精品久久久久久| 亚洲国产精品美女| 久久综合网络一区二区| 亚洲一区二区三区在线看| 韩日精品中文字幕| 国产精品v日韩精品v欧美精品网站 | 这里只有视频精品| 一区二区在线不卡| 国产麻豆日韩| 欧美日韩在线直播| 美腿丝袜亚洲色图| 亚洲永久字幕| 99精品国产在热久久| 欧美xart系列高清| 久久久久久婷| 午夜久久tv| 亚洲视频www| 亚洲精品在线视频| 91久久中文| 激情一区二区三区| 国产欧美日韩精品丝袜高跟鞋| 欧美精品在欧美一区二区少妇| 久久久久欧美精品| 亚洲深夜福利视频| 中文网丁香综合网| 99精品热视频只有精品10| 亚洲国产一区在线| 欧美国产免费| 久久久久国产精品一区| 午夜精品美女自拍福到在线 | 欧美顶级艳妇交换群宴| 久久一区二区三区超碰国产精品 | 中文av字幕一区| 91久久精品国产91性色| 在线播放中文字幕一区| 激情视频一区二区三区| 一区二区三区中文在线观看 | 欧美一级视频精品观看| 亚洲欧美国产制服动漫| 亚洲亚洲精品三区日韩精品在线视频| 亚洲国产精品久久91精品| 最新亚洲一区| 亚洲剧情一区二区| 亚洲视频一区二区| 亚洲一区二区在线视频| 亚洲综合视频网| 美日韩精品免费观看视频| 免费成人黄色av| 欧美日本亚洲韩国国产| 欧美日韩三级一区二区| 国产精品久久久久久久9999| 国产精品v欧美精品v日韩| 国产自产女人91一区在线观看| 精品不卡视频| 日韩午夜黄色| 性欧美xxxx大乳国产app| 久久五月天婷婷| 欧美激情在线狂野欧美精品| 亚洲免费综合| 老司机精品视频一区二区三区| 女仆av观看一区| 国产精品久久久久一区二区| 国产一区二区精品久久91| 宅男精品视频| 久色婷婷小香蕉久久| 亚洲国产99精品国自产| 亚洲曰本av电影| 久久综合九色欧美综合狠狠| 国产麻豆9l精品三级站|