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

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 閱讀(2878) 評論(2)  編輯 收藏 引用 所屬分類: C++隨筆而已

評論

# re: Why the inline function can not be coveraged? 2012-09-26 19:35 smagle

gcov原理分析詳細(xì)可參考:http://sdet.org/?p=212  回復(fù)  更多評論   

# re: Why the inline function can not be coveraged?[未登錄] 2012-09-26 22:16 codejie

@smagle
very great article. thanks!  回復(fù)  更多評論   

公告

Using C++

導(dǎo)航

統(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精品视频免费全部在线| 一区二区三区久久精品| 国产精品中文字幕在线观看| 久久久久免费视频| 免费在线观看精品| 亚洲欧美精品在线| 久久精品国产69国产精品亚洲| 亚洲国产精品久久久久久女王| 91久久中文| 欧美日韩在线精品| 久久视频在线免费观看| 欧美精品一区二区三区久久久竹菊| 亚洲一区久久久| 久久精品一区蜜桃臀影院| 亚洲精品日产精品乱码不卡| 在线中文字幕日韩| 亚洲韩日在线| 亚洲欧美在线磁力| 亚洲九九九在线观看| 亚洲在线中文字幕| 亚洲裸体视频| 欧美在线播放一区| 亚洲网站视频福利| 久久人人爽人人爽| 欧美一级视频免费在线观看| 欧美mv日韩mv亚洲| 久久久噜久噜久久综合| 欧美丝袜一区二区| 亚洲国产一区二区三区青草影视 | 欧美v亚洲v综合ⅴ国产v| 欧美美女bbbb| 欧美国产精品中文字幕| 国产精品一区二区在线| 亚洲欧洲在线免费| 亚洲高清一区二区三区| 亚洲欧美久久久久一区二区三区| 亚洲乱码国产乱码精品精98午夜| 欧美伊人久久大香线蕉综合69| 亚洲美女电影在线| 久久亚洲国产精品日日av夜夜| 先锋影院在线亚洲| 欧美视频在线免费| 亚洲精品日韩综合观看成人91| 在线观看免费视频综合| 欧美一区二区黄色| 久久国产精品久久精品国产| 欧美日韩在线不卡一区| 亚洲精品永久免费精品| 亚洲日本中文字幕区| 久久在精品线影院精品国产| 久久九九精品| 国产在线欧美| 久久精品国产精品亚洲| 久久视频精品在线| 黄色日韩网站| 久久久久亚洲综合| 欧美丰满少妇xxxbbb| 在线观看欧美日韩国产| 久久久综合视频| 免费成人小视频| 亚洲国产精品福利| 欧美大片91| 91久久夜色精品国产九色| 日韩特黄影片| 国产精品播放| 亚洲欧美综合一区| 久久亚洲二区| 亚洲欧洲一区二区三区| 欧美精品videossex性护士| 亚洲精品久久久一区二区三区| 99在线热播精品免费| 欧美日韩视频在线观看一区二区三区 | 中文av一区二区| 国产精品久久久久久久久久久久久| 亚洲午夜电影网| 久久er99精品| 亚洲欧洲视频在线| 欧美视频免费看| 午夜国产不卡在线观看视频| 久久亚洲视频| 日韩午夜在线视频| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 亚洲精品在线一区二区| 亚洲欧美三级在线| 国内精品免费在线观看| 欧美chengren| 亚洲欧美成人一区二区在线电影 | 久久不射中文字幕| 亚洲欧洲日本在线| 国产欧美一区二区三区沐欲| 久久久成人网| 一区二区免费看| 看片网站欧美日韩| 亚洲一区二区毛片| 亚洲成色精品| 国产精品热久久久久夜色精品三区| 久久精品一区中文字幕| 一本色道久久88精品综合| 久久gogo国模裸体人体| 夜夜嗨av一区二区三区四季av| 国产色产综合色产在线视频| 欧美电影在线| 久久黄色小说| 亚洲一区二区三区影院| 亚洲国产三级| 老司机亚洲精品| 亚洲欧美日本视频在线观看| 亚洲人成在线播放| 国产一区二区在线免费观看| 欧美精品一区二区精品网| 久久黄色影院| 午夜精品久久久久久久99黑人| 亚洲日本在线视频观看| 久久影院午夜论| 欧美在线1区| 亚洲一区二区三区在线观看视频| 在线精品福利| 国产亚洲成av人片在线观看桃| 欧美日韩网址| 欧美高清一区二区| 女仆av观看一区| 久久在线免费观看视频| 久久成人精品视频| 欧美中日韩免费视频| 亚洲无玛一区| 亚洲综合第一页| 一区二区三区 在线观看视频| 亚洲第一中文字幕在线观看| 裸体一区二区三区| 久久性色av| 免费在线亚洲| 欧美成人午夜激情| 欧美国产综合一区二区| 免费不卡在线视频| 欧美国产日韩一区二区在线观看| 久久蜜桃资源一区二区老牛| 久久九九久精品国产免费直播| 欧美在线综合| 久久综合伊人77777麻豆| 老鸭窝毛片一区二区三区| 久久在线免费| 欧美成人免费视频| 亚洲黄色片网站| 亚洲美女视频在线免费观看| 99re66热这里只有精品4| 一区二区久久久久久| 亚洲一卡二卡三卡四卡五卡| 亚洲欧美日韩中文播放| 欧美一区二区日韩| 老司机精品导航| 欧美日韩黄色一区二区| 国产精品欧美日韩久久| 国产丝袜一区二区| 亚洲国产成人久久综合| 夜夜嗨av一区二区三区免费区| 亚洲女与黑人做爰| 久久久久久久久岛国免费| 欧美成人精精品一区二区频| 亚洲黄色高清| 亚洲欧美另类在线观看| 久久青青草综合| 欧美日本精品| 国产日韩av一区二区| 亚洲福利视频网站| 亚洲午夜性刺激影院| 久久久久久久久久看片| 亚洲黄色成人久久久| 午夜老司机精品| 男人的天堂亚洲| 国产精品一区二区三区乱码| 亚洲大片免费看| 午夜精品久久久久久久男人的天堂 | 亚洲国产精品久久久久久女王| 一区二区三区视频观看| 久久琪琪电影院| 国产精品家庭影院| 亚洲国产婷婷| 久久精品av麻豆的观看方式 | 先锋影音一区二区三区| 欧美国产日韩a欧美在线观看| 亚洲网站视频福利| 欧美韩日高清| 狠狠做深爱婷婷久久综合一区| 夜夜夜久久久| 欧美1区2区3区| 亚洲综合精品四区| 欧美日韩国产综合视频在线观看 | 欧美人妖在线观看| 亚洲第一视频| 久久亚洲国产精品日日av夜夜| 宅男噜噜噜66国产日韩在线观看| 蜜臀av在线播放一区二区三区| 国产日韩欧美91| 亚洲欧美日本精品|