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

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>
            久久久.com| 另类欧美日韩国产在线| 亚洲精品午夜精品| 欧美日韩免费看| 亚洲天堂免费在线观看视频| 日韩一级大片| 国产精品久久久久久久电影 | 狠狠色狠狠色综合日日91app| 久久精品中文字幕一区| 久久国产精品72免费观看| 激情欧美一区| 亚洲国产日本| 欧美性做爰毛片| 久久成人18免费网站| 久久视频精品在线| 99精品国产在热久久婷婷| 中文高清一区| 伊人激情综合| 日韩视频不卡| 国产真实久久| 91久久一区二区| 国产精品一区二区三区久久久 | 亚洲精品一区二区三区不| 亚洲精品中文字幕女同| 国产精品男gay被猛男狂揉视频| 久久gogo国模啪啪人体图| 美女91精品| 欧美一区二区精品在线| 牛牛国产精品| 欧美中文字幕久久| 欧美剧在线观看| 久久久一区二区三区| 欧美激情国产日韩| 久久高清免费观看| 欧美精品日韩www.p站| 久久国产免费| 欧美区一区二区三区| 久久国产99| 欧美色精品天天在线观看视频| 久久久精品日韩| 欧美小视频在线| 亚洲国产裸拍裸体视频在线观看乱了| 国产精品久久久久久亚洲毛片 | 久久亚洲捆绑美女| 欧美午夜片在线免费观看| 蜜臀99久久精品久久久久久软件| 欧美体内she精视频| 免费在线看成人av| 国产麻豆综合| 宅男在线国产精品| 一区二区三区精品视频| 免费久久99精品国产| 久久手机免费观看| 国产欧美精品一区二区三区介绍 | 久久久久网站| 国产精品自拍一区| 宅男噜噜噜66一区二区66| 亚洲精选91| 免费成人高清| 欧美不卡高清| 亚洲国产精品成人久久综合一区| 久久激情视频| 老司机一区二区三区| 国产一区二区三区在线播放免费观看| 亚洲视频在线二区| 亚洲永久免费观看| 欧美午夜精品电影| 亚洲图片在线| 午夜国产精品影院在线观看| 欧美日韩亚洲另类| 99国产精品99久久久久久粉嫩| 亚洲免费观看| 欧美黄污视频| 一区二区三区四区在线| 亚洲自拍电影| 国产日韩成人精品| 欧美在线首页| 欧美成人午夜免费视在线看片| 雨宫琴音一区二区在线| 久久免费的精品国产v∧| 欧美88av| 在线中文字幕日韩| 国产精品无码永久免费888| 午夜精品久久久久久久99热浪潮| 久久成人一区| 亚洲国产精品黑人久久久| 欧美国产免费| 亚洲影院在线观看| 久久久久久综合网天天| 亚洲福利视频在线| 欧美日韩高清在线观看| 亚洲深夜激情| 免费中文日韩| 亚洲欧美第一页| 国内精品模特av私拍在线观看| 久久久久国产免费免费| 最新日韩精品| 久久av二区| 亚洲日本欧美日韩高观看| 国产精品二区影院| 久久久久国产成人精品亚洲午夜| 最新国产拍偷乱拍精品| 欧美在线精品一区| 亚洲人成人99网站| 国产日韩精品综合网站| 欧美成人一区二区三区片免费| 正在播放欧美一区| 欧美顶级艳妇交换群宴| 亚洲欧美日韩爽爽影院| 亚洲国产99精品国自产| 国产精品久久久久久久久久三级| 久久久久欧美精品| 亚洲先锋成人| 亚洲黄网站黄| 免费不卡视频| 欧美在线视频日韩| 中文av一区二区| 亚洲第一页中文字幕| 国产伦精品一区二区三| 欧美大片免费观看在线观看网站推荐| 亚洲综合精品自拍| 亚洲狠狠婷婷| 久久综合婷婷| 午夜精品久久久久久久久久久久| 亚洲精品久久视频| 在线观看三级视频欧美| 国产日韩一区欧美| 国产精品久久久久婷婷| 欧美精品系列| 欧美成人午夜剧场免费观看| 久久黄金**| 欧美一区二视频在线免费观看| 99精品久久久| 日韩一级大片在线| 亚洲人精品午夜在线观看| 欧美mv日韩mv亚洲| 久久嫩草精品久久久精品一| 欧美中文字幕视频| 欧美一区二区三区另类 | 亚洲国产高清高潮精品美女| 国产美女一区| 国产精品一香蕉国产线看观看 | 国产精品久久久久av免费| 欧美激情按摩在线| 欧美黄色日本| 欧美激情视频给我| 欧美国产亚洲另类动漫| 欧美电影打屁股sp| 欧美精品三区| 欧美视频一区二区三区…| 欧美日韩视频在线一区二区观看视频| 欧美成人激情在线| 欧美另类一区二区三区| 欧美日韩日本国产亚洲在线| 欧美日韩无遮挡| 欧美日韩在线免费视频| 欧美性大战久久久久| 国产精品久久精品日日| 国产精品视频免费观看www| 国产免费观看久久| 激情文学综合丁香| 亚洲国产91精品在线观看| 亚洲第一色中文字幕| **性色生活片久久毛片| 亚洲精品视频中文字幕| 亚洲香蕉成视频在线观看| 亚洲欧美日韩国产一区二区三区| 欧美在线亚洲| 欧美成人久久| 一本色道久久88亚洲综合88| 亚洲自拍偷拍麻豆| 久久免费精品视频| 欧美精品自拍偷拍动漫精品| 国产精品免费久久久久久| 国产主播一区二区| 亚洲精品日本| 欧美一区国产一区| 亚洲电影av| 亚洲一区二区影院| 久热综合在线亚洲精品| 欧美色图五月天| 在线不卡中文字幕播放| 亚洲一卡久久| 免费在线观看成人av| 中日韩视频在线观看| 久久亚洲精品视频| 国产精品免费网站| 亚洲人成在线播放| 欧美专区在线观看一区| 亚洲黄色免费| 久久久99爱| 国产精品影片在线观看| 亚洲国产欧美一区二区三区同亚洲| 亚洲视频在线一区| 老司机久久99久久精品播放免费| 野花国产精品入口| 欧美成人在线免费观看| 国内精品久久久久国产盗摄免费观看完整版 | 亚洲午夜91| 欧美精品91|