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

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 閱讀(2896) 評論(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>
            欧美亚洲午夜视频在线观看| 久久久91精品| 日韩视频三区| 欧美日韩综合视频网址| 在线亚洲激情| 亚洲自拍偷拍色片视频| 国产亚洲精品aa| 日韩写真在线| 亚洲午夜激情| 国内久久视频| 欧美亚洲午夜视频在线观看| 午夜欧美精品| 在线精品亚洲| 久久久精品午夜少妇| 久久精品日产第一区二区| 欧美日韩视频一区二区| 先锋影音国产精品| 久久乐国产精品| 国产欧美一区二区三区国产幕精品| 亚洲激情一区二区| 久久久天天操| 午夜精品成人在线| 欧美色精品在线视频| 亚洲女人天堂成人av在线| 欧美一二三区精品| 9国产精品视频| 性色av一区二区怡红| 亚洲精品一二三| 欧美一区二区观看视频| 日韩视频在线免费观看| 羞羞答答国产精品www一本 | 亚洲高清免费视频| 亚洲人精品午夜在线观看| 国产精品毛片高清在线完整版| 亚洲少妇诱惑| 久久国产精品免费一区| 亚洲特黄一级片| 久久一区国产| 久久国产精品一区二区三区| 亚洲免费在线观看| 亚洲精品在线一区二区| 亚洲国产成人精品女人久久久 | 亚洲亚洲精品三区日韩精品在线视频 | 亚洲精品综合| 午夜精品久久久久久久| 亚洲特级片在线| 欧美大片91| 免费视频亚洲| 黑丝一区二区| 久久国产黑丝| 久久精品道一区二区三区| 欧美色中文字幕| 午夜国产精品视频| 欧美另类一区| 亚洲男人的天堂在线观看| 欧美成人久久| 午夜欧美精品久久久久久久| 欧美精品aa| 亚洲第一狼人社区| 亚洲国产高清在线观看视频| 久久狠狠一本精品综合网| 久久激情综合网| 久久婷婷成人综合色| 久久99在线观看| 国产日韩三区| 欧美一级在线播放| 久久激情综合网| 国内揄拍国内精品久久| 久久成人精品无人区| 亚洲美女中文字幕| 欧美成人一区二区三区在线观看| 亚洲无限av看| 国产精品久久久久av| 久久这里只有| 亚洲国产综合视频在线观看| 欧美jjzz| 99天天综合性| 欧美主播一区二区三区美女 久久精品人| 久久久久久9999| 欧美国产日本韩| 中文日韩欧美| 国产美女精品视频免费观看| 欧美专区在线观看一区| 欧美不卡视频| 韩国三级电影久久久久久| 在线中文字幕一区| 久久久久在线| 亚洲乱码久久| 国产欧美日韩亚州综合| 久久久亚洲高清| 久久av一区二区| 1024亚洲| 欧美三级在线视频| 亚洲欧洲精品一区二区精品久久久| 国产一区二区三区免费观看| 老司机午夜精品视频| 一区二区三区欧美日韩| 久久精品视频免费| 一本色道久久综合狠狠躁篇怎么玩| 久久久夜夜夜| 亚洲网址在线| 亚洲国产高清在线| 亚洲午夜在线观看视频在线| 国产资源精品在线观看| 欧美激情综合亚洲一二区| 午夜精品久久久久| 欧美一区二区三区在线视频 | 亚洲欧美日韩一区在线| 一区二区三区高清在线| 国产资源精品在线观看| 欧美精品一区在线观看| 欧美一区=区| 久久久爽爽爽美女图片| 亚洲视频在线观看免费| 欧美人与禽性xxxxx杂性| 欧美在线一级视频| 日韩午夜av在线| 欧美va亚洲va香蕉在线| 欧美在线地址| 亚洲色诱最新| 日韩视频在线观看| 亚洲激情电影中文字幕| 国产一区白浆| 国产精自产拍久久久久久蜜| 欧美极品影院| 欧美h视频在线| 99国产精品国产精品毛片| 欧美二区在线观看| 久久久久国产精品www| 在线播放国产一区中文字幕剧情欧美| 久久久久久久久久看片| 亚洲免费在线| 欧美成人午夜激情视频| 久久久视频精品| 亚洲免费av电影| 最新日韩精品| 亚洲品质自拍| 亚洲激情视频网| 最新亚洲电影| 亚洲精品日本| 妖精视频成人观看www| 国产精品久久久久久久久免费| 先锋影音国产精品| 欧美亚洲在线视频| 欧美一区二区视频在线| 欧美在线一级视频| 久久精品欧美日韩| 一本久道久久综合狠狠爱| 欧美一区网站| 久久久五月天| 蜜桃久久精品乱码一区二区| 免费成人毛片| 亚洲精品1区2区| 亚洲精品一区二区三区蜜桃久| 久久九九热re6这里有精品| 欧美一级专区| 一区二区三区四区五区精品视频| 国产精品亚洲综合| 国产视频欧美视频| 欧美啪啪成人vr| 欧美日韩一区二区三区在线观看免| 欧美在线观看日本一区| 久久天天躁狠狠躁夜夜爽蜜月 | 亚洲欧美视频一区二区三区| 午夜精品视频一区| 久久这里只有精品视频首页| 欧美电影专区| 一区二区不卡在线视频 午夜欧美不卡在| 久久久久**毛片大全| 欧美va天堂在线| 99国产精品视频免费观看一公开| 欧美成人精品h版在线观看| 欧美亚洲在线视频| 免费高清在线一区| 亚洲精品久久久久久久久| 亚洲尤物视频在线| 裸体一区二区三区| 国产精品久久久久久久久免费| 欧美日韩无遮挡| 狠狠色丁香久久综合频道| 亚洲毛片在线观看| 久久激情五月婷婷| 亚洲三级影院| 久久久蜜桃一区二区人| 欧美一区二区免费| 香港久久久电影| 欧美成人一区二区| 国产日韩欧美中文| 一区二区三区四区精品| 麻豆精品视频在线观看| 日韩一区二区精品葵司在线| 久久精品一区二区三区四区 | 正在播放欧美一区| 久久影院午夜片一区| 国产精品久久久久久亚洲调教| 欧美三日本三级少妇三2023| 亚洲成色777777在线观看影院| 在线电影国产精品| 欧美一区二区三区视频免费播放| 性伦欧美刺激片在线观看|