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

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>
            亚洲国产成人av好男人在线观看| 亚洲精品永久免费精品| 亚洲一区二区三区成人在线视频精品| 欧美日产国产成人免费图片| 99ri日韩精品视频| 99热免费精品| 国产精品网站在线播放| 亚洲免费影视第一页| 亚洲一本视频| 国内久久婷婷综合| 亚洲国产成人精品久久| 欧美色视频一区| 欧美伊人久久大香线蕉综合69| 欧美夜福利tv在线| 亚洲黄一区二区三区| 99精品视频免费全部在线| 国产精品久久综合| 裸体歌舞表演一区二区| 欧美二区乱c少妇| 亚洲午夜激情网站| 欧美一区二区大片| 亚洲黄色免费电影| 亚洲一区二区三区影院| 精品1区2区| 亚洲最新中文字幕| 韩国av一区二区三区在线观看| 亚洲国产精品久久精品怡红院| 欧美精品国产精品日韩精品| 午夜国产精品影院在线观看| 久久久久久亚洲精品杨幂换脸| 日韩亚洲欧美成人一区| 欧美一级大片在线免费观看| 日韩视频免费| 久久精品视频在线免费观看| 亚洲美女网站| 久久精品国产免费观看| 亚洲午夜精品久久久久久浪潮 | 亚洲第一页中文字幕| 亚洲精品欧美在线| 影音先锋亚洲一区| 亚洲调教视频在线观看| 亚洲人成网在线播放| 午夜视频在线观看一区二区三区 | 国产精品久久九九| 欧美国产高潮xxxx1819| 国产乱码精品一区二区三区av| 亚洲高清免费视频| 伊人激情综合| 午夜一区二区三区不卡视频| 亚洲私人影吧| 欧美精品123区| 欧美大片在线观看| 国产一区在线播放| 亚洲一区区二区| 亚洲一区二区三区免费观看 | 亚洲一级片在线看| 亚洲毛片视频| 蜜桃av综合| 欧美成人精品激情在线观看| 国模套图日韩精品一区二区| 亚洲午夜黄色| 亚洲欧美中日韩| 国产精品高清免费在线观看| 亚洲美女视频网| 一区二区欧美视频| 欧美精品在线免费播放| 亚洲国产精品电影| 亚洲精品1区| 欧美aⅴ一区二区三区视频| 欧美jizzhd精品欧美喷水 | 欧美大片一区二区三区| 免费观看日韩av| 樱花yy私人影院亚洲| 久久久精品一区| 欧美成人中文| 亚洲激情婷婷| 欧美日韩精品一区二区天天拍小说| 亚洲丶国产丶欧美一区二区三区| 最新国产拍偷乱拍精品| 欧美国产乱视频| 一区二区精品在线观看| 亚洲欧美日韩一区二区在线| 国产精品一区二区视频| 午夜一区二区三区在线观看| 久久久国产91| 亚洲国产日韩欧美在线图片| 欧美激情在线| 一本久久综合亚洲鲁鲁五月天| 午夜欧美大尺度福利影院在线看| 国产欧美日韩视频在线观看| 久久高清免费观看| 亚洲第一视频| 亚洲欧美区自拍先锋| 国产一区二区欧美| 美女日韩欧美| 亚洲少妇诱惑| 免费视频一区| 亚洲神马久久| 激情av一区| 欧美日韩视频| 久久成人一区| 9色国产精品| 久久综合网hezyo| 中文亚洲免费| 国内精品久久久久久久影视蜜臀 | 狠狠综合久久av一区二区老牛| 美女精品在线观看| 中文日韩在线| 欧美电影在线播放| 亚洲嫩草精品久久| 最新成人av网站| 国产伦理一区| 欧美日韩精品免费看| 欧美影视一区| 国产精品99久久久久久人| 美女国内精品自产拍在线播放| 亚洲一区二区少妇| 亚洲二区视频| 国产欧美日韩综合一区在线观看| 老色鬼精品视频在线观看播放| 亚洲一区二区黄| 亚洲精品国精品久久99热一| 久久久噜噜噜久噜久久| 亚洲一区二区三区在线| 亚洲欧洲一区二区在线播放| 国内成+人亚洲+欧美+综合在线| 欧美日韩国产一区二区三区| 久久一区二区精品| 欧美资源在线观看| 午夜精品久久久久久久蜜桃app| 亚洲日韩中文字幕在线播放| 农村妇女精品| 久久九九热免费视频| 亚洲欧美网站| 亚洲视频大全| 一区二区欧美视频| 日韩视频一区二区三区在线播放| 狠狠色丁香久久综合频道| 国产伦精品免费视频| 欧美日韩天天操| 欧美久久久久久久久久| 米奇777超碰欧美日韩亚洲| 久久久久久久久综合| 久久久久久国产精品一区| 欧美在线播放视频| 久久精品最新地址| 久久精品人人做人人综合| 久久国产精品毛片| 久久久久欧美精品| 久久亚洲精品一区| 欧美成人精品在线视频| 欧美激情第五页| 欧美日韩在线一区二区| 欧美日韩色综合| 国产精品二区在线| 国产精品一区二区视频| 国产欧美在线视频| 激情一区二区三区| 亚洲精品日本| 亚洲小视频在线观看| 欧美亚洲一区三区| 久久人人爽人人爽爽久久| 老司机一区二区三区| 欧美激情中文不卡| 亚洲精品你懂的| 亚洲人成小说网站色在线| 一区二区三区福利| 亚洲欧美日韩精品久久奇米色影视| 亚洲在线免费观看| 久久久99久久精品女同性| 欧美激情综合色| 国产精品日韩一区| 亚洲电影免费| 亚洲尤物影院| 久久久久久一区二区三区| 欧美大胆a视频| 中文亚洲免费| 老司机aⅴ在线精品导航| 欧美日韩一卡二卡| 黄色成人在线| 在线一区二区日韩| 久久久天天操| 夜夜嗨av一区二区三区四季av| 香蕉免费一区二区三区在线观看| 裸体女人亚洲精品一区| 欧美日韩亚洲高清| 激情成人在线视频| 亚洲一区二区日本| 免费观看成人| 亚洲欧美日韩中文播放| 欧美电影美腿模特1979在线看| 国产精品欧美日韩| 亚洲精品中文字| 久久久综合网站| 中国日韩欧美久久久久久久久| 老牛国产精品一区的观看方式| 国产精品亚洲片夜色在线| 亚洲精品久久久久久久久久久久| 久久久久久夜精品精品免费| 夜夜嗨av色一区二区不卡|