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

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>
            欧美日韩hd| 国产精品欧美在线| 亚洲国产精品久久久久秋霞蜜臀| 亚久久调教视频| 羞羞答答国产精品www一本 | 亚洲电影免费观看高清完整版| 欧美在线视频观看免费网站| 国产亚洲欧洲| 欧美福利一区二区| 欧美日韩一区二区三区| 亚洲欧美日韩精品久久久| 亚洲一区网站| 精品成人在线| 日韩视频免费观看高清完整版| 欧美日韩一区二区在线| 亚洲欧美国产va在线影院| 香蕉免费一区二区三区在线观看| 一色屋精品视频在线看| 亚洲人成久久| 国产免费观看久久| 亚洲电影激情视频网站| 国产精品久久97| 久久一区二区三区超碰国产精品| 欧美电影在线| 久久久久国产精品午夜一区| 蜜臀va亚洲va欧美va天堂| 亚洲影院在线观看| 久久色在线观看| 亚洲欧美日韩一区二区| 久久一区国产| 欧美一级久久久| 欧美激情视频网站| 久久久久久电影| 欧美亚洲成人精品| 欧美成人免费在线观看| 国产美女精品视频| 亚洲区一区二区三区| 国产综合久久久久久| 日韩午夜剧场| 亚洲国产日韩欧美一区二区三区| 在线观看视频亚洲| 一本色道久久综合狠狠躁篇怎么玩| 国产一区二区三区久久精品| 日韩视频永久免费观看| 亚洲第一网站免费视频| 午夜精品久久久久久久久久久| av成人免费在线| 蜜桃av一区| 久久影音先锋| 国产亚洲激情| 亚洲一区二区伦理| 亚洲网站视频福利| 欧美精彩视频一区二区三区| 久久一区亚洲| 国产有码在线一区二区视频| 宅男噜噜噜66一区二区| 在线综合欧美| 欧美日韩一区二| 亚洲福利视频二区| 在线成人黄色| 久久婷婷国产综合国色天香| 久久久久一区| 韩国三级电影久久久久久| 欧美一区二区三区播放老司机| 亚洲综合日韩在线| 国产精品久久久久久妇女6080 | 欧美在线一级va免费观看| 亚洲男女自偷自拍图片另类| 欧美日韩直播| 在线一区欧美| 午夜视频一区二区| 国产欧美日韩一区二区三区| 欧美亚洲在线视频| 久久影院亚洲| 亚洲国产欧美久久| 欧美日产一区二区三区在线观看| 亚洲国产欧美在线人成| avtt综合网| 国产精品婷婷| 欧美一区二区成人| 免费国产一区二区| 99成人免费视频| 国产精品美女999| 小黄鸭精品aⅴ导航网站入口 | 亚洲国产美女精品久久久久∴| 另类亚洲自拍| 亚洲精品欧美极品| 亚洲欧美激情诱惑| 黄色亚洲免费| 欧美精品一区二区三区高清aⅴ| 亚洲精品美女在线观看| 亚洲欧美成人一区二区三区| 国产一区二区激情| 欧美sm视频| 亚洲免费一在线| 免费在线观看一区二区| 9色精品在线| 国产亚洲一区二区三区| 欧美—级高清免费播放| 亚洲在线观看免费视频| 麻豆久久精品| 午夜综合激情| 亚洲卡通欧美制服中文| 国产精品试看| 欧美成人免费va影院高清| 亚洲免费综合| 亚洲欧洲在线一区| 久久久久在线| 亚洲欧美日韩精品久久亚洲区| 韩国三级电影久久久久久| 欧美日韩亚洲另类| 久久久亚洲精品一区二区三区| 99国内精品久久| 欧美激情久久久久| 欧美专区第一页| 一区二区三区免费看| 亚洲国产精品成人一区二区| 国产精品入口尤物| 欧美日韩国产综合视频在线观看中文 | 久久精品国产精品亚洲综合| 亚洲免费观看在线观看| 久久在线免费观看| 午夜精品999| 一区二区三区欧美视频| 亚洲激情网站免费观看| 国一区二区在线观看| 国产精品亚洲人在线观看| 欧美激情第一页xxx| 久久这里有精品视频| 欧美诱惑福利视频| 午夜精品亚洲一区二区三区嫩草| aa国产精品| 亚洲精品在线观看视频| 亚洲国产你懂的| 亚洲电影成人| 亚洲成色777777在线观看影院| 久久综合网hezyo| 久久久久久久久一区二区| 欧美一级二区| 久久精品国产一区二区三| 欧美一区二区三区四区夜夜大片| 亚洲尤物视频在线| 午夜精彩视频在线观看不卡 | 欧美一区在线直播| 香蕉成人伊视频在线观看| 亚洲一级二级| 亚洲欧美日本在线| 欧美一区在线直播| 久久精品三级| 玖玖在线精品| 欧美国产激情| 亚洲精品1区| 日韩视频精品在线| 一区二区三区成人| 亚洲欧美日韩一区| 亚洲欧美在线高清| 久久久久国产一区二区三区四区 | 亚洲精品国产精品国自产观看浪潮 | 日韩视频在线永久播放| 一区二区国产日产| 午夜精品久久| 久久狠狠久久综合桃花| 另类尿喷潮videofree| 亚洲大胆女人| 日韩视频―中文字幕| 亚洲一区二区三区在线播放| 午夜精品久久久99热福利| 久久久91精品国产一区二区三区 | 国产精品久久久久99| 国产喷白浆一区二区三区| 国产在线观看91精品一区| 在线国产亚洲欧美| 一区二区三区精品在线| 欧美一区二区三区成人| 欧美成人一区二区在线 | 欧美3dxxxxhd| 一区二区三区国产精品| 欧美亚洲三区| 欧美另类69精品久久久久9999| 国产精品成人va在线观看| 韩国av一区二区三区| 一区二区av| 麻豆精品传媒视频| a4yy欧美一区二区三区| 久久视频免费观看| 国产精品美女主播在线观看纯欲| 黄色亚洲在线| 亚洲欧美综合精品久久成人| 欧美gay视频激情| 亚洲愉拍自拍另类高清精品| 免费一级欧美在线大片| 国产一区二区久久| 中日韩美女免费视频网站在线观看| 久久久福利视频| 一区二区三区 在线观看视| 美玉足脚交一区二区三区图片| 国产精品毛片| 夜夜嗨av一区二区三区免费区| 久热综合在线亚洲精品| 亚洲一区日韩在线|