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

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>
            欧美一区二区三区男人的天堂 | 欧美成va人片在线观看| 国产欧美精品日韩| 久久超碰97中文字幕| 亚洲欧美在线一区二区| 国产亚洲成年网址在线观看| 久久se精品一区精品二区| 欧美亚洲日本网站| 亚洲国产成人精品久久| 亚洲国产成人午夜在线一区| 欧美暴力喷水在线| 亚洲综合成人婷婷小说| 欧美亚洲网站| 亚洲黄色毛片| 一区二区三区三区在线| 国产亚洲精品v| 欧美freesex8一10精品| 欧美三级免费| 免费一区视频| 国产精品多人| 免费成人av资源网| 欧美日韩激情小视频| 久久国产福利国产秒拍| 欧美成人小视频| 小处雏高清一区二区三区 | 欧美在线视频在线播放完整版免费观看| 国产一区久久久| 亚洲人成人一区二区在线观看| 国产精品一级二级三级| 欧美国产日本在线| 国产精品美女久久久| 欧美a级一区| 国产欧美日韩中文字幕在线| 亚洲第一区中文99精品| 国产综合久久久久影院| 99国产精品国产精品久久| 在线观看不卡| 亚洲女同在线| 亚洲永久在线| 欧美成人一区二区在线| 久久人人爽人人爽| 国产精品久久777777毛茸茸| 亚洲福利av| 在线成人免费观看| 欧美亚洲综合另类| 亚洲综合精品四区| 欧美福利精品| 欧美国产日本| 在线播放豆国产99亚洲| 欧美中文在线观看| 午夜精品影院| 国产精品黄页免费高清在线观看| 亚洲精品1区| 亚洲精品一区二区三区av| 久久久久久穴| 久久在线免费观看| 好吊妞这里只有精品| 亚洲一区二区三区免费观看| 一区二区三区四区精品| 欧美美女日韩| 99re6热在线精品视频播放速度| 亚洲国产精品一区二区第一页| 久久精品国产一区二区三| 久久成人综合视频| 国产午夜精品理论片a级探花| 国产精品99久久久久久久vr| 一区二区三区视频在线看| 欧美男人的天堂| 亚洲精品一二三区| 亚洲一区二区三区视频播放| 欧美色道久久88综合亚洲精品| 亚洲精品网站在线播放gif| 一区二区三区免费看| 国产精品成人一区二区| 亚洲男女毛片无遮挡| 久久免费一区| 亚洲高清网站| 欧美日韩国产精品一区二区亚洲| 亚洲免费观看高清完整版在线观看熊 | 亚洲日本中文字幕区 | 日韩一区二区精品在线观看| 在线一区二区视频| 国产精品网站视频| 欧美一区二区国产| 欧美黄在线观看| 中文av一区二区| 国产精品婷婷| 鲁大师影院一区二区三区| 亚洲电影专区| 午夜天堂精品久久久久| 精品福利免费观看| 欧美日韩国产综合视频在线观看中文 | 国产精品户外野外| 久久国产欧美| 亚洲欧洲日韩综合二区| 亚洲综合精品自拍| 亚洲高清视频一区二区| 国产精品啊啊啊| 久久综合狠狠综合久久综合88| 亚洲精品小视频| 另类图片国产| 亚洲一二三区精品| 一区二区三区在线高清| 国产精品盗摄一区二区三区| 久久久之久亚州精品露出| 一区二区黄色| 欧美粗暴jizz性欧美20| 欧美伊人影院| 在线视频日本亚洲性| 激情成人综合| 国产精品人成在线观看免费 | 欧美二区在线观看| 午夜精品久久久久久久99水蜜桃| 欧美激情在线| 久久久夜色精品亚洲| 亚洲男女自偷自拍| 亚洲精品乱码久久久久久黑人 | 国产日韩av一区二区| 欧美高清视频在线观看| 欧美亚洲在线| 亚洲一区在线观看视频| 最新国产乱人伦偷精品免费网站| 久久婷婷一区| 欧美尤物巨大精品爽| 一本在线高清不卡dvd| 亚洲人人精品| 亚洲丰满少妇videoshd| 国内精品美女av在线播放| 国产精品v片在线观看不卡| 鲁大师成人一区二区三区| 久久精品1区| 久久av资源网站| 久久成人18免费观看| 午夜精品久久久久久久久久久久久| 亚洲人成小说网站色在线| 欧美电影免费观看高清完整版| 久久精品国产亚洲5555| 先锋a资源在线看亚洲| 亚洲影音一区| 亚洲欧美韩国| 午夜日韩视频| 久久成年人视频| 久久久91精品国产| 久久久免费精品视频| 久久视频精品在线| 美女成人午夜| 欧美成人午夜剧场免费观看| 免费成人黄色| 亚洲国产日韩一区| 亚洲毛片在线| 一区二区三区精密机械公司| 亚洲午夜日本在线观看| 亚洲欧美精品在线| 久久国产精彩视频| 蜜臀va亚洲va欧美va天堂| 欧美freesex交免费视频| 欧美激情久久久久久| 欧美精品在线网站| 国产精品免费福利| 国外成人在线视频| 亚洲美女免费精品视频在线观看| 日韩一级大片| 欧美一级在线视频| 免费在线亚洲欧美| 亚洲人成在线观看网站高清| 在线视频日韩| 久久精品一区二区三区四区| 久久中文字幕一区二区三区| 欧美另类一区| 国产视频久久| 亚洲六月丁香色婷婷综合久久| 亚洲天堂成人| 免播放器亚洲| 一区二区三区欧美| 久久中文精品| 国产精品久久久久久久7电影| 尤物网精品视频| 在线一区二区三区四区五区| 久久久亚洲高清| 99精品99久久久久久宅男| 欧美一区深夜视频| 欧美精品免费播放| 国产一区二区毛片| 亚洲性感美女99在线| 欧美成人嫩草网站| 亚洲与欧洲av电影| 欧美福利视频在线| 国产一区欧美日韩| 亚洲一区美女视频在线观看免费| 欧美h视频在线| 亚洲资源在线观看| 欧美日韩国产精品专区| 136国产福利精品导航网址| 亚洲一区二区三区四区五区黄| 欧美国产日本高清在线| 性色av一区二区三区红粉影视| 欧美乱人伦中文字幕在线| 在线成人中文字幕| 久久久久久网| 亚洲永久精品大片|