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

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>
            欧美劲爆第一页| 国产精品一区二区久久久| 激情欧美一区| 麻豆精品在线视频| 久久精品国产99国产精品| 极品尤物一区二区三区| 欧美黄在线观看| 欧美久久久久久| 亚洲女人av| 久久av一区二区| 91久久国产综合久久蜜月精品| 另类专区欧美制服同性| 免费在线成人av| 亚洲欧美美女| 久久xxxx精品视频| 亚洲人妖在线| 中文欧美在线视频| 国内自拍视频一区二区三区| 亚洲国产精品成人精品| 欧美人与禽猛交乱配视频| 亚洲尤物在线| 久久亚洲精品欧美| 亚洲综合电影| 蜜桃av一区二区| 亚洲欧美日韩国产精品| 久久久九九九九| 亚洲午夜激情网页| 久久久久久久一区二区| 亚洲午夜性刺激影院| 久久久久久成人| 亚洲中字黄色| 美玉足脚交一区二区三区图片| 亚洲摸下面视频| 老司机久久99久久精品播放免费 | 欧美四级电影网站| 久久深夜福利免费观看| 欧美三级网址| 欧美大片网址| 国产在线不卡精品| 一区二区三区成人| 最新亚洲一区| 久久国产88| 亚洲欧美日韩专区| 欧美精品乱码久久久久久按摩| 久久久久网站| 国产精品视频男人的天堂| 亚洲日本中文字幕区| 樱花yy私人影院亚洲| 亚洲欧美www| 亚洲综合精品| 欧美日韩一区二区三区四区五区| 欧美国产欧美综合| 一区视频在线| 久久精品成人一区二区三区| 性做久久久久久久久| 欧美日韩亚洲一区二区三区在线| 欧美91精品| 国内精品久久久久影院优| 亚洲欧美激情精品一区二区| 一区二区欧美日韩| 欧美乱在线观看| 亚洲国产精品成人精品| 亚洲三级网站| 欧美激情精品久久久久久变态| 免费观看成人www动漫视频| 国模大胆一区二区三区| 久久精品国产999大香线蕉| 久久精品一区中文字幕| 国产亚洲精品bv在线观看| 午夜精品久久久久影视 | 亚洲第一久久影院| 久久久夜夜夜| 欧美激情导航| 亚洲精品一区在线| 欧美国产精品人人做人人爱| 91久久亚洲| 国产精品99久久久久久久久| 欧美体内谢she精2性欧美| 亚洲午夜极品| 久久久之久亚州精品露出| 国内综合精品午夜久久资源| 麻豆久久精品| 亚洲人成人一区二区三区| 亚洲香蕉在线观看| 国产区精品视频| 久久综合婷婷| 亚洲毛片av在线| 欧美一区观看| 亚洲成人自拍视频| 欧美猛交免费看| 亚洲曰本av电影| 免费观看成人| 亚洲影院在线| 悠悠资源网亚洲青| 欧美日韩国产成人在线| 午夜精品久久久久影视| 欧美激情欧美激情在线五月| 亚洲视频在线免费观看| 国产一区二区视频在线观看| 美女被久久久| 亚洲一区二区在线看| 欧美ed2k| 午夜一级久久| 亚洲看片免费| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美金8天国| 正在播放欧美一区| 老司机aⅴ在线精品导航| 日韩午夜在线播放| 国产一在线精品一区在线观看| 欧美激情区在线播放| 亚洲欧美日韩电影| 亚洲电影有码| 久久成人免费电影| 一卡二卡3卡四卡高清精品视频| 国产视频亚洲| 欧美午夜精品久久久久久人妖| 亚洲欧美清纯在线制服| 亚洲国产va精品久久久不卡综合| 欧美一区二区三区在线观看 | 欧美人交a欧美精品| 久久精品99| 亚洲欧美国产精品va在线观看| 最新国产乱人伦偷精品免费网站| 久久精品视频导航| 一本色道久久综合亚洲精品高清 | 亚洲欧美制服中文字幕| 亚洲美女黄色| 亚洲国产精品成人综合色在线婷婷| 国产模特精品视频久久久久| 欧美精品aa| 免费亚洲一区| 久久亚洲视频| 久久久精品性| 久久精品三级| 久久精品国产91精品亚洲| 亚洲网友自拍| 在线亚洲欧美| 在线午夜精品自拍| 国产精品99久久久久久有的能看| 亚洲欧洲一级| 亚洲人成亚洲人成在线观看| 亚洲国产欧美日韩| 亚洲国产成人在线| 亚洲国产毛片完整版| 欧美激情精品久久久久久蜜臀 | 亚洲人成精品久久久久| 亚洲第一页自拍| 亚洲国产一区在线| 亚洲黄色三级| 艳妇臀荡乳欲伦亚洲一区| 亚洲精选在线观看| 日韩系列在线| 亚洲天堂久久| 欧美在线观看视频| 久久乐国产精品| 欧美成人国产| 欧美三级视频在线播放| 国产农村妇女毛片精品久久麻豆 | 亚洲精品欧美激情| 正在播放日韩| 欧美一区二区三区电影在线观看| 欧美在线网址| 免费人成精品欧美精品| 亚洲国产一区二区三区a毛片| 亚洲精品精选| 亚洲女优在线| 开心色5月久久精品| 欧美日韩久久不卡| 国产女人精品视频| 亚洲国产精品一区二区www在线| 日韩性生活视频| 亚洲欧美视频在线观看视频| 久久久综合精品| 亚洲欧洲在线一区| 亚洲欧美日韩国产一区| 暖暖成人免费视频| 国产精品视频观看| 亚洲国产精品久久久久婷婷884 | 欧美在线观看视频一区二区三区 | 亚洲日本久久| 亚洲欧美日韩在线| 蜜臀久久久99精品久久久久久| 亚洲精品美女在线| 久久国产精品99国产精| 欧美精品日韩| 国产一区二区三区丝袜 | 黄色成人在线网址| 亚洲一区二区三区精品视频| 久久偷看各类wc女厕嘘嘘偷窃| 亚洲黄色一区| 久久免费视频网站| 国产欧美日韩视频一区二区三区| 亚洲欧洲日韩综合二区| 久久av二区| 在线视频精品一| 牛牛影视久久网| 国内一区二区三区在线视频| 亚洲高清一区二| 亚洲一区二区在线播放|