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

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>
            日韩视频不卡| 久久看片网站| 国产午夜精品理论片a级探花| 欧美视频在线观看一区| 欧美三级中文字幕在线观看| 欧美午夜不卡在线观看免费| 国产精品一区免费观看| 国产精品有限公司| 伊人久久亚洲热| 亚洲国产美女久久久久| 影院欧美亚洲| 亚洲精品永久免费| 亚洲欧美在线磁力| 久久综合九色综合网站| 亚洲国产精品第一区二区| 99国产精品久久| 久久成人精品一区二区三区| 欧美电影免费观看高清完整版| 欧美日韩国产在线播放网站| 国产日韩1区| 亚洲肉体裸体xxxx137| 亚洲一区欧美| 欧美国产精品劲爆| 亚洲欧美电影院| 欧美成人综合在线| 国产日韩精品一区二区三区| 99精品视频免费观看| 久久久精彩视频| 亚洲免费观看高清完整版在线观看| 午夜精品久久久| 欧美丝袜第一区| 亚洲日本欧美日韩高观看| 久久国产精品久久久久久电车| 亚洲日本黄色| 久久影视精品| 国产一区二区三区电影在线观看| 亚洲午夜在线观看| 91久久国产综合久久| 久久狠狠久久综合桃花| 欧美体内谢she精2性欧美| 亚洲欧洲一级| 玖玖视频精品| 在线视频成人| 香蕉乱码成人久久天堂爱免费| 亚洲黄色一区| 麻豆精品视频在线观看视频| 国内精品久久久久久久影视蜜臀| 亚洲欧美乱综合| 亚洲精品乱码久久久久久蜜桃麻豆| 久久久久久久综合狠狠综合| 国产日韩在线不卡| 欧美在线视频在线播放完整版免费观看 | 午夜天堂精品久久久久| 亚洲久久一区二区| 欧美极品色图| 亚洲久久成人| 亚洲精品国产视频| 欧美日韩成人激情| 一区二区毛片| 在线亚洲免费| 国产精品久久久久免费a∨大胸| 亚洲一区高清| 亚洲高清一区二区三区| 欧美日精品一区视频| 99视频一区二区| 亚洲人成绝费网站色www| 裸体素人女欧美日韩| 91久久精品网| 亚洲日本免费| 国产精品九九久久久久久久| 国产精品毛片在线| 亚洲视频自拍偷拍| 亚洲一区二区视频在线观看| 国产精品入口66mio| 销魂美女一区二区三区视频在线| 中文无字幕一区二区三区| 国产精品视频九色porn| 久久久国产亚洲精品| 久热精品视频| 亚洲午夜免费福利视频| 亚洲一级影院| 尤物视频一区二区| 亚洲精品乱码久久久久久黑人| 欧美日韩在线播| 亚洲影院色无极综合| 欧美在线观看视频一区二区| 亚洲国产乱码最新视频| 欧美一区二区三区久久精品茉莉花| 亚洲欧美欧美一区二区三区| 在线观看国产欧美| 99精品免费网| 激情欧美一区二区| 亚洲精品自在久久| 国产一区亚洲一区| 亚洲欧洲精品一区二区三区不卡 | 久久久精品免费视频| 亚洲欧洲日本mm| 亚洲一区二区三区精品动漫| 樱花yy私人影院亚洲| 亚洲日本va午夜在线影院| 国产深夜精品| 99pao成人国产永久免费视频| 国产在线视频不卡二| 亚洲精品欧洲精品| 国产一区二区在线观看免费播放| 亚洲国产视频一区| 国产在线精品成人一区二区三区| 亚洲精华国产欧美| 欲香欲色天天天综合和网| 一区二区三区高清| 欧美久久久久久蜜桃| 久久综合伊人77777尤物| 欧美体内she精视频| 亚洲国产精品va在线看黑人动漫| 国产日产欧产精品推荐色| 亚洲精品国产精品国自产观看 | 亚洲精品国产精品乱码不99按摩 | 国产精品一区二区久久国产| 免费在线成人av| 国产精品亚洲人在线观看| 亚洲精品久久久久久久久久久| 一区二区三区自拍| 欧美一区二区在线看| 亚洲自拍偷拍福利| 欧美理论电影在线播放| 欧美福利视频| 在线观看亚洲专区| 久久成人国产精品| 久久久亚洲成人| 国产视频久久久久久久| 亚洲一区二区三区中文字幕| 亚洲婷婷综合久久一本伊一区| 欧美激情精品| 亚洲国产午夜| 99香蕉国产精品偷在线观看| 欧美精品在线视频观看| 亚洲精品一区二区在线| 一区二区欧美在线观看| 欧美日韩免费高清| 一本一道久久综合狠狠老精东影业 | 激情综合亚洲| 久久麻豆一区二区| 免费欧美网站| 亚洲国产黄色| 欧美国产日本在线| 99精品视频免费观看| 亚洲男人天堂2024| 国产欧美91| 久久亚洲私人国产精品va媚药 | 午夜视频在线观看一区| 性视频1819p久久| 国产视频不卡| 久热精品视频在线观看一区| 亚洲国产一区二区a毛片| 99视频精品在线| 国产精品一区二区a| 久久精品综合一区| 最近看过的日韩成人| 在线一区二区三区做爰视频网站| 欧美日韩中文精品| 久久国产精品毛片| 亚洲高清激情| 亚洲欧美中文日韩在线| 海角社区69精品视频| 欧美精品九九99久久| 亚洲欧美怡红院| 亚洲成色999久久网站| 欧美国产一区视频在线观看| 亚洲黄色高清| 午夜精品视频网站| 亚洲高清资源| 国产精品久久久久久久app| 久久精品视频免费播放| 亚洲精品激情| 老鸭窝毛片一区二区三区 | 久久三级视频| 亚洲国产成人不卡| 国产精品成人观看视频免费| 久久精品欧美日韩精品| 亚洲电影免费在线| 欧美在线观看网站| 99视频精品免费观看| 精品1区2区3区4区| 国产精品青草久久| 欧美国产精品一区| 欧美一区二区免费| 一本色道久久88精品综合| 欧美va天堂| 久久久99国产精品免费| 亚洲尤物在线视频观看| 亚洲精品欧美| 永久免费视频成人| 国产日韩av高清| 国产精品电影在线观看| 欧美激情成人在线| 美女视频网站黄色亚洲| 欧美伊人久久| 亚洲欧美日韩一区二区三区在线| 亚洲美女尤物影院| 亚洲三级网站|